Skip to content

Instantly share code, notes, and snippets.

@torsten
torsten / proxy.rb
Last active April 30, 2024 17:53
A quick HTTP proxy server in Ruby.
#!/usr/bin/env ruby
# A quick and dirty implementation of an HTTP proxy server in Ruby
# because I did not want to install anything.
#
# Copyright (C) 2009-2014 Torsten Becker <torsten.becker@gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
@henrik
henrik / hash_deep_diff.rb
Created July 14, 2009 08:38
Recursively diff two Ruby hashes.
# Recursively diff two hashes, showing only the differing values.
# By Henrik Nyh <http://henrik.nyh.se> 2009-07-14 under the MIT license.
#
# Example:
#
# a = {
# "same" => "same",
# "diff" => "a",
# "only a" => "a",
# "nest" => {
@wbailey
wbailey / databases.rake
Created February 11, 2011 08:58
ActiveRecord migrations outside of Rails
require 'yaml'
require 'logger'
require 'active_record'
namespace :db do
def create_database config
options = {:charset => 'utf8', :collation => 'utf8_unicode_ci'}
create_db = lambda do |config|
ActiveRecord::Base.establish_connection config.merge('database' => nil)
@timdiggins
timdiggins / chef-roles-to-json-task.rb
Created February 19, 2011 06:53
rake task to convert existing ruby roles to json
# ADD this to Rakefile and run it by issuing rake roles.to_json
ROLE_DIR = File.expand_path(File.join(TOPDIR, "roles"))
namespace :roles do
desc "Convert ruby roles from ruby to json, creating/overwriting json files."
task :to_json do
Dir.glob(File.join(ROLE_DIR, '*.rb')) do |rb_file|
role = Chef::Role.new
role.from_file(rb_file)
json_file = rb_file.sub(/\.rb$/,'.json')
@pksunkara
pksunkara / config
Last active June 21, 2024 08:46
Sample of git config file (Example .gitconfig) (Place them in $XDG_CONFIG_HOME/git)
[user]
name = Pavan Kumar Sunkara
email = pavan.sss1991@gmail.com
username = pksunkara
[init]
defaultBranch = master
[core]
editor = nvim
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
pager = delta
@r-moeritz
r-moeritz / pretty-literals.lisp
Created June 24, 2011 10:30
pretty hash table & vector literal syntax for common lisp
;;;; pretty-literals.lisp - pretty hash table & vector literal syntax
;;;; inspired by and uses code from http://frank.kank.net/essays/hash.html
(in-package #:pretty-literals)
;; vector literal syntax using brackets
(set-macro-character #\[
(lambda (str char)
(declare (ignore char))
(let ((*readtable* (copy-readtable *readtable* nil))
@jacobvosmaer
jacobvosmaer / gist:3187346
Created July 27, 2012 10:35
Open all files with git merge conflicts in Vim

Open all files with git merge conflicts in MacVim

git diff --name-only | uniq | xargs mvim

When git encounters a merge conflict, e.g. during a rebase, it drops you back into the shell with a dirty working directory. I like this one-liner for opening all files with a merge conflict in MacVim.

Once you're in Vim, you can then switch between the files with :n and :prev, or another favourite: :w | n (save current file and open the next command line-supplied file).

UPDATE: see below for a version that works with real terminal commands.

# 2017年9月以降は Flash ではなく m3u8 での配信になりましたので、この内容は古くなりました。
# 新しい録音方法に関しては
# https://gist.github.com/riocampos/93739197ab7c765d16004cd4164dca73
# をご覧ください。
##############################################################################
# RTMPEのtype9 handshakeに対応している必要があるのでRTMPDump v2.4必須
# ラジオ第2は全放送局とも同じ
# swfVfyオプションのURLは http://www3.nhk.or.jp/netradio/files/swf/rtmpe.swf でもOK
# 各チャンネルに2種類ずつ記載していますがどちらも同じなので好みの物を使ってください
@catupper
catupper / 0.幼女問題
Last active July 30, 2022 05:19
幼女問題まとめ
幼女問題というのは、論理パズルの問題のことです。幼女は「幻ノ女」の略称です。論理パズルの世界で登場する、完璧な演繹、推論をするこの世ならざる存在として幼女が使われます。
結果、「幼女問題」と名にし負う問題は沢山あります。今回は、有名無名関係なく、あらゆる論理パズルを幼女問題にしました。
1.2人の幼女のケーキ分け
2.2人の幼女の数あて
3.3人の幼女の数あて
4.5人の幼女の山分け
5.5人の幼女の組あて
6.13人の幼女とトランプの館
7.23人の幼女と石像の館
@dashed
dashed / github-pandoc.css
Created September 26, 2013 13:42
GitHub-like CSS for pandoc standalone HTML files (perfect for HTML5 output). Based on Marked.app's GitHub CSS. Added normalize.css (v2.1.3) in the prior to GitHub css.
/*! normalize.css v2.1.3 | MIT License | git.io/normalize */
/* ==========================================================================
HTML5 display definitions
========================================================================== */
/**
* Correct `block` display not defined in IE 8/9.
*/