Skip to content

Instantly share code, notes, and snippets.

require "hmac"
require "hmac-sha2"
# reference:
# http://docs.amazonwebservices.com/AWSECommerceService/2009-07-01/DG/index.html?BasicAuthProcess.html
# http://docs.amazonwebservices.com/AWSECommerceService/2009-07-01/DG/index.html?Query_QueryAuth.html
module AmazonSignature
def sign_request(params)
params.reverse_merge!(:Timestamp => timestamp, :Version => "2009-07-01")
params.merge!(:Signature => build_signature(params, "GET"))
@terrcin
terrcin / setup-statsd.sh
Created June 10, 2011 10:14 — forked from collegeman/setup-statsd.sh
Turn an Ubuntu 10.04 linode into a StatsD/Graphite server
# install git
sudo apt-get install g++ curl libssl-dev apache2-utils libapache2-mod-wsgi
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
@kennwhite
kennwhite / aml_centos_private_image_repo_push.sh
Last active December 2, 2015 21:53
Bundle Amazon/CentOS Linux to private Docker image repo
#!/usr/bin/env bash
#
# Bundling a minimal Amazon Linux image to a portable Docker container image
# Based on: https://forums.aws.amazon.com/message.jspa?messageID=541030#557755
#
#
yum install -y wget docker && service docker start
wget -q https://raw.githubusercontent.com/dotcloud/docker/master/contrib/mkimage-yum.sh
#
# Example for bundling AML Minimal HVM EBS Build: amzn-ami-minimal-hvm-2015.03.0.x86_64-ebs (ami-2ccae744)
@jmreidy
jmreidy / test_mocha.opts
Last active January 9, 2018 11:49
Unit test React Native with Mocha
--compilers js:./test/support/compiler
--require ./test/support/init
@elgalu
elgalu / write_expectation.rb
Last active May 9, 2019 08:39
An RSpec expectation to test text written to standard output and standard error
require 'rspec'
require 'stringio'
# Custom matcher to test text written to standard output and standard error
#
# @example
# expect { $stderr.puts "Some random error" }.to write(/Some.* error/).to(:stderr)
#
# @example
# expect { $stderr.puts "Some specific error" }.to write('Some specific error').to(:stderr)
@terjesb
terjesb / core.clj
Created October 1, 2013 19:20
Google Analytics Core Reporting API v3 using Service Account from Clojure
(ns ga-exp.core
(:import
(com.google.api.client.googleapis.auth.oauth2 GoogleCredential$Builder)
(com.google.api.client.googleapis.javanet GoogleNetHttpTransport)
(com.google.api.client.json.jackson2 JacksonFactory)
(com.google.api.services.analytics Analytics$Builder AnalyticsScopes)))
(def HTTP_TRANSPORT (GoogleNetHttpTransport/newTrustedTransport))
(def JSON_FACTORY (JacksonFactory.))
@apeckham
apeckham / lucene-dash.md
Last active October 17, 2021 16:46
Add Lucene Javadocs to Kapeli Dash

Install j2d

  • wget https://github.com/iamthechad/javadoc2dash/releases/download/1.1.0/j2d-cli-1.1.0.zip
  • unzip j2d-cli-1.1.0.zip

Build Javadocs

  • wget https://archive.apache.org/dist/lucene/java/8.5.1/lucene-8.5.1-src.tgz
  • brew install ant
@subelsky
subelsky / casperjs_example.js
Created August 8, 2012 18:51
Webscraping with CasperJS, PhantomJS, jQuery, and XPath
var system = require('system');
if (system.args.length < 5) {
console.info("You need to pass in account name, username, password, and path to casperJS as arguments to this code.");
phantom.exit();
}
var account = system.args[1];
var username = system.args[2];
var password = system.args[3];
@martinklepsch
martinklepsch / random-color.clj
Last active April 23, 2022 20:07
Generate a random HEX color in cojure or clojurescript
(require '[clojure.string :as s])
;; My initial attempt
(def c [:0 :1 :2 :3 :4 :5 :6 :7 :8 :9 :A :B :C :D :E :F])
(str "#" (s/join (map name (repeatedly 6 #(rand-nth c)))))
;; Another option not using keywords (/ht locks in #clojure)
(def c [0 1 2 3 4 5 6 7 8 9 \A \B \C \D \E \F])
(str "#" (s/join (repeatedly 6 #(rand-nth c))))
;; the last line can be simplified even more (/ht xificurC in #clojure)
@jedisct1
jedisct1 / long-domain-names.txt
Last active November 26, 2022 19:34
Long domain names are long. Hopeless SEO, domains registered by cats and WTF domains.
1-tr-18su-ka-8dow-56-oo9-13swx-r-k-ife-0nj-rnq-ihb-dd-p-1-0-z-a.info.
292fu2013-1-2-3-htt-4t3l60-zqn673-w9gp7kip0422wemrzsftm-htm-com.info.
aljumahiriyahalarabiyahallibiyahashshabiyahalishtirakiyahaluzma.info.
anderson-piedmont-spartanburg-greenville-easley-spine-pain-care.info.
associationfrancaisedesdirecteursdelaphotographiedelatelevision.info.
audio-player-zawqkerrhfoepdnmvbdkslahgjvklahjkfqqqojcgrtsksmcls.info.
ausencosandwellascentisaaxwaynegossruddswanheinercrimemellifont.info.
australianpublicsectoranti-corruptionconference2009fraudrortsin.info.
bewarecrimestoppersassistcorruptpolicepoliticcrimecriminalfraud.info.
camp-the-lycian-way-camps-the-lycian-way-camping-lycian-way-map.info.