This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install git | |
sudo apt-get install g++ curl libssl-dev apache2-utils | |
sudo apt-get install git-core | |
# download the Node source, compile and install it | |
git clone https://github.com/joyent/node.git | |
cd node | |
./configure | |
make | |
sudo make install | |
# install the Node package manager for later use |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns lazy-sort) | |
(defn qsort [[head & tail]] | |
(when head | |
(lazy-cat (qsort (filter #(< % head) tail)) | |
[head] | |
(qsort (remove #(< % head) tail))))) | |
(defn merge* | |
[[f1 & r1 :as l1] [f2 & r2 :as l2]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -ex | |
if [ ! -f /usr/bin/chef-solo ]; then | |
apt-get update | |
apt-get -y upgrade |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
## disconnect | |
# ./disconnect.rb -u yourusername | |
# | |
# This is a command-line utility for the bulk-downloading of run data from | |
# the connect.garmin.com web application, which has lackluster export | |
# capabilities. | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def a(*args, &block) | |
puts "a got a block" if block_given? | |
end | |
def b(*args, &block) | |
puts "b got a block" if block_given? | |
end | |
# In this call, `b' is called with the block and the | |
# return value is given to `a' as an argument. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://gist.github.com/1185131 | |
class Array | |
def next; self[1..-1] end | |
# returns a function that is the combination of a sequence of function calls | |
# on some external arguments. the functions combined are the elements of self. | |
def compose | |
lambda do |*args| | |
inject(*args) do |mem, fn| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add this to your spec_helper.rb | |
RSpec.configure do |config| | |
config.treat_symbols_as_metadata_keys_with_true_values = true | |
config.around(:each, :vcr) do |example| | |
name = example.metadata[:full_description].downcase.gsub(/\W+/, "_").split("_", 2).join("/") | |
VCR.use_cassette(name, :record => :new_episodes) do | |
example.call | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## SCROLL DOWN FOR THE RACE, THE FOLLOWING IS JUST UTILITY FROM COMMONLY USED CODE. | |
# Author:: Mohammad A. Ali (mailto:[email protected]) | |
# Copyright:: Copyright (c) 2008 eSpace, Inc. | |
# License:: Distributes under the same terms as Ruby | |
require 'fiber' | |
class Fiber |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use 'backtype.storm.clojure) | |
(use 'backtype.storm.config) | |
(require '[backtype.storm [thrift :as thrift]]) | |
(import 'storm.starter.spout.RandomSentenceSpout) | |
(import 'backtype.storm.LocalCluster) | |
(defboltfull suffix-bolt ["word"] | |
:params [suffix] | |
:let [conf-state (atom nil)] | |
:prepare ([conf context collector] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Determine if any of the causes of the exception was of the specified type | |
(defn exception-cause? [klass ^Throwable t] | |
(->> (iterate #(.getCause ^Throwable %) t) | |
(take-while identity) | |
(some (partial instance? klass)) | |
boolean)) |