Skip to content

Instantly share code, notes, and snippets.

View indirect's full-sized avatar

André Arko indirect

View GitHub Profile
@indirect
indirect / application.controller.js
Last active August 27, 2015 21:45
intersection-with-promises
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});
@indirect
indirect / app.rb
Created March 6, 2014 21:52
Repro case for Ruby 2.0 Content-Disposition: gzip handling
require 'sinatra'
require 'zlib'
configure do
set :server, :puma
end
get '/text' do
body File.read("text")
end
@indirect
indirect / less_than_proc.rb
Created May 12, 2014 08:34
Subclass proc to add a custom inspect method, add a class method to create a curried instance
class LessThanProc < Proc
attr_accessor :present
def self.with(present)
pv = Gem::Version.new(present.dup)
lt = self.new { |required| pv < Gem::Version.new(required) }
lt.present = present
return lt
end
#!/bin/bash
set -ex
bundle install --standalone
digest=$(md5 -q Gemfile)
cmd="raise \"Gemfile changed\" if %x[md5 -q Gemfile].chomp != \"${digest}\""
echo $cmd > bundle/bundler/setup.rb.new
cat bundle/bundler/setup.rb >> bundle/bundler/setup.rb.new
### Keybase proof
I hereby claim:
* I am indirect on github.
* I am indirect (https://keybase.io/indirect) on keybase.
* I have a public key whose fingerprint is 53B5 BDD2 6623 41EB 2932 B002 509A E6D4 A089 D900
To claim this, I am signing this object:
@indirect
indirect / gc.bash
Created September 12, 2014 08:27
clone a github repo and then cd into it
# clone a github repo and then cd into it
function gc {
local repo=${1#*github.com/}
git clone "$repo" "$HOME/src/$repo"
cd "$HOME/src/$repo"
}

What is a coder's worst nightmare?

Mick Stute, BS in CS, PhD work in Bioinformatics

This was mine:

Was hired by a psychologist to fix a program that seemed to have "strange output" written by one of his ex-grad students. It was a program that reads a data files, asks about 50 questions, does some calculations, and comes up with some score based on this PhD's research. It's on a research 3B2 at the university. He demonstrates the program and sure enough there seemed to be strange flashing words on the screen when it moves from question to question and they don't seem nice. I agree to do it, should be pretty straight forward, so he'll pay me by the hour to determine how big the fix is and then we'll agree to a fee.

Day 1

@indirect
indirect / README.md
Last active August 29, 2015 14:24
Rails 4 silenceable logger

Rails 4 Silenceable Logger

For when you really, really don't want to log a request.

I'm using this logger to skip logging requests for CarrierWave-uploaded images in development. Loading database dumps from other environments means that the images simply aren't there in development. Rather than deal with an ActiveSupport::RoutingError and a huge 20 line backtrace per missing image, I'm just suppressing all output using this logger and a catchall route that's only active in development.

Usage

Add lib/silenceable_logger.rb to your Rails app, and adapt config/development.rb and config/routes.rb as needed.

@indirect
indirect / rspec_retries.rb
Last active August 29, 2015 14:26 — forked from seancribbs/rspec_retries.rb
Retry specs tagged with :sometimes
# Works with RSpec 3.2.0
module Sometimes
def run_with_retries(example_to_run, retries)
example = RSpec.current_example
example.metadata[:retries] ||= retries
retries.times do |t|
example.metadata[:retried] = t + 1
example.instance_variable_set(:@exception, nil)
example_to_run.run
#!/usr/bin/ruby -w
require 'fileutils'
$pageBreakTag = /<hr>\s<A name=[0-9]+><\/a>/i
$brTag = /<br>/i
$bodyTag = /<body[^>]*>/i
$fileHeaderTag = /file.*<br>/i