Skip to content

Instantly share code, notes, and snippets.

@sorah
sorah / relink.sh
Last active August 29, 2015 13:57
homebrew: link missing LinkedKegs again
if [ ! -f $HOME/local/bin/diff-highlight ]
then
wget https://raw.githubusercontent.com/git/git/34d9819e0a387be6d49cffe67458036450d6d0d5/contrib/diff-highlight/diff-highlight
wget https://gist.githubusercontent.com/a2ikm/2dbfb89114dfa5c543ed/raw/e2d8d550ef601c9310712f4187b803658427dd42/diff-highlight.utf8.patch
patch -u diff-highlight < diff-highlight.utf8.patch
chmod +x diff-highlight
rm diff-hilight.orig diff-hilight.utf8.patch
mkdir -p $HOME/local/bin
mv diff-highlight $HOME/local/bin
fi
@akisute
akisute / UILabel+AKiOS6Compatibility.m
Created October 2, 2014 08:24
You will no longer be suffered by iOS 6 Hiragino fonts.
- (NSString *)text6Compatible
{
return self.text;
}
- (void)setText6Compatible:(NSString *)text6Compatible
{
self.text = text6Compatible;
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(7)) {
@rummelonp
rummelonp / _cap
Created February 4, 2015 16:28
capistrano 3 用の zsh 補完関数
#compdef cap
# ------------------------------------------------------------------------------
# Description
# -----------
#
# Completion script for Capistrano (http://capistranorb.com/).
#
# ------------------------------------------------------------------------------
# Authors
# -------
@kamipo
kamipo / server_id
Created February 11, 2015 04:07
MySQLとか(Tokyo|Kyoto)ナントカのserver_idを計算するために使ってたコマンド
#!/usr/bin/perl -l
use strict;
use warnings;
$ENV{LANG} = "C";
$ENV{PATH} ||= "/usr/local/bin:/usr/bin/:/bin";
my $eth = shift || "eth0";
`ip addr list dev $eth|grep 'inet '` =~ m{\.(\d+?)\.(\d+?)\/};
// semicolonless Java
public class A
{
public static void main(String[] args) {
return\u003b
}
}
@a2ikm
a2ikm / gist:305404
Last active September 4, 2015 10:04
dump database to yaml for fixtures
#
#= dump database to yaml for fixtures
#
# originated by elm200 <http://d.hatena.ne.jp/elm200/20070928/1190947947>
#
#== install
#
# move this file to RAILS_ROOT/lib/tasks/extract_fixtures.rake
#
namespace :db do
ja:
# extract from activesupport
date:
formats:
default: "%Y/%m/%d"
short: "%m/%d"
long: "%Y年%m月%d日(%a)"
day_names: [日曜日, 月曜日, 火曜日, 水曜日, 木曜日, 金曜日, 土曜日]
abbr_day_names: [日, 月, 火, 水, 木, 金, 土]
@glv
glv / gist:703997
Created November 17, 2010 20:16
USE INDEX with Active Record finders for Rails 3
# for background, see http://m.onkey.org/use-index-with-active-record-finders
# and http://twitter.com/#!/dougalcorn/status/4963159878139904
from = "#{quoted_table_name} USE INDEX(index_activities_on_created_at_and_country_id)"
Activity.from(from).where('created_at >= ? AND country_id = ?', 10.days.ago, 79).all