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
--- vim: set nosta noet ts=4 sw=4 ft=lua: | |
--- | |
--- Hello. I'm a partitioner that puts rows into dated tables, segmented by date ranges. | |
--- Install me like so on your master table, as a db admin user (for the security definer): | |
--- | |
--- CREATE TRIGGER auto_partition BEFORE INSERT ON [table] FOR EACH ROW EXECUTE PROCEDURE auto_partition() | |
--- | |
CREATE OR REPLACE FUNCTION clear_partition_cache() | |
RETURNS boolean |
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
-- | |
-- PostgreSQL database dump | |
-- | |
-- Dumped from database version 9.1.1 | |
-- Dumped by pg_dump version 9.1.1 | |
-- Started on 2011-11-02 16:53:36 EET | |
SET statement_timeout = 0; | |
SET client_encoding = 'UTF8'; |
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
-------------------------------------------------------------------------------- | |
-- PHP-style serialization in PostgreSQL | |
-- Making a better situation of someone else's bad decision | |
-- See examples at bottom | |
-------------------------------------------------------------------------------- | |
-------------------------------------------------------------------------------- | |
-- Serialization function per type | |
CREATE OR REPLACE FUNCTION php_serialize(boolean) RETURNS text |
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
# This method finds related articles using Jaccard index (optimized for PostgreSQL). | |
# More info: http://en.wikipedia.org/wiki/Jaccard_index | |
class Article < ActiveRecord::Base | |
def related(limit=10) | |
Article.find_by_sql(%Q{ | |
SELECT | |
a.*, | |
( SELECT array_agg(t.name) FROM taggings tg, tags t |
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
<?php | |
class ImageDiff { | |
// not bigger 20 | |
private $matrix = 15; | |
public function getImageInfo($image_path){ | |
list($width, $height, $type, $attr) = getimagesize($image_path); | |
$image_type = ''; |
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
# example location parts of nginx.conf | |
# add your own AWS keys, server lines etc, and set your aws domains, paths | |
http { | |
# you will need the luacrypto in the cpath, download from http://luacrypto.luaforge.net/ | |
lua_package_cpath "/home/justin/lua/luacrypto-0.2.0/src/l?.so.0.2.0;;"; | |
server { | |
listen 80; |
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
{ | |
"vars": { | |
"@gray-base": "#000", | |
"@gray-darker": "lighten(@gray-base, 13.5%)", | |
"@gray-dark": "lighten(@gray-base, 20%)", | |
"@gray": "lighten(@gray-base, 33.5%)", | |
"@gray-light": "lighten(@gray-base, 46.7%)", | |
"@gray-lighter": "lighten(@gray-base, 93.5%)", | |
"@brand-primary": "darken(#428bca, 6.5%)", | |
"@brand-success": "#5cb85c", |
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 random_string_pllua(string_length INTEGER, lowercase BOOLEAN DEFAULT false) RETURNS text | |
LANGUAGE pllua VOLATILE | |
AS $$ | |
-- math.randomseed(socket.gettime()) -- seems to be needed by luajit only | |
local alnum = { | |
'0','1','2','3','4','5','6','7','8','9', | |
'a','b','c','d','e','f','g','h','i','j','k','l','m', | |
'n','o','p','q','r','s','t','u','v','w','x','y','z', | |
'A','B','C','D','E','F','G','H','I','J','K','L','M', | |
'N','O','P','Q','R','S','T','U','V','W','X','Y','Z' |
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
ko.bindingHandlers.tagsinput = { | |
init: function(element, valueAccessor, allBindings) { | |
var options = allBindings().tagsinputOptions || {}; | |
var value = valueAccessor(); | |
var valueUnwrapped = ko.unwrap(value); | |
var el = $(element); | |
el.tagsinput(options); | |