alias please='sudo $(history 2 | head -n1 | perl -pe "s/^\s*\d+\s+//")'Update:
alias please='sudo $(fc -nl -1)'
alias please='sudo $(history 2 | head -n1 | perl -pe "s/^\s*\d+\s+//")'alias please='sudo $(fc -nl -1)'
.length but objects don't.param() to get a truthy value for the object: if ($.param(obj)) {
// obj has stuff
}
empty() Considered Harmful
empty().A variable is considered empty if it does not exist or if its value equals FALSE. empty() does not generate a warning if the variable does not exist.empty($foo)
$foo == FALSE
! $foo
empty() does not generate a warning if the variable does not exist.class Foo {
public $bar;
protected $_foo;
private $_baz;
}
$obj of type Foo one can access $obj->bar but not $obj->_foo or $obj->_baz without being lexically within the class (for $_baz) or a subclass (for $_bar) of Foo.$obj->bazinga = 1;
bazinga is not even declared on class Foo, the correct response for any self-respecting object system would be to tell you to sod off and stop playing the fool.public function value($val = null) {
if ($val !== null) {
$this->_value = $val;
}
return $this->_value;
}
$_value is no business of the user's. The class defined no public property '$value' but, when I did this:$obj->value = 'foo';
__get to get, or __set to set, and if they do nothing it just goes ahead and creates something for you.strftime can't do, but you can't put your format codes inside other strings so you always end up resorting to strftime anyway.strftime you won't have culture shock when you use literally any other language ever written.#!/bin/bash
find "$HOME/wallpapers" -type f \
-exec sh -c 'file "$1" | grep -q "image"' '{}' '{}' \; \
-a -fprint wallpapers-cache-new \
\
&& mv wallpapers-cache-new wallpapers-cache
wallpapers-cache, and the wallpaper switcher itself uses that:#!/bin/bash WALLPAPERS="$HOME/wallpapers-cache" export DISPLAY=:0 r=`rl -c1 $WALLPAPERS` gsettings set org.gnome.desktop.background picture-uri "file://$r"
rl comes from the randomize-lines package in Debian-based OSes.