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
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 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
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
// 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
sudo defaults write /Library/Preferences/com.apple.loginwindow HiddenUsersList -array-add dlt |
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.extract_nth_dow(d date) RETURNS integer | |
AS $$ | |
-- Calculates and returns the Nth day of the week for the given date. | |
SELECT (EXTRACT(day FROM d)::INTEGER - 1) / 7 + 1; | |
$$ LANGUAGE sql; |
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 is_leap_year(year integer) | |
RETURNS BOOLEAN AS $$ | |
SELECT ($1 % 4 = 0) AND (($1 % 100 <> 0) or ($1 % 400 = 0)) | |
$$ LANGUAGE sql IMMUTABLE STRICT; | |
CREATE OR REPLACE FUNCTION is_leap_year(date date) | |
RETURNS BOOLEAN AS $$ | |
SELECT DATE_PART('month', DATE_TRUNC('year', $1)+'1 months 28 days'::INTERVAL) = 2; | |
$$ LANGUAGE sql IMMUTABLE STRICT; |
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 diff_elements(anyarray, anyarray) | |
returns anyarray language sql immutable as $$ | |
select array( | |
select unnest($2) | |
except | |
select unnest($1) | |
);$$; | |
create operator - ( | |
procedure = diff_elements, |
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
# OS X 10.10 | |
sudo discoveryutil udnsflushcaches; sudo discoveryutil mdnsflushcache | |
# OS X 10.9 | |
dscacheutil -flushcache; sudo killall -HUP mDNSResponder | |
# OS X 10.7-10.8 | |
sudo killall -HUP mDNSResponder | |
# OS X 10.5-10.6 |