Skip to content

Instantly share code, notes, and snippets.

@rads
rads / .gitignore
Created April 1, 2012 22:40
lein-cljsbuild 0.1.5 bug
/target
/lib
/classes
/checkouts
pom.xml
*.jar
*.class
.lein-deps-sum
.lein-failures
.lein-plugins
@swannodette
swannodette / gist:2038633
Created March 14, 2012 18:52
project.clj
(defproject cljs-demo "0.1.0-SNAPSHOT"
:description "ClojureScripting!"
:dev-dependencies [[lein-cljsbuild "0.1.2"]]
:cljsbuild {:builds [{:source-path "src"
:compiler {:optimizations :simple
:pretty-print true}}]})
;; then from project directory
;; ---------------------------
;;
@travisp
travisp / invitations_controller.rb
Created March 9, 2012 15:56
devise_invitable with omniauthable
class InvitationsController < Devise::InvitationsController
# GET /resource/invitation/accept?invitation_token=abcdef
def edit
if params[:invitation_token] && self.resource = resource_class.to_adapter.find_first( :invitation_token => params[:invitation_token] )
session[:invitation_token] = params[:invitation_token]
render :edit
else
set_flash_message(:alert, :invitation_token_invalid)
redirect_to after_sign_out_path_for(resource_name)
@hugoduncan
hugoduncan / gist:1994274
Created March 7, 2012 16:42
new pallet first steps

Zero to running in five minutes with lein.

Install leiningen

The first thing we need is leiningen, a build tool for clojure. You can downlaod this with your web browser, curl or wget or your favourite download tool. Here we show using curl.

bash$ curl -O http://github.com/technomancy/leiningen/raw/stable/bin/lein
@pheuter
pheuter / sc-dl.js
Created March 5, 2012 20:44
Bookmarklet that generates download link for a Soundcloud upload
(function(d) {
var dl = d.createElement('a');
dl.innerText = 'Download MP3';
dl.href = "http://media.soundcloud.com/stream/"+d.querySelector('#main-content-inner img[class=waveform]').src.match(/\.com\/(.+)\_/)[1];
dl.download = d.querySelector('em').innerText+".mp3";
d.querySelector('.primary').appendChild(dl);
dl.style.marginLeft = '10px';
dl.style.color = 'red';
dl.style.fontWeight = 700;
})(document);

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@sgonyea
sgonyea / pgp.rb
Created March 2, 2012 01:34
BouncyCastle PGP Encryption in JRuby, _WITHOUT_ writing the data to disk before encryption
require 'java'
require 'java/bcpg-jdk16-146.jar'
module MyProject
def self.keys_dir
@keys_dir ||= Bundler.root.join("config/pgp/")
end
module PGP
java_import 'java.io.ByteArrayInputStream'
@robinkraft
robinkraft / first_cascalog_queries.clj
Created February 13, 2012 03:10
Explorations with Cascalog
;; Sam, I got up to 21, some of which now reside forma-clj
(def nums
[1
2
3
4
5
6])
@jasonrudolph
jasonrudolph / git-branches-by-commit-date.sh
Created February 12, 2012 20:40
List remote Git branches and the last commit date for each branch. Sort by most recent commit date.
# Credit http://stackoverflow.com/a/2514279
for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort -r
@keesun
keesun / HttpWebServer.java
Created February 10, 2012 22:39
Vert.x HttpServer Demo
package http;
import org.vertx.java.core.Handler;
import org.vertx.java.core.app.VertxApp;
import org.vertx.java.core.http.HttpServer;
import org.vertx.java.core.http.HttpServerRequest;
/**
* @author Keesun Baik
*/