Skip to content

Instantly share code, notes, and snippets.

View justgage's full-sized avatar

Gage Peterson justgage

View GitHub Profile
@mudge
mudge / gist:1076046
Created July 11, 2011 15:06
JavaScript version of ActiveSupport's to_sentence method.
function toSentence(array) {
var wordsConnector = ", ",
twoWordsConnector = " and ",
lastWordConnector = ", and ",
sentence;
switch(array.length) {
case 0:
sentence = "";
break;
@idris
idris / lesswatch.js
Created July 13, 2011 14:37
lesswatch command that can be run to watch a directory and compile .less files to .css files when they are modified.
#!/usr/bin/env node
var fs = require('fs');
var exec = require('child_process').exec;
/*
* lesswatch usage:
*
* `lesswatch` to watch the current directory
@zbroyar
zbroyar / gist:1432555
Created December 5, 2011 06:28
OCaml CURL GET, POST, PUT, DELETE examples
(* ocamlfind ocamlopt -o exmpl -package curl -linkpkg exmpl.ml *)
open Printf
let _ = Curl.global_init Curl.CURLINIT_GLOBALALL
(*
*************************************************************************
** Aux. functions
*************************************************************************
*)
@rferraz
rferraz / cometd_client.clj
Created February 5, 2012 06:12
Clojure CometD client example
(ns test.cometd-client
(:import (org.cometd.bayeux.client ClientSessionChannel$MessageListener)
(org.cometd.client BayeuxClient BayeuxClient$State)
(org.cometd.client.transport ClientTransport LongPollingTransport)
(org.eclipse.jetty.client HttpClient)))
(def channel-name "/my-channel")
(def client-url "http://localhost:8080/cometd")
@scaryguy
scaryguy / change_primary_key.md
Last active April 8, 2024 14:23
How to change PRIMARY KEY of an existing PostgreSQL table?
-- Firstly, remove PRIMARY KEY attribute of former PRIMARY KEY
ALTER TABLE <table_name> DROP CONSTRAINT <table_name>_pkey;
-- Then change column name of  your PRIMARY KEY and PRIMARY KEY candidates properly.
ALTER TABLE <table_name> RENAME COLUMN <primary_key_candidate> TO id;
@mwhite
mwhite / git-aliases.md
Last active April 30, 2024 11:32
The Ultimate Git Alias Setup

The Ultimate Git Alias Setup

If you use git on the command-line, you'll eventually find yourself wanting aliases for your most commonly-used commands. It's incredibly useful to be able to explore your repos with only a few keystrokes that eventually get hardcoded into muscle memory.

Some people don't add aliases because they don't want to have to adjust to not having them on a remote server. Personally, I find that having aliases doesn't mean I that forget the underlying commands, and aliases provide such a massive improvement to my workflow that it would be crazy not to have them.

The simplest way to add an alias for a specific git command is to use a standard bash alias.

# .bashrc
@xeoncross
xeoncross / ajax.js
Last active August 3, 2023 06:06
Simple, cross-browser Javascript POST/GET xhr request object. Supports request data and proper AJAX headers.
/**
* IE 5.5+, Firefox, Opera, Chrome, Safari XHR object
*
* @param string url
* @param object callback
* @param mixed data
* @param null x
*/
function ajax(url, callback, data, x) {
try {
@Sigmus
Sigmus / gulpfile.js
Last active November 15, 2017 11:55
gulpfile.js with browserify, reactify, watchify and gulp-notify.
var source = require('vinyl-source-stream');
var gulp = require('gulp');
var gutil = require('gulp-util');
var browserify = require('browserify');
var reactify = require('reactify');
var watchify = require('watchify');
var notify = require("gulp-notify");
var scriptsDir = './scripts';
var buildDir = './build';
@staltz
staltz / introrx.md
Last active May 7, 2024 09:38
The introduction to Reactive Programming you've been missing
@myguidingstar-zz
myguidingstar-zz / index.html
Last active March 5, 2016 02:33
Clojurescript/Om simple slideshow
<html>
<head>
<style type="text/css">
.slider{
margin:50px auto;
width:500px;
height:300px;
overflow:hidden;
position:relative;
border:5px solid #eaeaea;