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
@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 / 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 / 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",
@yagihiro
yagihiro / sample.c
Last active July 29, 2022 11:25
timer sample on linux kernel
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/timer.h>
#include <linux/jiffies.h>
static void mykmod_timer_handler(unsigned long data);
static unsigned long onesec;
DEFINE_TIMER(mytimer, mykmod_timer_handler, 0, 0);
@yagihiro
yagihiro / sample.c
Last active August 29, 2022 23:18
workqueue sample on linux kernel
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/workqueue.h>
static void mykmod_work_handler(struct work_struct *w);
static struct workqueue_struct *wq = 0;
static DECLARE_DELAYED_WORK(mykmod_work, mykmod_work_handler);
static unsigned long onesec;
@yagihiro
yagihiro / Makefile
Last active September 9, 2016 04:37
minimum linux kernel module
obj-m := mykmod.o
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
@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 / suffix array sample by c.c
Last active September 9, 2016 04:38
suffix array sample by c
#include <stdio.h>
#include <stdlib.h>
struct SuffixArray
{
unsigned ip; /* index point */
char *suffix;
};
static int compare(const void *l, const void *r)
@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 / .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"