
No idea how to solve hard IT problems? Try to do something new. Open your mind!
/Stanislaw Wyspianski, "The creation of the world", stained glass, Franciszkanow church, Krakow, PL/
Talking uses energy, doing creates it
current perl:
$foo = [ map { ... } @$bar ]
better perl:
$foo = map { } $bar
%hash = (foo => 42);
$hash{foo} # where is hash sign, % ?
@list = qw/foo bar baz/;
$list[1] # where is list sign, @ ?
$list[1][2] # wolf
$$list[1][2] # dog1
$list->[1][2] # dog2
$list->[1]->[2] # dog3
$ref = \@list;
$ref = [@ref]
# maybe it is @list?
$ref = [ $some->method ]
# or maybe it is %hash?
$ref = { $some->method }
# could be better to make something like
$ref = $some->method->return_as_hashref
$ref = $some->method->return_as_arrayref
Controller app::foo;
sub index : Private {
my ($self, $c, $param1) = @_;
}
sub show : Local {
my ($self, $c, $param1) = @_;
}
sub index : LocalRegex('^(.*)$') {
my ( $self, $c ) = @_;
my ($param1) = @{ $c->req->captures };
}
ALTER TABLE `news` CHANGE `body` `body` BLOB NULL DEFAULT NULL; ALTER TABLE `news` CHANGE `body` `body` TEXT CHARACTER SET utf8 NULL DEFAULT NULL;
$wide_char_string = Encode::decode_utf8($octets)
Encode::is_utf8($checked_string)
length($octets) > length($wide_char_string)
(octet_string eq unicode_string) == falseYou cannot compare such strings without decode/encode, they are natively different!
{linux, osx, freebsd, solaris}$ groups
{windows - active directory}> dsquery user -samid %USERNAME%|dsget user -memberof
{linux, osx, bsd}$ du -sh
{linux}$ du --max-depth=1
{osx, bsd}$ du -d1
{SunOS}$ du
{linux}$ du --max-depth=1 -kx|sort -n
{osx, bsd}$ du -d1 -kx|sort -n
{linux}$ find . -regextype posix-extended -type f -regex ".*\.(java|class)"
{osx, bsd}$ find -E . -type f -regex ".*\.(java|class)"
{linux, osx}$ lsof
{freebsd}$ fstat
{linux}$ vmstat 3
{osx, bsd}$ iostat 3
{linux}$ free
{freebsd}$ swapinfo
{osx}$ vm_stat
{osx}$ top -l 1 -s 0 -n 0
{linux}$ netstat -apne --inet
{osx}$ lsof -i
{freebsd}$ sockstat
{SunOS}$ netstat
{windows}$ netstat -b
netstat -b -v # slower but with tree of dependencies
{linux}$ lsmod
{osx}$ kextstat
{freebsd}$ kldstat
{linux}$ modprobe SomeModule
{freebsd}$ kldload SomeModule
{linux}$ rmmod SomeModule
{freebsd}$ kldunload SomeModule
{linux}$ strace
{osx}$ dtrace
{freebsd}$ truss
(strace is also available in /usr/ports/devel/strace)
{linux}$ ldconfig -p
{freebsd}$ ldconfig -r
{freebsd}$ pkg_info -W /path/to/checked_file
{debian ubuntu}$ dpkg -S /path/to/checked_file
{redhat centos}$ rpm -qf /path/to/file
{osx, for brew}$ ls -l `which node`|perl -lane '{print $F[-1]}'
OsX - it shows the original brew package/file this command is linked to
{linux}$ apt-cache search your_name
{freebsd}$ cd /usr/ports; make search key=your_name
make search name=pear display=name,path
you can also try simple locate (only in package names):
{freebsd}$ locate -i your_name | grep "/usr/ports/"
{redhat centos}$ yum search name
yum provides name
{debian ubuntu}$ apt-get install package_name
{redhat centos}$ yum install name
{freebsd}$ pkg_add -r package_name
{windows}$ msiexec /i package.msi
{osx}$ ???
In FreeBSD you have packages made in distribution release time - unfortunately there are no binary upgrades for released version){debian ubuntu}$ apt-get update; apt-get upgrade
{redhat centos}$ yum update
{debian ubuntu}$ apt-src
{freebsd}$ cd /usr/ports/path/package; make install clean
{osx}$ use brew or macports
Couldn't instantiate component "app::Model::app", "->config->{schema_class} must be defined for this model
app.yaml
app_local.yaml
$> Python
>>> foo = "bla bla bla"
>>> foo.upper()
'BLA BLA BLA'
>>> foo.len()
Traceback (most recent call last):
File "", line 1, in ?
AttributeError: 'str' object has no attribute 'len'
>>> len(foo)
11
irb> foo.upcase
=> "BLA BLA BLA"
irb> foo.length
=> 11
var = 123 # string
$var = 123 # global variable
@var = 123 # class variable
@@var = 123 # package variable
def class1
attr_reader :duration
end
# which is a shortcut of:
def class1
attr_reader(:duration)
end
# which is a shortcut of:
def class1
def duration
@duration
end
end
# which is a shortcut of:
def class1
def duration
return(@duration)
end
end