Skip to content

Instantly share code, notes, and snippets.

@furaibo
furaibo / e-hentai.py
Last active July 29, 2025 14:19
E-Hentaiギャラリーの画像をダウンロードするPythonスクリプトです。ご自由にお使い下さい。
#!/usr/bin/python
#-*-coding:utf-8 -*-
# E-HentaiのページURLをもとにギャラリー画像を取得するスクリプト
# パッケージのインポート
import os
import sys
import re
import urllib2
Ruby 2.1.0 in Production: known bugs and patches
Last week, we upgraded the github.com rails app to ruby 2.1.0 in production.
While testing the new build for rollout, we ran into a number of bugs. Most of
these have been fixed on trunk already, but I've documented them below to help
anyone else who might be testing ruby 2.1 in production.
@naruse I think we should backport these patches to the ruby_2_1 branch and
release 2.1.1 sooner rather than later, as some of the bugs are quite critical.
I'm happy to offer any assistance I can to expedite this process.
@wancw
wancw / git-today-summary
Created December 19, 2013 10:32
Summarize what you did today.
#!/usr/bin/env bash
git log --all --since=midnight --author="$USER" $* --format='%d' --numstat \
| awk -f <(cat <<- 'SCRIPT'
/\(/ { NB=NB+1 ; next }
NF==3 { ADD=ADD+$1; DEL=DEL+$2; NC=NC+1 }
END { printf "+%d, -%d in %d commit(s), %d branch(es)\n", ADD, DEL, NC, NB }
SCRIPT)
@wancw
wancw / ls-migrations-then-checkout
Last active December 16, 2016 18:55
列出切換 branch 前需要 rollback 的 South migration。
#!/usr/bin/env zsh
if [[ $# != 1 ]]; then
cat - << USAGE
Usage: `basename $0` <branch>
USAGE
return 1
fi
local old_branch=$(git rev-parse --abbrev-ref HEAD)
@hovsater
hovsater / gist:7688474
Last active December 29, 2015 15:09
User-defined command to setup key mappings for RSpec.
function RSpecCommands(bang)
if !a:bang
noremap <Leader>t :!bundle exec rspec %<CR>
noremap <Leader>T :!bundle exec rspec %:<C-R>=line('.')<CR><CR>
else
silent! nunmap <Leader>t
silent! nunmap <Leader>T
endif
endfunction
@9cardinals
9cardinals / gist:7652799
Created November 26, 2013 02:55
error on model generation
vera:bloccit monicacardinal$ bundle exec bin/rails generate model Post title:string body text
invoke active_record
/Users/monicacardinal/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.12/lib/active_record/dynamic_matchers.rb:55:in `method_missing': undefined method `migration_error=' for #<Class:0x007fa9d3fdaca8> (NoMethodError)
from /Users/monicacardinal/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.12/lib/active_record/railtie.rb:66:in `block (3 levels) in <class:Railtie>'
from /Users/monicacardinal/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.12/lib/active_record/railtie.rb:65:in `each'
from /Users/monicacardinal/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.12/lib/active_record/railtie.rb:65:in `block (2 levels) in <class:Railtie>'
from /Users/monicacardinal/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-3.2.12/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
from /Users/monicacardinal/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-3.2.12/lib/active_support/lazy_load_hooks.rb:36
@jimweirich
jimweirich / weird.rb
Created November 5, 2013 03:51
What does the following print? I was surprised. (Actually, I was surprised it was legal syntax.)
def foo(a=:default, b)
puts "a=#{a}, b=#{b}"
end
foo(:value)
foo(:x, :y)
@desimone
desimone / crashplan.freenas.md
Last active April 16, 2017 16:22
How-to install the Crashplan plugin with Freenas

How-to : Crashplan & Freenas

Pre-requisites

Install

Step 0: Skip if you are using existing install

@sepastian
sepastian / multi_cartesian_product.rb
Last active July 26, 2024 19:46
Build the cartesian product of multiple arrays in Ruby.
# Given an array of arrays s = [ [1,2,3], [4,5,6], ... ]
# compute the Cartesian product among the elements of s.
require 'pp'
s = [[1, 2], [3, 4, 5], [6, 7, 8, 9]]
pp s[1..-1].inject(s[0]){ |m,v| m = m.product(v).map(&:flatten) }
[[1, 3, 6],
[1, 3, 7],
[1, 3, 8],
@scy
scy / opening-and-closing-an-ssh-tunnel-in-a-shell-script-the-smart-way.md
Last active July 27, 2025 18:17
Opening and closing an SSH tunnel in a shell script the smart way

Opening and closing an SSH tunnel in a shell script the smart way

I recently had the following problem:

  • From an unattended shell script (called by Jenkins), run a command-line tool that accesses the MySQL database on another host.
  • That tool doesn't know that the database is on another host, plus the MySQL port on that host is firewalled and not accessible from other machines.

We didn't want to open the MySQL port to the network, but it's possible to SSH from the Jenkins machine to the MySQL machine. So, basically you would do something like

ssh -L 3306:localhost:3306 remotehost