Skip to content

Instantly share code, notes, and snippets.

*** ruby-1.9.3-p484.origin/file.c 2013-07-10 10:33:05.000000000 +0900
--- ruby-1.9.3-p484/file.c 2014-02-03 14:17:21.054461600 +0900
***************
*** 4126,4132 ****
#ifdef __CYGWIN__
#include <winerror.h>
! extern unsigned long __attribute__((stdcall)) GetLastError(void);
#endif
*** ruby-2.0.0-p353/file.c.origin 2014-02-03 14:10:23.019204500 +0900
--- ruby-2.0.0-p353/file.c 2014-02-03 14:10:50.577250200 +0900
***************
*** 4181,4187 ****
#ifdef __CYGWIN__
#include <winerror.h>
! extern unsigned long __attribute__((stdcall)) GetLastError(void);
#endif
@tanitanin
tanitanin / thread_pool.rb
Last active January 4, 2016 21:39
Thrad Pool for arbitarily killing in Ruby
#!/bin/ruby
require 'thread'
class ThreadPool
def initialize(size, &session)
@size = size
@queue = SizedQueue.new(size)
@map = {}
@map_mutex = Mutex.new
session.call(self)
@tanitanin
tanitanin / pipestream.h
Last active December 27, 2015 05:49
popenをfstreamっぽく使うためのラッパー
#pragma once
#include <cstdio>
#include <iostream>
#include <memory>
#include <stdexcept>
class invalid_command : std::runtime_error {
public:
invalid_command(const std::string &cause)
@tanitanin
tanitanin / rvm.cap
Created October 10, 2013 12:42
Capistrano v3でcapistrano/rvmがまだinstall/gemset createを実装してなかったので自分用に書いたメモ
# lib/capistrano/rvm.cap
namespace :rvm do
desc 'RVM install in :rvm_type or :rvm_custom_path'
task :install do |host|
on roles(:app) do
rvm_path = '~/.rvm'
#rvm_path = '/usr/local/rvm' if :rvm_type == :system
#rvm_path = :rvm_custom_path if :rvm_custom_path
rvm_dir = File.dirname(rvm_path)
execute "mkdir -p #{rvm_path} && cd #{rvm_dir} && curl -L https://get.rvm.io | bash"
@tanitanin
tanitanin / hello.rb
Last active December 24, 2015 23:39
Daemonsでデーモン化したスクリプトをCapistranoから起動できるようにする
##### hello.rb
#!/usr/bin/env ruby
require 'daemons'
require 'logger'
# Initialize
logpath = File.expand_path("app.log")
log = Logger.new(logpath)
log.info("Completely initialized")
@tanitanin
tanitanin / gnuplot.h
Last active December 24, 2015 06:09
GnuplotをC++で使うためのクラス
#pragma once
#include <iostream>
#include <string>
#include <memory>
#include <cstdio>
#include <cstdarg>
using namespace std;