Skip to content

Instantly share code, notes, and snippets.

View BanzaiMan's full-sized avatar

Hiro Asari BanzaiMan

View GitHub Profile
@bbrowning
bbrowning / instructions.md
Last active December 20, 2015 23:49
OpenShift pre_build hook to allow Windows developers to deploy to OpenShift
  1. Make sure your Gemfile.lock is not committed to your OpenShift git repository.

  2. Copy the pre_build file to .openshift/action_hooks/pre_build

  3. Add .openshift/action_hooks/pre_build to git, set the executable bit, and push your changes

    git add .openshift/action_hooks/pre_build git update-index --chmod=+x .openshift/action_hooks/pre_build git commit -m "Add bundle_install in pre_build hook" git push

@coffeemug
coffeemug / gist:6168031
Last active February 3, 2022 23:16
The fun of implementing date support
After spending the better part of the month implementing date support
in RethinkDB, Mike Lucy sent the team the following e-mail. It would
have been funny, if it didn't cause thousands of programmers so much
pain. Read it, laugh, and weep!
-----
So, it turns out that we're only going to support dates between the
year 1400 and the year 10000 (inclusive), because that's what boost
supports.
@jedisct1
jedisct1 / bench results
Last active December 19, 2015 02:09
msgpack benchmark results
ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-darwin12.4.0]
user system total real
YAML 29.190000 1.150000 30.340000 ( 31.303681)
JSON 1.780000 0.050000 1.830000 ( 2.357544)
Marshal 1.300000 0.020000 1.320000 ( 1.781964)
MessagePack 0.520000 0.160000 0.680000 ( 0.692523)
jruby 1.7.4 (1.9.3p392) 2013-05-16 2390d3b on Java HotSpot(TM) 64-Bit Server VM 1.7.0_17-b02 +indy [darwin-x86_64]
@evanphx
evanphx / bundle-update-lockfile.rb
Last active August 8, 2016 11:44
Need to update a Gemfile.lock but don't want to install the gems? No problem! Run this in the same directory as your Gemfile!
#!/usr/bin/env ruby
require 'bundler'
gems = ARGV
if gems.empty?
puts "Updating all gems"
Bundler.definition(true)
@mislav
mislav / _readme.md
Last active May 15, 2024 11:03
tmux-vim integration to transparently switch between tmux panes and vim split windows

I use tmux splits (panes). Inside one of these panes there's a Vim process, and it has its own splits (windows).

In Vim I have key bindings C-h/j/k/l set to switch windows in the given direction. (Vim default mappings for windows switching are the same, but prefixed with C-W.) I'd like to use the same keystrokes for switching tmux panes.

An extra goal that I've solved with a dirty hack is to toggle between last active panes with C-\.

Here's how it should work:

@BanzaiMan
BanzaiMan / gist:5129358
Last active March 5, 2017 22:17
Updating system TZ dataUse at your own risk. If desired, back up /usr/share/zoneinfo.
rm -rf zoneinfo
mkdir zoneinfo
curl -s -L -o - http://www.iana.org/time-zones/repository/tzdata-latest.tar.gz | tar xzvf - -C zoneinfo
cd zoneinfo
sudo zic africa antarctica asia australasia backward etcetera europe factory northamerica pacificnew southamerica systemv
zdump -v Pacific/Apia # or any time zone that shows the latest tzdata update
@mislav
mislav / procs-vs-lambda.md
Last active March 26, 2021 18:34
Jim Weirich on the differences between procs and lambdas in Ruby

Jim Weirich:

This is how I explain it… Ruby has Procs and Lambdas. Procs are created with Proc.new { }, lambdas are created with lambda {} and ->() {}.

In Ruby 1.8, proc {} creates lambda, and Ruby 1.9 it creates procs (don't ask).

Lambdas use method semantics when handling parameters, procs use assignment semantics when handling parameters.

This means lambdas, like methods, will raise an ArgumentError when called with fewer arguments than they were defined with. Procs will simply assign nil to variables for arguments that were not passed in.

@headius
headius / gist:4343186
Created December 20, 2012 05:42
Running a startup flag-timing tool for JRuby users, to find the best flags on their system.
system ~/projects/jruby/blah $ jruby ../../startup_bench/lib/tune.rb 1 'touch Gemfile.lock && rm Gemfile.lock && jruby -S bundle install --quiet --local'
Beginning tuning for `touch Gemfile.lock && rm Gemfile.lock && jruby -S bundle install --quiet --local`
Trying 90 combinations of flags
--------------------------------------------------------------------------------
Last: -J-server
Average time: 8.529s
Overall average: 8.529s
Estimated completion time: 2012-12-19 23:46:27 -0600
--------------------------------------------------------------------------------
Last: -J-client
MRI 1.8.7-p371
>> $KCODE
=> "NONE"
>> "s.net" =~ /\A[^\W_]+([-.][^\W_]+)*\.[a-z]{2,6}\.?\Z/i
=> 0
>> $KCODE = 'UTF8'
=> "UTF8"
>> "s.net" =~ /\A[^\W_]+([-.][^\W_]+)*\.[a-z]{2,6}\.?\Z/i
=> 0
@knu
knu / git-word-diff-auto
Created November 29, 2012 10:55
git-word-diff-auto - offers a missing --word-diff="auto"
#!/bin/sh
#
# git-word-diff-auto - offers a missing --word-diff="auto"
#
# Copyright (c) 2012 Akinori MUSHA
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions