Skip to content

Instantly share code, notes, and snippets.

View adambarthelson's full-sized avatar
🐢

Adam Barthelson adambarthelson

🐢
  • Washington, D.C.
View GitHub Profile
@dnagir
dnagir / rspec-syntax-cheat-sheet.rb
Created November 5, 2010 09:29
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
@alexvbush
alexvbush / run_perl_python_scipts_in_rails.rb
Created July 19, 2011 22:08
How to run Perl and Python scripts in a Rails app.
#This will run Perl and Python scripts respectively in Rails console using 'gem escape'. Gem Escape allows to format path to the scripts properly.
perl_cmd = Escape.shell_command(['perl', "#{RAILS_ROOT}/bin/test_perl_script.pl"]).to_s
system perl_cmd
python_cmd = Escape.shell_command(['python', "#{RAILS_ROOT}/bin/test_python_script.py"]).to_s
system python_cmd
@lusis
lusis / log4j.xml
Created November 23, 2011 07:11
Ruby logstash cli application - allows searching historical data in ElasticSearch or live tailing from AMQP topic exchange
<!-- the env variables are controlled by Chef and passed in via -D on the java command-line -->
<!-- This is using the appender here: https://github.com/t0xa/gelfj -->
<appender name="graylog2" class="org.graylog2.log.GelfAppender">
<param name="graylogHost" value="${graylog.server}"/>
<param name="originHost" value="${graylog.origin}"/>
<param name="extractStacktrace" value="true"/>
<param name="addExtendedInformation" value="true"/>
<!-- The _web part is because a given app has multiple components -->
<!-- This app might have a _web as well as an _batch component -->
<param name="facility" value="${graylog.facility}_web"/>
@hrldcpr
hrldcpr / tree.md
Last active June 19, 2025 08:17
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@davemo
davemo / api.proxy.server.js
Created November 6, 2012 21:56
A simple express.js server with a proxy that intercepts all requests with /api/ and proxies them to localhost:3000
var express = require('express'),
httpProxy = require('http-proxy'),
app = express();
var proxy = new httpProxy.RoutingProxy();
function apiProxy(host, port) {
return function(req, res, next) {
if(req.url.match(new RegExp('^\/api\/'))) {
proxy.proxyRequest(req, res, {host: host, port: port});
@fnichol
fnichol / Berksfile
Created November 16, 2012 19:42
A Puppet Master!
site :opscode
# i heard you liked puppet
cookbook 'puppet'
@Bendihossan
Bendihossan / twitter.php
Created April 13, 2013 16:06
Get tweets from twitter in less than 20 lines of PHP.
<?php
define('CONSUMER_KEY', 'your-key');
define('CONSUMER_SECRET', 'your-key');
define('TWITTER_TOKEN', 'your-key');
define('TWITTER_TOKEN_SECRET', 'your-key');
$oauth = new OAuth(CONSUMER_KEY, CONSUMER_SECRET, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI);
$oauth->setToken(TWITTER_TOKEN, TWITTER_TOKEN_SECRET);
$oauth->fetch('https://api.twitter.com/1.1/statuses/home_timeline.json?count=10');
@petehamilton
petehamilton / README.md
Last active March 31, 2020 18:18
Circle CI Build Status widget for Dashing (Multiple Builds)

Description

Dashing widget to show the status of builds from CircleCI. Also shows the avatar of the person who is running/breaking/passing the current build.

Usage

  • Get a Circle API Token from your Account Dashboard and set it in your environment as CIRCLE_CI_AUTH_TOKEN
  • Add the httparty to your Gemfile and run bundle install

Then:

@gkze
gkze / frost.sh
Created July 16, 2013 18:28
Stephen Frost's crazy one-liner
#!/bin/bash
for host in *; do NAME=`echo $host | cut -f1 -d.`; DOMAIN=`echo $host | cut -f2 -d.`; IPMI="$NAME.ipmi.$DOMAIN.resonatedigital.net"; IP=`host $IPMI | cut -f4 -d' '`; if [ "$IP" != "found:" ]; then cat TEMPLATE.cfg | sed -e "s:NAME:$NAME.ipmi.$DOMAIN:" -e "s:IPADDRESS:$IP:" -e 's:rsnt_iad_linux_physical_hadoop:rsnt_iad_oob_ipmi:' -e 's:generic-rsnt-iad-linux-host:generic-rsnt-iad-host:' | grep -v 'register' > ../../../oob/ipmi/$NAME.ipmi.$DOMAIN.cfg; fi; done
@ChuckJHardy
ChuckJHardy / run.js
Created September 28, 2013 16:19
Express Server for ZeroMQ, Socket.io and Angular.js
'use strict';
var express = require('express'),
app = express(),
http = require('http'),
server = http.createServer(app),
path = require('path'),
io = require('socket.io').listen(server),
fs = require('fs'),
zmq = require('zmq'),