Skip to content

Instantly share code, notes, and snippets.

View nojima's full-sized avatar
o_O

Yusuke Nojima nojima

o_O
View GitHub Profile
@nojima
nojima / suffixarray.cpp
Created July 11, 2011 15:49
Suffix Array Construction and String Search
#include <algorithm>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <vector>
using namespace std;
struct Comp1 {
const char* str;
Comp1(const char* str): str(str) {}
@nojima
nojima / terminator_config
Created October 6, 2011 02:46
$HOME/.config/terminator/config
[global_config]
title_transmit_bg_color = '#0300C8'
[keybindings]
go_up = <Alt>K
go_down = <Alt>J
go_left = <Alt>H
go_right = <Alt>L
split_horiz = <Alt>O
split_vert = <Alt>E
@nojima
nojima / ex1_test.rb
Created October 24, 2011 15:32
le2 ex1 test
port = 1234
port = ARGV[0].to_i if ARGV[0]
puts "Test #1"
hoge_txt = IO.read('hoge.txt')
server_pid = spawn("./server #{port}")
begin
result = `./client localhost #{port} hoge.txt`
result.gsub("\r\n", "\n")
if result.index(hoge_txt)
@nojima
nojima / check.rb
Created May 23, 2012 04:11
実験1ソート課題チェック用スクリプト.要 Ruby 1.9
#!/usr/bin/env ruby
# coding: utf-8
# Requirements:
# ruby1.9.1 libruby1.9.1 ruby1.9.1-dev
require "optparse"
require "open3"
include Open3
@nojima
nojima / gist:3813164
Created October 1, 2012 17:23
(ffmpeg) AVIを読み込んで先頭の5フレームをGray画像として取り出すコード
extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
}
int get_first_video_stream_index(AVFormatContext* format_context)
{
for (int i = 0; i < format_context->nb_streams; ++i) {
if (format_context->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
@nojima
nojima / Output.txt
Created October 3, 2012 12:31
ドミニオンで(属州, 金貨, 銀貨)の順に買えるものを買うという戦略を行った際の,nターン目のお金と勝利点の期待値を求めるコード
#Iter: Money Score
# 1: 3.50 3.00
# 2: 3.50 3.00
# 3: 4.50 3.00
# 4: 4.50 3.00
# 5: 5.16 3.22
# 6: 5.55 3.77
# 7: 5.75 4.53
# 8: 6.34 6.00
# 9: 6.34 7.48
<?xml version="1.0" encoding="UTF-8"?>
<gexf xmlns="http://www.gexf.net/1.2draft"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.gexf.net/1.2draft http://www.gexf.net/1.2draft/gexf.xsd"
version="1.2">
<graph defaultedgetype="directed">
<attributes class="node">
<attribute id="0" title="kind" type="string">
<options>source|sink|others</options>
@nojima
nojima / mergesort.cpp
Created November 27, 2012 13:39
Naive implementation of merge sort
$ g++ -Wall -Wextra -std=c++0x -o mergesort mergesort.cpp
@nojima
nojima / crawl.go
Last active December 23, 2015 10:59
A Tour of Go Exercise: Web Crawler
package main
import (
"fmt"
)
type Fetcher interface {
// Fetch returns the body of URL and
// a slice of URLs found on that page.
Fetch(url string) (body string, urls []string, err error)
@nojima
nojima / install-riak
Last active December 24, 2015 19:28
Riak Install Memo (Ubuntu 13.04 Desktop 64bit)
# First of all, we need enlarge the limit of file descripters.
# The following link will help:
# http://docs.basho.com/riak/latest/ops/tuning/open-files-limit/
# Install erlang
$ sudo apt-get install erlang
# Download riak
$ mkdir -p ~/build
$ cd ~/build