Skip to content

Instantly share code, notes, and snippets.

@stephanschubert
stephanschubert / compact.gemspec
Last active August 29, 2015 14:02
Hash#compact removes all keys with nil as value.
Gem::Specification.new do |s|
s.name = 'compact'
s.version = '0.0.1'
s.platform = Gem::Platform::RUBY
s.author = 'Stephan Schubert'
s.email = '[email protected]'
s.summary = 'Hash#compact'
s.description = 'Removes all keys with nil as value.'
s.files = ['compact.rb']
@stephanschubert
stephanschubert / selecta_search_history.zsh
Last active August 23, 2016 10:20
Reverse command history search with selecta's fuzzy matching for ZSH
function exists { which $1 &> /dev/null }
if exists selecta; then
function selecta_select_history() {
local tac
exists gtac && tac="gtac" || { exists tac && tac="tac" || { tac="tail -r" } }
BUFFER=$(fc -l -n 1 | eval $tac | selecta $LBUFFER)
CURSOR=$#BUFFER # move cursor
zle -R -c # refresh
}
#!/bin/bash
# This script creates a custom ruby definition for rbenv
# which incorporates the rvm patches from skaes.
#
# (c) [email protected]
#
rubyexpress_repo="https://github.com/skaes/rvm-patchsets.git"
rubybuild_repo="https://github.com/sstephenson/ruby-build.git"
mkdir rbenv-railsexpress
require "net/http"
def start_server
# Remove the X to enable the parameters for tuning.
# These are the default values as of Ruby 2.2.0.
@child = spawn(<<-EOC.split.join(" "))
XRUBY_GC_HEAP_FREE_SLOTS=4096
XRUBY_GC_HEAP_INIT_SLOTS=10000
XRUBY_GC_HEAP_GROWTH_FACTOR=1.8
XRUBY_GC_HEAP_GROWTH_MAX_SLOTS=0
@stephanschubert
stephanschubert / private_delegate.rb
Created March 26, 2015 07:35
Delegate methods privately (requires ActiveSupport)
class Module
def private_delegate(*methods)
delegate(*methods)
methods.extract_options!
methods.each { |m| private(m) }
end
end
@stephanschubert
stephanschubert / reinstall-everything-brewd.sh
Created July 22, 2015 16:38
Re-install everything brew'd.
#!/bin/bash
for i in `brew list -1`
do
if [[ "$i" == python.* ]] || [[ "$i" == ruby.* ]]
then
continue
fi
brew rm --force $i && brew install $i
done
#!/bin/bash
# git-cleanup-repo
#
# Author: Rob Miller <[email protected]>
# Adapted from the original by Yorick Sijsling
#
# * 2015/11/05 - Fixed formatting issues (Stephan Schubert)
KEEP_BRANCHES='(master|staging|ci-[0-9]+)$'
@stephanschubert
stephanschubert / endpoints.md
Created May 20, 2016 06:57 — forked from derhuerst/_.md
List of HAFAS API Endpoints
@stephanschubert
stephanschubert / PinchZoomPan.js
Created December 1, 2016 15:52 — forked from iammerrick/PinchZoomPan.js
React Pinch + Zoom + Pan
import React from 'react';
const MIN_SCALE = 1;
const MAX_SCALE = 4;
const SETTLE_RANGE = 0.001;
const ADDITIONAL_LIMIT = 0.2;
const DOUBLE_TAP_THRESHOLD = 300;
const ANIMATION_SPEED = 0.04;
const RESET_ANIMATION_SPEED = 0.08;
const INITIAL_X = 0;
@stephanschubert
stephanschubert / .csscomb.json
Created May 19, 2017 11:40
My CSS Comb configuration
{
"remove-empty-rulesets": true,
"always-semicolon": true,
"color-case": "lower",
"block-indent": " ",
"color-shorthand": true,
"element-case": "lower",
"eof-newline": true,
"leading-zero": false,
"quotes": "double",