Nile. Length: 6852 km. Linear: 3700 km. Sinuosity: 1.85. Amazon. Length: 6448 km. Linear: 3000 km. Sinuosity: 2.15.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ $# -ne 1 ]; then | |
echo "Usage: $(basename $0) COFFEEFILE" | |
echo " - Compile COFFEEFILE into a minified javascript on file changes." | |
exit 64 | |
fi | |
COFFEE=coffee | |
UGLIFYJS=uglifyjs |
This gist will contain some example code using SQL window functions. The code is made for PostgreSQL 9.1.9 and may or may not be compatible to other databases. MySQL is certainly not supported as it currently (2014) lacks support for window functions alltogether. The code creates, modifies and deletes some tables (see 05_cleanup.sql
), so make sure to run it in a fresh db if you are not sure this does not mess with your existing data.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# These three do the same thing: | |
[:type, :action].each_with_object({}) {|m,h| h[m] = order.send(m)} | |
[:type, :action].inject({}) {|h,m| h[m] = order.send(m); h} | |
Hash[[:type, :action].map {|m| [m, order.send(m)]}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Files ~ "^\.(htaccess|htpasswd)$"> | |
deny from all | |
</Files> | |
Options Indexes | |
AuthUserFile /etc/apache2/.htpasswd | |
AuthGroupFile /dev/null | |
AuthName "Temporarily blocked! Please contact your webmaster" | |
AuthType Basic | |
require valid-user | |
order deny,allow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SwitchTypeOfStateToEnum < ActiveRecord::Migration | |
class Order < ActiveRecord::Base | |
enum state: [ :pending, :running, :success, :failed ] | |
end | |
def change | |
rename_column :orders, :state, :state_old | |
add_column :orders, :state, :integer | |
reversible do |dir| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function acc(i) { | |
return function(d) { | |
return d[i]; | |
} | |
} | |
function ch(a,b) { | |
return function(d) { | |
return a(b(d)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
urxvt -depth 32 -bg rgba:ff00/f900/db00/dddd -bd rgba:ff00/f800/d000/dddd -fg rgba:0000/0000/0000/eeee -sr -scrollstyle plain -geometry 140x37+$[ 50 + $[ RANDOM % 100 ]]+$[ 500 + $[ RANDOM % 200 ]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function bxt_fileList($d,$x=false){ | |
foreach(scandir($d) as $f)if(is_file($d.'/'.$f)&&(!$x||preg_match('/'.$x.'$/i',$f)))$l[]=$f; | |
return $l; | |
} | |
// silly "ninja" comment code from | |
// http://de3.php.net/manual/en/function.scandir.php#90628 | |
function file_list($d,$x){ | |
foreach(array_diff(scandir($d),array('.','..')) as $f)if(is_file($d.'/'.$f)&&(($x)?ereg($x.'$',$f):1))$l[]=$f; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({abc:1,def:1,jkl:1}[xyz]) | |
// nearly the same as: | |
( xyz=="abc" || xyz=="def" || xyz=="jkl" ) | |
// and.... | |
(function(){switch(pn) { | |
case "prv":return "previous"; | |
case "nxt":return "next"; | |
}})() |
OlderNewer