Skip to content

Instantly share code, notes, and snippets.

View langalex's full-sized avatar

Alexander Lang langalex

View GitHub Profile
langalex / rest_client_helpers.rb
Created April 16, 2021 11:12
rest-client stub bad request error with RSpec
View rest_client_helpers.rb
module RestClientHelpers
def bad_request_error(json_body)
request = double(:request, redirection_history: nil)
net_http_res = double(:response, to_hash: {}, code: 400)
response = RestClient::Response.create(json_body.to_json, net_http_res, request) response, 400
RSpec.configure do |c|
View controllers.application\.js
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
langalex / html.html
Last active October 25, 2016 10:03 — forked from thilo/html.html
An example how to use the bots platform to build a custom report
View html.html
<!doctype html>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scaleable=no">
<title>Example Report</title>
<div class="page-header">
<h1>Example Report</h1>
langalex / bag.rb
Created October 2, 2013 16:45
A data structure to put stuff in and take it out again. NIH syndrome?
View bag.rb
class Bag
def initialize
@contents =
def put_in(names, amount)
@contents[[names].flatten] += amount
def take_out(name, amount)
langalex / make_timelapse.bash
Created June 8, 2013 15:51
Turns a series of JPEG files into a video.
View make_timelapse.bash
# usage: cd <directory full of JPGs> && make_timelapse
mkdir ./captures
for i in `find . -name '*.JPG'` ;
#Write the filename to be friendly with ffmpeg's odd filename input
FILENAME=`printf '%04d.jpg' $COUNTER`
cp $i ./captures/$FILENAME
langalex / log_calls.rb
Created February 3, 2013 17:35
Extend an object with this module to print out all method calls to it.
View log_calls.rb
module LogCalls
def self.extended(b)
b.class_eval do
(b.methods - Object.methods).each do |m|
define_method "#{m.to_s.gsub(/[\?\!=]/, '')}_with_logging#{m.to_s[/[\?\!=]/]}" do |*args|
puts m
send "#{m.to_s.gsub(/[\?\!=]/, '')}_without_logging#{m.to_s[/[\?\!=]/]}", *args
alias_method_chain m.to_sym, :logging
langalex / .travis.yml
Created January 24, 2013 16:44
Parrallel tests with travis-ci
View .travis.yml
- RUN_TESTS=cucumber
- RUN_TESTS=rspec_testunit
langalex / backup.rb
Created August 23, 2012 14:13
Couchbase EBS RAID Backup on Scalarium
View backup.rb
#!/usr/bin/env ruby
# Backs up the mounted EBS RAID storage used by Couchbase of an EC2 instance using the Scalarium API.
# Before running the snapshot it stops Couchbase disk writes and then freezes the file system.
# File system must be XFS.
# Usage:<scalarium api token>, <mount point for ebs raid>, <name of couchbase bucket to back up>).start (must be run on the EC2 instance).
require 'rest_client'
langalex /
Created June 15, 2012 14:37
Logging in to the hotel wifi at Nordic Ruby 2012
# take one of the wifi cards from the bar and fill in the blanks
# this wil log you into the hotel wifi without having to type in the username/password every time
curl -XPOST -d "username=<username>&password=<password>&"
langalex / credits.rb
Created April 21, 2012 23:19
Ruby Script to generate the intro and credits for my Railsgirls Berlin film
View credits.rb
# encoding: utf-8
require_relative 'type'
require 'yaml'
30.times {puts}
sleep 2
command '"That was: #{} #{Location.current} #{}"', "=> That was: Railsgirls Berlin 2012"