Skip to content

Instantly share code, notes, and snippets.

View mumoshu's full-sized avatar
🏠
Working from home

Yusuke Kuoka mumoshu

🏠
Working from home
View GitHub Profile
@wtaysom
wtaysom / where_is.rb
Created September 23, 2011 08:57
A little Ruby module for finding the source location where class and methods are defined.
module Where
class <<self
attr_accessor :editor
def is_proc(proc)
source_location(proc)
end
def is_method(klass, method_name)
source_location(klass.method(method_name))
@kinopyo
kinopyo / gist:1350279
Created November 9, 2011 03:46
Rails asset(画像、CSSなど)hostのについての勉強メモです。

asset hostを指定

image_tag("rails.png")のhelper methodで生成するリンクはデフォルトでは同じホストのpublicフォルダを指しています。それを変更したい場合はconfig/environments/production.rbActionController::Base.asset_hostをいじります。

ActionController::Base.asset_host = "assets.example.com"
image_tag("rails.png")
# => <img alt="Rails" src="http://assets.example.com/images/rails.png?1230601161" />
@tbje
tbje / plugins.sbt
Created November 23, 2011 12:09
Different versions of sbt and global plugins
import sbt._
import Defaults._
libraryDependencies <++= (scalaVersion, sbtVersion) {
case (scalaVersion, sbtVersion @ "0.11.0") => Seq(
sbtPluginExtra("name.heikoseeberger.groll" % "groll" % "0.4.0-SNAPSHOT", sbtVersion, scalaVersion), // corresponds to addSbtPlugin("name.heikoseeberger.groll" % "groll" % "0.4.0-SNAPSHOT")
sbtPluginExtra("com.typesafe.sbteclipse" % "sbteclipse" % "1.5.0-SNAPSHOT", sbtVersion, scalaVersion)
)
case (scalaVersion, sbtVersion @ "0.11.1") => Seq(
@cailinanne
cailinanne / cache_book.rb
Created November 28, 2011 03:33
Testing cache clearing with Rails 3.1 and Rspec
#spec/requests/cache_book_spec.rb
require 'spec_helper'
describe "CacheBook" do
# Turn on caching
before do
ActionController::Base.perform_caching = true
ActionController::Base.cache_store = :file_store, "tmp/cache"
FileUtils.rm_rf(Dir['tmp/cache'])
@Koc
Koc / gist:1501185
Created December 20, 2011 10:50
start-stop-daemon php example
#!/bin/sh
# Quick start-stop-daemon example, derived from Debian /etc/init.d/ssh
set -e
NAME="brouzie-php-53"
RUN_AS_USER=brouzie
PHP_FCGI_CHILDREN=3
PHP_FCGI_MAX_REQUESTS=200
@czarneckid
czarneckid / gist:1536207
Created December 29, 2011 21:08
Installing older or specific versions of Homebrew formulas

We first want to take a look at what versions are installed for a given formula, brew info FORMULA. Let's take a look at the versions of Redis that are installed.

@czq. ➜  Formula rvm:() git:(master) brew info redis
redis 2.4.5
http://redis.io/
/usr/local/Cellar/redis/2.4.4 (9 files, 460K)
/usr/local/Cellar/redis/2.4.5 (9 files, 460K) *
...
@dcarley
dcarley / README.md
Created February 1, 2012 10:49
VirtualBox NAT interface stops responding under load

VirtualBox NAT bug

Pushing a certain quantity/mixture of data through a VB guest's NAT interface causes all TCP/UDP connections to fail for a period of time thereafter.

The only way I've been able to reliably reproduce this is to use pip(1) to download a large list of Python packages. After a number of packages have been downloaded (14~20) pip will exit with an HTTP or DNS timeout. Inbound port-forwarded SSH connections will drop with:

Connection to 127.0.0.1 closed by remote host.

This appears most likely to occur with the Intel PRO/1000 MT Desktop (82540EM) NIC. It is harder to reproduce with PCnet-FAST III (Am79C973) NICs. It is not reproducible with host-only or bridged adapters.

@alobato
alobato / start-stop-example.sh
Created March 3, 2012 23:09
start-stop-example
#!/bin/sh
# Quick start-stop-daemon example, derived from Debian /etc/init.d/ssh
set -e
# Must be a valid filename
NAME=foo
PIDFILE=/var/run/$NAME.pid
#This is the command to be run, give the full pathname
DAEMON=/usr/local/bin/bar
@finack
finack / application.rb
Created March 17, 2012 06:18
Example Chef Deploy Revision for Rails 3+
app = node[:rails][:app]
rails_base app[:name] do
ruby_ver app[:ruby_ver]
gemset app[:gemset]
end
%w{config log pids cached-copy bundle system}.each do |dir|
directory "#{app[:app_root]}/shared/#{dir}" do
owner app[:deploy_user]
@j5ik2o
j5ik2o / gist:2156447
Created March 22, 2012 05:41
Play framework 2.0でデーモン化する方法

commons-daemonの依存関係を追加する

次のようにproject/Build.scala を編集する。

object ApplicationBuild extends Build {
    // ...
    val appDependencies = Seq(
      "commons-daemon" % "commons-daemon" % "1.0.10"
    )

// ...