Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
require 'json'
def parse(uri)
JSON.parse `curl #{uri}`.gsub("/*\n * This file is intended for use only on aws.amazon.com. We do not guarantee its availability or accuracy.\n *\n * Copyright 2014 Amazon.com, Inc. or its affiliates. All rights reserved.\n */\ncallback({",'{').gsub("\);", '').gsub(/([a-zA-Z]+):/, '"\1":')
end
table = {
:light => parse('http://a0.awsstatic.com/pricing/1/ec2/previous-generation/light_linux.min.js'),
@tatsuru
tatsuru / app.psgi
Created October 6, 2014 12:29
plack sample
use Plack::Builder;
my $app = sub {
return [ 200, [ 'Content-Type' => 'text/plain' ], [ 'Hello World' ] ];
};
builder {
enable "ServerStatus::Lite", path => '/server-status', allow => ['127.0.0.1'], scoreboard => '/dev/shm/server-status', counter_file => '/tmp/counter_file';
$app;
};
@tatsuru
tatsuru / Dockerfile
Created April 16, 2014 07:18
ikachan dockerfile
# Ikachan Dockerfile
FROM tatsuru/debian
RUN apt-get update
RUN apt-get install -y build-essential curl libssl-dev
RUN curl -s https://raw.githubusercontent.com/tagomoris/xbuild/master/perl-install > /tmp/perl-install
RUN bash /tmp/perl-install 5.18.2 /opt/perl-5.18
@tatsuru
tatsuru / gist:8837289
Created February 6, 2014 02:16
skype event
%type 通知の種類
%sname 相手の名前
%fname ファイル名
%fpath ファイルのパス?
%smessage メッセージ
%fsize ファイルサイズ
%sskype ?
@tatsuru
tatsuru / gist:8518036
Created January 20, 2014 10:37
tmux status line
set -g status-right "#W [#(cat /sys/class/power_supply/BAT0/status | cut -c-1)#(cat /sys/class/power_supply/BAT0/capacity)][#(cat /sys/class/power_supply/BAT1/status | cut -c-1)#(cat /sys/class/power_supply/BAT1/capacity)] %Y/%m/%d %H:%M"
package main
import (
"fmt"
"math"
)
func sqrt_newton(x float64) float64 {
z, prev := 1.0, 3.0
const threshold = 1e-15
@tatsuru
tatsuru / c.js
Created September 15, 2013 15:31
var c = function(){ $('div#bigCookie').click(); };
setInterval(c, 1);
var g = function(){$('div#goldenCookie').click();};
setInterval(g, 5000);
var u0 = function(){$('div#upgrade0').click();};
setInterval(u0, 1000);
var calculator = function() {
@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