Skip to content

Instantly share code, notes, and snippets.

#include <fstream>
#include <iterator>
std::vector<char> read(const std::string& name) {
std::ifstream ifs(name, std::ios::in | std::ios::binary);
if (ifs.fail()) throw std::runtime_error("file not found");
typedef std::istreambuf_iterator<char> itr;
return std::vector<char>(itr(ifs), itr());
}
@takumakei
takumakei / gitbucket.rb
Created July 12, 2014 11:04
Homebrew formula for the gitbucket
require 'formula'
class Gitbucket < Formula
homepage 'https://github.com/takezoe/gitbucket'
url 'https://github.com/takezoe/gitbucket/releases/download/2.1/gitbucket.war'
sha256 '48ad9f399c6a8dabf38647e12f43139b33e8ede7136edc7f06270dc0beafe9f1'
head do
url 'https://github.com/takezoe/gitbucket.git'
depends_on :ant => :build
@takumakei
takumakei / h2.rb
Last active August 29, 2015 13:59
Homebrew formula for the latest stable version 1.3.176 and beta version 1.4.177 of h2
require 'formula'
class H2 < Formula
homepage 'http://www.h2database.com/'
url 'http://www.h2database.com/h2-2014-04-05.zip'
version '1.3.176'
sha1 '9a87bf67741e1b9f9711db160e783898f4242bfe'
devel do
url 'http://www.h2database.com/h2-2014-04-12.zip'
@takumakei
takumakei / eb.rb
Created April 11, 2014 06:13
Homebrew formula for the eb
require "formula"
class Eb < Formula
homepage "http://www.sra.co.jp/people/m-kasahr/eb/"
url "ftp://ftp.sra.co.jp/pub/misc/eb/eb-4.4.3.tar.bz2"
sha1 "1cc55c90fcac224bf299289e7a0fe1559f0761ab"
def install
system "./configure", "--disable-debug",
"--disable-dependency-tracking",
@takumakei
takumakei / dgate.rb
Created April 8, 2014 16:53
Homebrew formula for the Deploygate cli
require 'formula'
class Dgate < Formula
homepage 'https://deploygate.com/docs/cli'
url 'https://deploygate.com/client/dgate.tar.gz'
sha1 '23e3723bf01f6fbca0a097fc895ca9812a8c9de3'
version '0.0.1'
patch :DATA
@takumakei
takumakei / Gemfile
Last active August 29, 2015 13:56
mongoDB + ruby + map_reduceのサンプル
source "https://rubygems.org"
gem "mongo"
gem "bson_ext"
// TOTP.scala
// Copyright (c) 2013 TAKUMA Kei<takumakei@gmail.com>
// This software is released under the MIT License.
// http://opensource.org/licenses/MIT
package com.takumakei.totp
import scala.annotation.tailrec
object Base32 {
@takumakei
takumakei / backup.sh
Created November 9, 2013 17:18
任意のディレクトリをrsyncで同期バックアップするシェルスクリプト
#!/bin/bash
function find-mount-point {
mount | grep $1 | awk '{print $3}'
}
function check-mount {
a=$(find-mount-point $1)
if [ "$a" = "" ]; then
b=/Volumes/$(basename $1)
@takumakei
takumakei / question.sh
Last active December 26, 2015 23:38
[macosx] shellでダイアログを表示する
#!/bin/bash
function input-text {
script='
set answer to ""
try
tell application "SystemUIServer"
set result to display dialog "question" default answer "" with title "title" buttons {"cancel", "ok"} default button 2
if (get button returned of result) is equal to "ok" then
set answer to (get text returned of result)
@takumakei
takumakei / duri.sh
Last active December 26, 2015 23:38
[macosx] a shell script to create a data-uri from an image file.
#!/bin/bash
function get-property {
sips -g "$1" "$2" | tail -1 | awk '{ print $2 }'
}
function col-80 {
ruby -e "
b = []
while a = gets