Skip to content

Instantly share code, notes, and snippets.

# Unique, atomic sequential number generator using MongoMapper, MongoDB and Ruby.
# Usage:
# Helper::Sequence.next_value(:my_seq)
# => 1
# Helper::Sequence.next_value(:my_seq)
# => 2
# Helper::Sequence.next_value(:my_other_seq)
# => 1
# Helper::Sequence.next_value(:my_seq)
# => 3
@philfreo
philfreo / QueryStringTest.php
Created June 22, 2011 19:44
add_querystring_var() and remove_querystring_var() improvements, with tests
<?php
class QueryStringTest extends PHPUnit_Framework_TestCase {
/**
* @covers remove_querystring_var
*/
public function testRemoveQueryStringVar() {
// tests without any other querystring params
@mokagio
mokagio / sticky.css
Created February 26, 2012 20:53
Twitter Bootstrap + Sticky Footer + Fixed Nav Bar
html, body, .container, .content {
height: 100%;
}
.container, .content {
position: relative;
}
.proper-content {
padding-top: 40px; /* >= navbar height */
@martinsik
martinsik / chat-frontend.js
Last active September 24, 2024 14:54
Node.js chat frontend and server
$(function () {
"use strict";
// for better performance - to avoid searching in DOM
var content = $('#content');
var input = $('#input');
var status = $('#status');
// my color assigned by the server
var myColor = false;
@philfreo
philfreo / gist:2321650
Created April 6, 2012 17:58
mysqldump cron
#!/bin/sh
# CRON
## delete encrypted backups older than 5 days
#55 3 * * * find /path/to/backups-enc -mtime +5 -exec rm {} \;
## delete un-encrypted backups older than 1 days
#55 3 * * * find /path/to/backups -mtime +0 -exec rm {} \;
## database dump at 4am UTC = 8pm PST (9pm PDT)
#0 4 * * * /path/to/this/script
@icebreaker
icebreaker / tiny_git_webserver.py
Created August 11, 2012 08:02 — forked from williame/tiny_git_webserver.py
A super-simple web-server to serve up files in a git (bare) repo
import os, subprocess, base64
import tornado.ioloop
import tornado.web
from tornado.options import define, options, parse_command_line
define("port",default=8888,type=int)
define("branch",default="master")
define("access",type=str,multiple=True)
class MainHandler(tornado.web.RequestHandler):