Skip to content

Instantly share code, notes, and snippets.

@tkawachi
tkawachi / .Rprofile
Created December 20, 2011 01:54
Show correct Japanese font for R
setHook(packageEvent("grDevices", "onLoad"),
function(...){
if(.Platform$OS.type == "windows")
grDevices::windowsFonts(sans ="MS Gothic",
serif="MS Mincho",
mono ="FixedFont")
if(capabilities("aqua"))
grDevices::quartzFonts(
sans =grDevices::quartzFont(
c("Hiragino Kaku Gothic Pro W3",
getQueryVariable = (variable) ->
query = root.location.search.substring(1)
pairStrings = query.split('&')
for pairString in pairStrings
pair = pairString.split("=")
if pair[0] == variable
return unescape(pair[1])
console.log("WARN: #{variable} is not found in query string")
#!/bin/bash
set -e
set -u
SOLR_DIRNAME="apache-solr-3.5.0"
SOLR_URL="http://tonchidot.s3.amazonaws.com/projects/NewSC/Server-Dev/apache-solr-3.5.0.tar.gz"
INSTALL_DIR="/usr/local/solr"
SCRIPT_FILE="$HOME/bin/start_solr.sh"
cd /tmp
@tkawachi
tkawachi / gist:2577734
Created May 2, 2012 15:55
Install gocode for go Mac binary distribution
PATH="$PATH:/usr/local/go/bin"
export GOBIN="$HOME/bin"
export PATH=$PATH:$HOME/bin
export GOPATH=/tmp
go get -u github.com/nsf/gocode
cd $GOPATH/src/github.com/nsf/gocode/vim/
./update.bash
require 'rake'
dependency = {
'all' => ['attr 1', 'attr 2', 'attr 3', 'attr 5'],
'attr 1' => ['attr 2', 'attr 3'],
'attr 2' => ['attr 5'],
'attr 3' => [],
'attr 5' => [],
}
@tkawachi
tkawachi / gist:3345106
Created August 14, 2012 00:27
recursive_symbolize_keys
class Hash
def recursive_symbolize_keys!
symbolize_keys!
values.select { |v| v.is_a? Hash }.each { |h| h.recursive_symbolize_keys! }
self
end
def recursive_symbolize_keys
dup.recursive_symbolize_keys!
end
@tkawachi
tkawachi / gist:3345511
Created August 14, 2012 01:23
rand_string
def rand_string(length=16)
chars = [*('A'..'Z'), *('a'..'z'), *(0..9)]
(0..length).map {chars.sample}.join
end
#!/usr/bin/env ruby
$:.push File.join(File.dirname(__FILE__), "../lib")
require 'pry'
require 'mylibrary'
binding.pry quiet: true
@tkawachi
tkawachi / gist:3530304
Created August 30, 2012 15:03
Gon に Ruby の Module で定義された定数を渡す
module Const
ABC = 1
module CategoryX
XYZ = 2
end
# Gon で JavaScript, CoffeeScript に渡せるように定数を hash に変換する
# @param [Module] target
def to_hash(target = self)
# coding: UTF-8
class GitUtil
class << self
# Current source code revision
def revision
rev = capistrano_revision
rev = command_revision unless rev
rev.try(:chomp)
end