Skip to content

Instantly share code, notes, and snippets.

View yagihiro's full-sized avatar
🏠
Working from home

Hiroki Yagita yagihiro

🏠
Working from home
View GitHub Profile
;; Copyright (C) 2007,2008,2009,2010 Hiroki Yagita.
;; ポリシー ----------------------------------------------------------
;; - meadow は捨てました
;; - xemacs は捨てました
;; - なるべくどこでも動くようにしたい
;; - 初期化スクリプトは ~/.emacs.d/init.el にしています
;; - ~/.emacs.d/ の下に分離スクリプトやデータを置くことがあります(それ以外の場所に置かない)
@yagihiro
yagihiro / .screenrc
Created August 23, 2009 05:44
.screenrc
defencoding utf-8
escape ^z^z
termcapinfo * hs@
hardstatus alwayslastline "[%02c] %`%-w%{=b bw}%n %t%{-}%+w"
@yagihiro
yagihiro / suffixarray.rb
Created February 12, 2010 02:45
suffix array sample by ruby
require "bsearch" # http://0xcc.net/ruby-bsearch/index.html.en
class SuffixArray
attr_accessor :word # original string(String)
attr_accessor :sary # suffix array(Array)
def initialize word
@word = word
@sary = Array.new(@word.size) {|i| i }
@yagihiro
yagihiro / indent.rb
Created March 1, 2011 05:38
簡易インデントツール (space 4つを tab 1つへ)
#!/usr/bin/ruby
#
# indent.rb PATH
# -> PATH.new というインデント済みのファイルが生成されます。
#
require "stringio"
out = StringIO.new
File.foreach(ARGV[0]) do |line|
@yagihiro
yagihiro / HttpConnectionWrapper.h
Created April 10, 2011 02:56
Objective-C で簡単に HTTP 通信を取り扱うことができるようにするクラス
//
// HttpConnectionWrapper.h
//
// Created by Hiroki Yagita on 11/04/09.
// Copyright 2011 Hiroki Yagita. All rights reserved.
//
/*! @file */
#import <Foundation/Foundation.h>
@yagihiro
yagihiro / simple_concurrent_queue.h
Last active December 2, 2015 11:03
A queue implementation with concurrency for C++11
/*
The MIT License (MIT)
Copyright (c) 2015 Hiroki Yagita
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@yagihiro
yagihiro / reschedulable_sidekiq.rb
Created January 19, 2016 12:02
Sidekiq を re-schedulable にするスニペット
# 最初にスケジュール済みのジョブを削除する
Sidekiq::ScheduledSet.new.each do |e|
if e.item[‘wrapped’] == self.class.to_s
e.delete
end
end
# もろもろ処理
# 最後に reschedule する
@yagihiro
yagihiro / instagram_oauth_token_request_sample.php
Created January 25, 2016 12:40
instagram_oauth_token_request_sample.php
use GuzzleHttp\Client as Guzzle;
// ...
if ($request->has('code')) {
$params = $request->all();
$g = new Guzzle;
$postParams = [
'form_params' => [
@yagihiro
yagihiro / inotify sample written by c.c
Last active September 9, 2016 04:35
inotify sample written by c on linux 2.6.x
/* http://www.ibm.com/developerworks/jp/linux/library/l-ubuntu-inotify/index.html */
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/inotify.h>
#define EVENT_SIZE ( sizeof (struct inotify_event) )
#define BUF_LEN ( 1024 * ( EVENT_SIZE + 16 ) )
@yagihiro
yagihiro / sample.c
Last active September 9, 2016 04:35
mmap(2) / read(2) system call sample
#include <stdio.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <stdlib.h>
const char *files[] = {
"/usr/share/dict/american-english",