Skip to content

Instantly share code, notes, and snippets.

@terryjray
terryjray / gist:3296171
Created August 8, 2012 15:55
Enabling hstore for new postgresql 9.1 and rails 3 install on ubuntu 12.04
RAILS_ENV=production rake db:setup
# produces the error below.....hmmm.....it's a no-worky
psql:/yourprojectpath/yourproject/db/structure.sql:29: ERROR: could not open extension control file "/usr/share/postgresql/9.1/extension/hstore.control": No such file or directory
# hstore postgresql extension needs to be installed, so....
sudo apt-get install postgresql-contrib
# now your extension should be available to enable so log in with psql
psql -d yourproject_production -U yourdbuser -W
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@Natim
Natim / language_app.py
Created August 18, 2012 08:40
Flask language_dispatch : Detect the user language and redirect to the right domain_name
# -*- coding: utf-8 -*-
import locale
import re
from flask import Flask, redirect, request
app = Flask(__name__)
LANGUAGE_CODES = ('fr', 'en', 'zh')
DOMAIN_NAME = 'example.com'
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active May 3, 2025 05:25
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@bennadel
bennadel / index.htm
Created September 18, 2012 14:04
Exposing A Mouse Service For Click Events In AngularJS
<!doctype html>
<html ng-app="Demo">
<head>
<meta charset="utf-8" />
<title>Sharing A Mouse Service In AngularJS</title>
</head>
<body
ng-controller="DemoController"
bn-document-click="handleClick()">
@seratch
seratch / build.sbt
Created September 27, 2012 05:35
My first JGit sample in Scala
// http://www.eclipse.org/jgit/download/
resolvers += "jgit-repo" at "http://download.eclipse.org/jgit/maven"
libraryDependencies += "org.eclipse.jgit" % "org.eclipse.jgit" % "[2.1,)"
@Yukilas
Yukilas / directive.js
Created October 30, 2012 09:42
AngularJS - Button loading directive
/*
``btn-loading`` attribute.
This attribute will update the button state using Twitter Bootstrap button plugin and
according the attribute value.
The attribute value should be a scope variable.
If the variable is ``true`` the button will have the ``loading`` state.
If the variable is ``false`` the button will be reset and displayed normaly.
@paulirish
paulirish / gist:4158604
Created November 28, 2012 02:08
Learn JavaScript concepts with recent DevTools features

Learn JavaScript concepts with the Chrome DevTools

Authored by Peter Rybin , Chrome DevTools team

In this short guide we'll review some new Chrome DevTools features for "function scope" and "internal properties" by exploring some base JavaScript language concepts.

Closures

Let's start with closures – one of the most famous things in JS. A closure is a function, that uses variables from outside. See an example:

@thedaviddias
thedaviddias / dabblet.css
Created December 2, 2012 21:27
CSS: Plaholder style
input::-webkit-input-placeholder {
color: #999;
}
input:-moz-placeholder {
color: #999;
}
input:-ms-input-placeholder {
color: #999;
}
input:focus::-webkit-input-placeholder {
@defunctzombie
defunctzombie / browser.md
Last active July 15, 2024 04:13
browser field spec for package.json