Skip to content

Instantly share code, notes, and snippets.

@tatsuru
tatsuru / c.c
Created May 8, 2013 06:48
chdir(2) and symbolic link
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
int main(int argc, char **argv) {
chdir(argv[1]);
pid_t pid = getpid();
printf("%d\n", (int)pid);
fflush(stdout);
sleep(60);
files = `git diff --name-only \`git describe --abbrev=0 --tags 'HEAD'\` \`git describe --abbrev=0 --tags 'HEAD^'\` #{local_cookbook_path}`.chomp.split("\n")
updated_cookbooks = files.map { |f| f.sub(/^cookbooks\/([^\/]+)\/.*$/, '\1')}.uniq
@tatsuru
tatsuru / Makefile
Created October 3, 2012 09:06
line to add to recent mysql Makefile when creating sandbox
MYSQL_NO_DASH_VERSION = 5.6.7
%_builddir ~/rpms/BUILD
%_smp_mflags -j4
%dist centos5
%_topdir ~/rpms
%debug_package %{nil}
%optflags x86_64 -O2 -fomit-frame-pointer -pipe
@tatsuru
tatsuru / ssh.rb
Created September 26, 2012 07:55
Net::SSH.start(
ip_address, "wtatsuru"
) do |session|
session.open_channel do |channel|
channel.request_pty do |ch, success|
raise "pty" unless success
end
channel.exec("sync") do |ch, success|
ch.on_data do |c, data| puts data end
end
@tatsuru
tatsuru / dante.conf
Created August 11, 2012 12:00
dante.conf
resolveprotocol: fake
route {
from: 0.0.0.0/0 to: 0.0.0.0/0 via: 127.0.0.1 port = 1080
protocol: tcp udp
proxyprotocol: socks_v5 socks_v4
method: none
}
@tatsuru
tatsuru / gist:3296314
Created August 8, 2012 16:18 — forked from onishi/gist:1630307
Media queries for Hatena Group
@media screen and (max-device-width: 480px) {
* {
font-size: 48px;
line-height: 64px;
word-break: break-all;
}
table#banner, div#simple-header, div.sidebar, div.caption {
display:none
}
img.hatena-star-comment-button, img.hatena-star-add-button, img.hatena-star-star {
@tatsuru
tatsuru / glog.pl
Created June 2, 2012 21:37
weechat global log plugin
# Weechat plugin
use strict;
use warnings;
my %options = (
buffer => "glog",
logger => "",
exclude => "",
);
@tatsuru
tatsuru / shift.c
Created November 30, 2011 14:08
cyclic shift
gcc -O3 -S shift.c
@tatsuru
tatsuru / count_tumblr.rb
Created August 29, 2011 00:48
count tumblr posts/day
#!/usr/bin/env ruby
require 'tumblife'
require 'yaml'
if ARGV.length < 2
puts "Usage: count_tumblr.rb blogname outfile [limit]"
exit 0
end