Calculate Thanksgiving Date
strtotime("3 weeks thursday",mktime(0,0,0,11,1,$year)
2741 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)
Gabe da Silveira http://www.darwinweb.net/
strtotime("3 weeks thursday",mktime(0,0,0,11,1,$year)
(?m)^@@.*?^(?=@@)
/** * For select menus. */ function select_from_menu($menu,$choices,$deselect=true) { if ($deselect) $menu = preg_replace('/ selected(="selected")?/','',$menu); if(!is_array($choices)) { $menu = preg_replace('/(value="'.preg_quote($choices).'")/',"$1 selected=\"selected\"",$menu); } else foreach($choices as $value) { $menu = preg_replace('/(value="'.preg_quote($value).'")/',"$1 selected=\"selected\"",$menu); } return $menu; } /** * For radio buttons and checkboxes. */ function check_from_menu($menu,$choices,$deselect=true) { if ($deselect) $menu = preg_replace('/ checked(="checked")?/','',$menu); if(!is_array($choices)) { $menu = preg_replace('/(value="'.preg_quote($choices).'")/',"$1 checked=\"checked\"",$menu); } else foreach($choices as $value) { $menu = preg_replace('/(value="'.preg_quote($value).'")/',"$1 checked=\"checked\"",$menu); } return $menu; }
name: lighttpd checkcommand: /bin/ps axww checkregex: /lighttpd/ onfailcommand: /home/USERNAME/lighttpd/restart.rb checkinterval: 600 aftercommandwait: 120 name: lighttpd-external checkcommand: /usr/local/bin/curl -I http://YOURDOMAIN.com:YOURPORT checkregex: /^HTTP/s onfailcommand: /usr/bin/killall -9 lighttpd; /home/USERNAME/lighttpd/restart.rb checkinterval: 600 aftercommandwait: 120
#!/usr/local/bin/ruby #Modified from Julik's original code posted to TextDrive forums. pstab = `ps axww` def kill_fcgi_proc(line) its = line.strip.split(/\s+/) pid = its[0] puts "KILLING #{line}" `kill -9 #{pid}` sleep(3) end if pstab =~ /\/usr\/local\/sbin\/lighttpd -f/ puts "Lighttpd still running." else pstab.scan(/^.*dispatch\.fcgi\s*$/) do |line| kill_fcgi_proc line end pstab = `ps axww` if pstab =~ /dispatch\.fcgi/ puts "Error, rogue dispatch.fcgi's still pissing jason off." else puts "Rogue dispatch.fcgi's cleared, starting lighty!" `/usr/local/sbin/lighttpd -f /home/USERNAME/lighttpd/lighttpd.conf` end end