Skip to content

Instantly share code, notes, and snippets.

@romannurik
romannurik / DashboardLayout.java
Created March 23, 2011 05:06
A custom Android layout class that arranges children in a grid-like manner, optimizing for even horizontal and vertical whitespace.
/*
* ATTENTION:
*
* This layout is now maintained in the `iosched' code.google.com project:
*
* http://code.google.com/p/iosched/source/browse/android/src/com/google/android/apps/iosched/ui/widget/DashboardLayout.java
*
*/
/*
@silvein
silvein / pre-commit
Created March 26, 2011 07:52
This is a Git pre-commit hook I'm developing to make sure local submodule changes are pushed before committing. This would probably be better as a pre-push hook, but there does not appear to be a facility for that.
#!/bin/bash
function git_submodule_unchanged () {
SUB_MODULE=$1
GSC_RC=0
pushd $SUB_MODULE > /dev/null
SUB_BRANCH=$(git branch | grep '*' | cut -d' ' -f 2)
if [[ "$(git log --pretty=oneline origin/${SUB_BRANCH}..${SUB_BRANCH})" != "" ]]; then
GSC_RC=1
fi
@laverdet
laverdet / binlog-tailer.js
Created May 6, 2011 07:56
MySQL binlog tailer
"use strict";
this.MysqlBinlogTailer = MysqlBinlogTailer;
var EventEmitter = require('events').EventEmitter;
var fs = require('fs');
var path = require('path');
/**
* Tails a Mysql binlog and emits an event for every query executed.
*/
@rwaldron
rwaldron / gist:1007531
Created June 4, 2011 03:16 — forked from voodootikigod/gist:1007426
BS ≈ BreakfastScript
Conditionals
( false :)
console.log "if"
:( true )
console.log "else if"
:()
console.log "else"
@naholyr
naholyr / gist:1048660
Created June 27, 2011 10:45
Quick 'n dirty Bash completion for "pman"
We couldn’t find that file to show.
@tj
tj / equivalent.js
Created August 24, 2011 00:21
example of backbone-style routing with Express
app.get('/help', function(req, res){
res.send('some help');
});
app.get('/search/:query/p:page', function(req, res){
var query = req.params.query
, page = req.params.page;
res.send('search "' + query + '", page ' + (page || 1));
});
@naholyr
naholyr / 01-db-test.js
Created August 27, 2011 09:39
REST avec NodeJS & Express - Tests Unitaires
var assert = require('assert')
, db = require('../db')({namespace:'bookmarks-test-db'})
, the_bookmark = {}
require('vows')
.describe('bookmarks-db')
.addBatch({
"Initialize": {
topic: function () {
db.deleteAll(this.callback);
@naholyr
naholyr / app.js
Created August 27, 2011 10:13
REST avec NodeJS & Express - Application
var express = require('express')
, app = module.exports = express.createServer()
app.configure(function () {
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(app.router);
app.use(express.static(__dirname + '/public'));
});
app.configure('development', function () {
@naholyr
naholyr / update-sublime-text.sh
Created September 6, 2011 15:27
Install or update Sublime Text from web site
#!/bin/bash
# Requirements: sed, grep, curl, pkill
# User configuration
LOCAL_INSTALL="/usr/lib/sublime-text-2" # Must be user-writable
REPO="dev" # "dev" for dev releases, or "2" for beta releases
TARGET_BUILD="Linux 32 bit" # can be one of "Windows", "Windows 64 bit", "OS X", "Linux 32 bit", "Linux 64 bit"
# Check if sublime text is running
@ratibus
ratibus / sfSearchTask.class.php
Created September 8, 2011 14:24
symfony search task
<?php
class sfSearchTask extends sfCommandApplicationTask
{
/**
* @see sfTask
*/
protected function configure()
{
$this->addArguments(array(