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');
@indexzero
indexzero / helpers.js
Created June 22, 2011 03:05
A quick sample of how to use api-easy with `npm test`
/*
* helpers.js: Test macros for APIeasy.
*
* (C) 2011, Charlie Robbins
*
*/
var assert = require('assert'),
http = require('http'),
journey = require('journey');
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active July 19, 2024 20:54
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@nilclass
nilclass / gist:4500881
Created January 10, 2013 09:57
proposal: promises for teste
// WITHOUT PROMISES:
tests: [
{
desc: "My async test",
run: function(env) {
var _this = this;
doSomethingThatReturnsAPromise().
then(
@cobyism
cobyism / gh-pages-deploy.md
Last active July 18, 2024 05:22
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

@jshaw
jshaw / byobuCommands
Last active July 4, 2024 10:58
Byobu Commands
Byobu Commands
==============
byobu Screen manager
Level 0 Commands (Quick Start)
------------------------------
<F2> Create a new window
#!/bin/bash
set -o errexit
# Author: David Underhill
# Script to permanently delete files/folders from your git repository. To use
# it, cd to your repository's root and then run the script with a list of paths
# you want to delete, e.g., git-delete-history path1 path2
if [ $# -eq 0 ]; then
exit 0

Build your own private, encrypted, open-source Dropbox-esque sync folder

Prerequisites:

  • One or more clients running a UNIX-like OS. Examples are given for Ubuntu 12.04 LTS, although all software components are available for other platforms as well (e.g. OS X). YMMV
  • A cheap Ubuntu 12.04 VPS with storage. I recommend Backupsy, they offer 250GB storage for $5/month. Ask Google for coupon codes.

Software components used:

  • Unison for file synchronization
  • EncFS for folder encryption
@digitaltonic
digitaltonic / hinder.sh
Last active September 21, 2016 12:07 — forked from jgdavey/hinder.sh
#!/bin/bash
set -e
function printUsage() {
echo -e USAGE="\nUsage: $0 ip_address delay_in_ms percentage_of_packet_loss \nor\nUsage: $0 reset\n"
}
if [ "$#" == "0" ] || [ "$#" == "1" ] && [ "$1" != "reset" ] || [ "$1" != "reset" ] && [ "$#" -ne 3 ]; then
printUsage