Skip to content

Instantly share code, notes, and snippets.

View ktnyt's full-sized avatar
🐱

ktnyt ktnyt

🐱
View GitHub Profile
@ktnyt
ktnyt / gist:5928759
Created July 4, 2013 15:50
An example of access log parsing
#!/usr/bin/env perl
use strict;
use warnings;
my %rank_hour; # Access per hour
my %rank_file; # Access per file
open LOG, "<", "access_log"; # Open log file
open CSV, ">", "access_log.csv"; # Open CSV output file
@ktnyt
ktnyt / ecell4.rb
Last active December 22, 2015 13:59
A brew formula for installing E-Cell version 4. Put the formula in /usr/local/Library/formula, run "brew install ecell4", and add /usr/local/lib/python2.7/site-packages to the $PYTHONPATH variable. Uncomment the lines in the "targets" array to install the module of choice. Note that some of these modules depend on other Python modules (e.g. SciPy)
require 'formula'
# Contact celery [at] g-language.org for questions
# Or should I call this formula plain ecell...?
class Ecell4 < Formula
homepage 'http://www.e-cell.org/'
url 'https://github.com/ecell/ecell4/tarball/master'
sha1 '2b1bdf70b0bdfd09e091943eb110b1aab03db6c6'
version '4'
@ktnyt
ktnyt / bustimer.rb
Created December 26, 2013 08:35
Parsing bus api output with ruby
#!/usr/bin/env ruby
require 'net/http'
require 'uri'
require 'json'
url = 'http://hack.sfc.keioac.jp/sfcbusapi/index.php'
uri = URI.parse( url )
res = Net::HTTP.get( uri )
m = /^callback\((.+)\);$/.match( res )
@ktnyt
ktnyt / needle.c
Last active January 1, 2016 19:49
A simple implementation of the Needleman-Wunsch Algorithm in C.
#include <stdio.h>
#include <stdlib.h>
void reverse(char** Pstring);
int match(char a, char b);
int main(int argc, char* argv[]) {
if(argc < 2) {
fprintf(stderr, "Usage: needle <sequence 1> <sequence 2>");
}
@ktnyt
ktnyt / seive1.c
Created March 24, 2014 09:31
Seive1
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <math.h>
#define BLOCK 30
#define CHECK(X, Y) (X & (1 << (Y - 1)))
int main(int argc, char** argv) {
@ktnyt
ktnyt / seive2.c
Created March 24, 2014 09:31
Seive2
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <math.h>
#define BLOCK 64
int main(int argc, char** argv) {
uint64_t *prime, *mask, limit, i, j;
@ktnyt
ktnyt / seive3.c
Created March 24, 2014 17:12
Seive3
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <math.h>
#define BLOCK 64
#define SHIFT(X) (1ULL << (X - 1))
#define CHECK(X,Y) (X & SHIFT(Y))
@ktnyt
ktnyt / weird-seive.c
Created March 25, 2014 14:55
Weird Stuff
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <math.h>
const uint64_t mask64[] = {
0x0000000000000001,0x0000000000000002,0x0000000000000004,0x0000000000000008,
0x0000000000000010,0x0000000000000020,0x0000000000000040,0x0000000000000080,
0x0000000000000100,0x0000000000000200,0x0000000000000400,0x0000000000000800,
@ktnyt
ktnyt / tsurukame.c
Created April 17, 2014 01:40
つるかめ算 with C
/* とりあえずここの中はテンプレだと思って大丈夫。
** #include <ライブラリ名.h> ってやるとライブラリを使える。
** stdioとstdlibがあれば大抵できるけど他にもほしくなるケースもあるよ。
** int main() っていうのも定型文で、メインの処理をここに書くよ。
** ※だからmainっていう名前なのね。
** int argcとchar** argvはコマンドライン引数って言うよ。
** コンパイルしたあとに実行するときに
** ./hoge 10 20 みたいにするとスペースで区切られた文字列が入ってるよ。
** テンプレここから ***********************************************************
@ktnyt
ktnyt / fibonacci.c
Created April 17, 2014 01:44
フィボナッチ with C
/* とりあえずここの中はテンプレだと思って大丈夫。
** #include <ライブラリ名.h> ってやるとライブラリを使える。
** stdioとstdlibがあれば大抵できるけど他にもほしくなるケースもあるよ。
** int main() っていうのも定型文で、メインの処理をここに書くよ。
** ※だからmainっていう名前なのね。
** int argcとchar** argvはコマンドライン引数って言うよ。
** コンパイルしたあとに実行するときに
** ./hoge 10 20 みたいにするとスペースで区切られた文字列が入ってるよ。
** テンプレここから ***********************************************************