Skip to content

Instantly share code, notes, and snippets.

@fwielstra
fwielstra / api.js
Created June 14, 2011 14:46
An example NodeJS / Mongoose / Express application based on their respective tutorials
/* The API controller
Exports 3 methods:
* post - Creates a new thread
* list - Returns a list of threads
* show - Displays a thread and its posts
*/
var Thread = require('../models/thread.js');
var Post = require('../models/post.js');
@mjg123
mjg123 / latinsq.clj
Created October 26, 2011 08:37
Latin square solver in clojure
(ns latinsq.core
(:use [clojure.set :only (difference)]))
(defn replace-at
"in string s, replaces character at index p with c"
[s p c]
(str
(.substring s 0 p)
c
@jsleetw
jsleetw / update
Created December 16, 2011 05:04 — forked from hSATAC/update
git update hook
#!/bin/sh
# place in {repo}/.git/hooks/update
# chmod +x update
name="$1"
old="$2"
new="$3"
user_name=$(git log -1 --pretty=format:%aN $new)
#branch=$(git rev-parse --symbolic --abbrev-ref $1)
branch=${name#refs/heads/}
@niepi
niepi / osx_php_homebrew.setup.md
Created February 28, 2012 13:23
OSX PHP Homebrew Setup

install php

with mysql pgsql intl support

$ brew install php --with-apache --with-mysql --with-pgsql --with-intl

set php timezone in php ini

date.timezone = Europe/Vienna
@crofty
crofty / leaflet-google.js
Created March 25, 2012 15:07
Leaflet plugin that enables the use of Google Map tiles - http://matchingnotes.com/using-google-map-tiles-with-leaflet
/*
* L.TileLayer is used for standard xyz-numbered tile layers.
*/
L.Google = L.Class.extend({
includes: L.Mixin.Events,
options: {
minZoom: 0,
maxZoom: 18,
tileSize: 256,
@domenic
domenic / README.md
Created March 29, 2012 16:01
Cross-platform git hooks for Node.js

Here's how this works:

  • Include a git_hooks/ directory in your project, with these two files (plus other hooks if you want, written in a similar style).
  • Add "npm" to your devDependencies in package.json, so that the pre-commit hook can do its magic.
  • Add test and lint scripts to your package.json, e.g.
    "scripts": {
        "test": "mocha",
 "lint": "jshint ./lib --show-non-errors"
@shytikov
shytikov / commit-msg
Created July 17, 2012 21:07
commit-msg hook script
#!/bin/sh
#
# Automatically adds branch name and branch description to every commit message.
#
NAME=$(git branch | grep '*' | sed 's/* //')
DESCRIPTION=$(git config branch."$NAME".description)
TEXT=$(cat "$1" | sed '/^#.*/d')
if [ -n "$TEXT" ]
then
@juandopazo
juandopazo / result.js
Created October 6, 2012 17:33
YUI TypeScript definitions
module Y {
interface Anim extends Base {
}
interface App extends App_Base, App_Content, App_Transitions, PjaxContent {
(config?: any);
@domenic
domenic / promises.md
Last active June 24, 2024 03:11
You're Missing the Point of Promises

This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
 // the rest of your code goes here.
@pzaich
pzaich / gist:3997914
Created November 2, 2012 00:48
install graphicsmagick to EC2
wget ftp://ftp.graphicsmagick.org/pub/GraphicsMagick/1.3/GraphicsMagick-1.3.15.tar.gz
tar -xvf GraphicsMagick-1.3.15.tar.gz
cd GraphicsMagick-1.3.15
./configure
make