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
// depends on jquery | |
function filterSelectWithField(selectList, searchField) { | |
selectList = $(selectList); | |
searchField = $(searchField); | |
options = selectList.find('option').clone(); | |
timer = null; | |
function sanitize(str) { | |
return $.trim(str).replace(/\s+/g, ' ').toLowerCase(); |
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 TABLE customers_audit AS ( | |
id SERIAL NOT NULL UNIQUE PRIMARY KEY, | |
created TIMESTAMPTZ NOT NULL DEFAULT NOW(), | |
before HSTORE, | |
after HSTORE | |
); | |
CREATE FUNCTION trigger_customers_audit RETURNS TRIGGER LANUAGE plpgsql AS $$ | |
INSERT INTO customers_audit(before, after) | |
SELECT hstore(OLD), hstore(NEW); |
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 trigger_updated RETURNS TRIGGER LANGUAGE plpgsql AS $$ | |
BEGIN | |
NEW.updated = NOW(); | |
RETURN NEW; | |
END; | |
$$ | |
CREATE TRIGGER updated BEFORE UPDATE ON payment | |
OR EACH ROW WHEN (OLD.* IS DISTINCT FROM NEW.*) | |
EXECUTE PROCEDURE trigger_updated(); |
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
sudo /Applications/Install\ OS\ X\ Mavericks.app/Contents/Resources/createinstallmedia \ | |
--volume /Volumes/Untitled \ | |
--applicationpath /Applications/Install\ OS\ X\ Mavericks.app \ | |
--nointeraction |
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 public.orthodrome_km(lat1 numeric, lon1 numeric, lat2 numeric, lon2 numeric) | |
RETURNS double precision | |
LANGUAGE plpgsql | |
AS $function$ | |
BEGIN | |
return acos(sin(radians(lat1))*sin(radians(lat2))+cos(radians(lat1))*cos(radians(lat2))*cos(radians(lon2)-radians(lon1)))*6371; | |
END; | |
$function$ |
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(); |
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
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
/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
<?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); | |
} | |
?> |