Skip to content

Instantly share code, notes, and snippets.

@poshaughnessy
poshaughnessy / app.js
Created January 31, 2012 09:28
Simple static site on Heroku with Node.js
var express = require('express');
var port = process.env.PORT || 3000;
var app = express.createServer();
app.get('/', function(request, response) {
response.sendfile(__dirname + '/index.html');
}).configure(function() {
app.use('/images', express.static(__dirname + '/images'));
}).listen(port);
@christianchristensen
christianchristensen / gist:1759543
Created February 7, 2012 12:49
OpenVPN CLI notes
## Quick Setup
sudo apt-get install byobu
sudo apt-get install htop
sudo apt-get install openvpn
# sudo apt-get install bitlbee
sudo apt-get install irssi
# cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
@MrMaksimize
MrMaksimize / closure
Created February 16, 2012 18:20
closure
<?php
$somefunction = function($foo, $bar){
//do something
}
$myfunction = ($somefunction($foo, $bar), $variable){
//do stuff
//call somefunction
//do some more stuff
@chriseidhof
chriseidhof / nsincrementalstore.markdown
Created February 18, 2012 16:39
Accessing an API using CoreData's NSIncrementalStore

Accessing an API using CoreData's NSIncrementalStore

Note: the original location of this article is on my blog, however, it is posted here too for better readability.

In this article, we will see how to use Core Data for accessing your API. We will use the Bandcamp API as our running example. I've only been experimenting with this code for a few days, so there might be mistakes in there.

@travist
travist / gist:1942541
Created February 29, 2012 17:12
Determine every event that gets fired on your page.
(function($) {
$('*').each(function() {
var e = $.data(this, 'events');
if(!e) return;
for(var p in e) {
$(this).bind(p, {event:p, name: this.tagName + '.' + this.className}, function(event) {
console.log(event.data.name + " triggered " + event.data.event);
});
};
});
@bcmiller
bcmiller / pre-commit
Created March 16, 2012 18:28
pre-commit
#!/bin/sh
# Place as .git/hooks/pre-commit
#Reject any commit that would have PHP syntaz errors on .php , .module, .install, .inc files
####
# Reject any commit that would add a line with tabs.
#
# You can enable this as a repo policy with
#
# git config hooks.allowtabs true
####
api = 2
core = 7.x
projects[drupal][type] = core
projects[drupal][version] = "7.12"
; Make system directories configurable to allow tests in profiles/[name]/modules to be run.
; http://drupal.org/node/911354
projects[drupal][patch][911354] = http://drupal.org/files/issues/911354.43.patch
@christianchristensen
christianchristensen / Migration.md
Created April 26, 2012 04:05
Implementing AllPlayers.com sign-in with Silex and PHP
@mikeygee
mikeygee / 01-before.html
Created May 7, 2012 07:45
truncate blog posts in jekyll
<!-- using the truncate filter -->
{% for post in site.posts limit:10 %}
<h2><a href="{{ post.url }}">{{ post.title }}</a></h2>
<span class="post-date">{{ post.date | date: "%B %d, %Y" }}</span>
{% if post.content.size > 2000 %}
{{ post.content | truncatewords: 300 }} <!-- bad! content gives you rendered html and you will truncate in the middle of a node -->
<a href="{{ post.url }}">read more</a>
{% else %}
{{ post.content }}
{% endif %}
@travist
travist / gist:2863998
Last active October 5, 2015 19:37
Dynamically add javascript to your page
// Conditionally loads scripts.
var loadScripts = function(params) {
// Iterate over each source.
var eachSource = function(callback) {
if (typeof params.scripts == 'string') {
callback(params.scripts);
}
else {
for (var i=0; i < params.scripts.length; i++) {