This file contains hidden or 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 a group | |
CREATE ROLE readaccess; | |
-- Grant access to existing tables | |
GRANT USAGE ON SCHEMA public TO readaccess; | |
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess; | |
-- Grant access to future tables | |
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess; |
This file contains hidden or 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
from __future__ import division | |
import numpy as np | |
RADIUS_OF_EARTH_IN_KM = 6371.01 | |
def haversine(lat1, lon1, lat2, lon2): | |
""" | |
Utility to calcutlate distance between two pointtodo explain regarding height | |
coverting from geodisc co-ordinate to cartestian gives errors when distances are further apart |
This file contains hidden or 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
import time.sleep | |
import zmq | |
context = zmq.Context() | |
socket = context.socket(zmq.PUB) | |
socket.bind('tcp://127.0.0.1:2000') | |
# Allow clients to connect before sending data | |
sleep(10) | |
socket.send_pyobj({1:[1,2,3]}) |
This file contains hidden or 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 | |
# Author: Carl Loa Odin <[email protected]> | |
# https://gist.github.com/loa/435da12af9494a112daf | |
test_res=0 | |
function get_git_version() { | |
version=$(git describe --tags 2> /dev/null) | |
if [ $? -eq 128 ]; then | |
# Return initial version incase no tags is found |
This file contains hidden or 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
upstream transmission { | |
server 127.0.0.1:9091; #Transmission | |
} | |
server { | |
listen 443 ssl spdy; | |
server_name example.com; | |
auth_basic "Server Restricted"; | |
auth_basic_user_file /var/www/myWebSite/web/.htpasswd; | |
# Path to the root of your installation |
This file contains hidden or 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 swapon -s | grep -q /mnt/swapfile | |
then | |
echo "Swapfile already mounted" | |
else | |
if [ -e /mnt/swapfile ] | |
then | |
echo "Mounting swapfile" | |
swapon /mnt/swapfile |
This file contains hidden or 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
// You create your bookmarklet by instantiating | |
// a new Bookmarklet function, then pass in the options like so. | |
// This example checks to see if the var is already defined, and makes | |
// sure not to overwrite it. This could happen if the user clicks on | |
// the bookmarklet more than once. | |
MyBookmarklet = MyBookmarklet || (MyBookmarklet = new Bookmarklet({ | |
// debug: true, // use debug to bust the cache on your resources | |
css: ['/my/style.css'], | |
js: [], |
This file contains hidden or 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 transliterate(my_text VARCHAR) RETURNS varchar AS $$ | |
DECLARE | |
text_out VARCHAR DEFAULT ''; | |
BEGIN | |
text_out := my_text; | |
text_out := translate(text_out, 'àâäåáăąãā', 'aaaaaaaaa'); | |
text_out := replace(text_out, 'æ', 'ae'); | |
text_out := translate(text_out, 'çċćčĉ', 'ccccc'); | |
text_out := translate(text_out, 'éèėëêēĕ', 'eeeeeee'); | |
text_out := translate(text_out, 'îïìíī', 'iiiii'); |
This file contains hidden or 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 slugify(title VARCHAR) RETURNS varchar AS $$ | |
BEGIN | |
RETURN trim(both '-' from regexp_replace(lower(transliterate(title)), '[^a-z0-9]+', '-', 'g')); | |
END; | |
$$ LANGUAGE plpgsql; |