Skip to content

Instantly share code, notes, and snippets.

@nikolas
nikolas / upsert_table_vararg.sql
Created September 11, 2012 23:06
upsert_table_vararg
-- This function is a generalized way to upsert multiple optional fields of a
-- table based on the hstore param "my_params"
create or replace function upsert_table_vararg(
my_table_name text,
my_id_col_name text,
my_params hstore
)
returns void as $$
declare vkey text;
declare vquery text;
@nikolas
nikolas / fortchan.js
Created September 7, 2012 15:36
js functions for fortchan.org
function d() {
return Math.random() >= 0.5;
}
function myLoop() {
var interval = setInterval(function() {
var str = '`~=~`~=+=~`~``~=~`~-+==~`~-_-~`:';
if ($('body')) {
var str = $('body').text();
}
@nikolas
nikolas / kaomoji.js
Created September 6, 2012 22:12
js functions for kaomojiworld.herokuapp.com
function myLoop() {
var interval = setInterval(function() {
$.post('/mojis', { 'moji[content]': 'hi' });
/*$.post('/users', {
'user[username]': Date(),
'user[password]': 'sillypass',
'user[password_confirmation]': 'sillypass'
});*/
}, 500);
}