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
PREPARE test AS | |
WITH RECURSIVE T(n) AS ( | |
SELECT date_trunc('month', $1::date)::date AS start | |
UNION | |
SELECT n+1 FROM T WHERE n < date_trunc('month', $1)::date + '1 month'::interval - '1 day'::interval | |
) | |
SELECT * FROM T; | |
EXECUTE test('15 nov 2012'); |
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
if(is_dir($currentPath)) { | |
?><table class="file-list"><? | |
$scan = scandir($currentPath); | |
array_shift($scan); | |
array_shift($scan); | |
foreach($scan as $name) { | |
if($name[0] != '.' && $name[0] != '_') { | |
$path = $currentPath.'/'.$name; | |
$icon = 'unknown'; | |
if(is_dir($path)) { |
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
window.addEventListener('load', function(event) { | |
// for each form on the page | |
for(i=0; i < document.forms.length; i++) { | |
f = document.forms[i]; | |
// add a 'submit' event listener | |
f.noValidate = true; | |
// except for safari, the event never triggers without noValidate=true | |
f.addEventListener('submit', function(event) { | |
// if form is not valid don't let it submit | |
if(!event.target.checkValidity()) { |
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 | |
// Originally by Andrew Moore | |
// Src: http://stackoverflow.com/questions/4795385/how-do-you-use-bcrypt-for-hashing-passwords-in-php/6337021#6337021 | |
// | |
// Heavily modified by Robert Kosek, from data at php.net/crypt | |
class Bcrypt { | |
private $rounds; | |
private $prefix; |
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
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false | |
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool true |
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 bcrypt($input, $salt=null, $rounds=12) { | |
if($rounds < 4 || $rounds > 31) $rounds = 12; | |
if(is_null($salt)) $salt = sprintf('$2a$%02d$', $rounds).substr(str_replace('+', '.', base64_encode(pack('N4', mt_rand(), mt_rand(), mt_rand(), mt_rand()))), 0, 22); | |
return crypt($input, $salt); | |
} | |
?> |
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
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user | |
killall Finder |
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
defaults write com.apple.finder QLEnableTextSelection -boolean YES | |
killall Finder |
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 mjpeg_grab_frame($url) { | |
$f = fopen($url, 'r'); | |
if($f) { | |
$r = null; | |
while(substr_count($r, "\xFF\xD8") != 2) $r .= fread($f, 512); | |
$start = strpos($r, "\xFF\xD8"); | |
$end = strpos($r, "\xFF\xD9", $start)+2; | |
$frame = substr($r, $start, $end-$start); | |
fclose($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
CREATE OR REPLACE FUNCTION updated() | |
RETURNS TRIGGER AS $$ | |
BEGIN | |
NEW.updated = NOW(); | |
RETURN NEW; | |
END; | |
$$ LANGUAGE 'plpgsql'; | |
CREATE TRIGGER updated BEFORE UPDATE ON projects FOR EACH ROW EXECUTE PROCEDURE updated(); |
OlderNewer