Skip to content

Instantly share code, notes, and snippets.

View kubo39's full-sized avatar
๐Ÿ’ญ
I may be slow to respond.

Hiroki Noda kubo39

๐Ÿ’ญ
I may be slow to respond.
  • Tokyo, Japan
  • 17:52 (UTC +09:00)
View GitHub Profile
@kubo39
kubo39 / rftoy.d
Last active December 24, 2015 19:59
it's a toy
module randomforest;
import std.random : uniform;
import std.math : log, sqrt;
import std.typecons;
import std.algorithm : swap;
import std.conv : to;
import std.stdio;
import std.socket;
import core.thread;
import core.time;
import core.sync.mutex;
class Resolver {
private Mutex m;
Address[][string] cache;
@kubo39
kubo39 / fibo.d
Created September 27, 2013 08:19
import std.stdio;
import std.concurrency;
void fib() {
auto msg = receiveOnly!(Tid, long)();
auto n = msg[1];
switch (n) {
case 0L: {
@kubo39
kubo39 / brainfxxk.d
Last active December 23, 2015 05:49
Dใงbrainf*ck
import std.stdio, std.file;
uint MAX_PROG_LEN = 30000;
void main(string[] args) {
auto program = cast(string) read(args[1], MAX_PROG_LEN);
// prepare VM
@kubo39
kubo39 / cmd.txt
Created April 15, 2013 15:17
ใฉใฎใ‚ณใƒžใƒณใƒ‰ใ‚’ใ‚ˆใไฝฟใฃใฆใ‚‹ใ‹
$ cat ~/.bash_history | sed "s|sudo ||g" | cut -d " " -f 1 | sort | uniq -c | sort -n | tail -n 10
37 top
39 dmd
39 ruby
46 make
51 rake
59 rackup
225 ls
268 gem
311 cd
@kubo39
kubo39 / queue.h
Last active December 15, 2015 15:19
#ifndef SIMPLE_QUEUE_H
#define SIMPLE_QUEUE_H
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <inttypes.h>
typedef struct {
void *val;
@kubo39
kubo39 / async.md
Created March 23, 2013 17:33
้žๅŒๆœŸใƒ—ใƒญใ‚ฐใƒฉใƒŸใƒณใ‚ฐใ‚ใ‚‚

้žๅŒๆœŸใจใ‹ไธฆๅˆ—ใจใ‹

ใ„ใ‚ใ‚†ใ‚‹้žๅŒๆœŸ

2็จฎ้กž่€ƒใˆใ‚‰ใ‚Œใ‚‹

  • IOๅคš้‡ๅŒ–(epoll/kqueue/etc..)

read(2)/write(2)ใŒ้žๅŒๆœŸ

@kubo39
kubo39 / fakednsserver.rb
Last active December 13, 2015 23:39
fake DNS server
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'socket'
class DNSQuery
attr_reader :domain_io
def initialize data
@data = data
@domain_io = ''

ใƒ‘ใ‚ฟใƒผใƒณ่ช่ญ˜

ใ‚‚ใฎใŒใฉใฎใใ‚‰ใ„ไผผใฆใ„ใ‚‹ใ‹=้กžไผผๅบฆ

ไผผใฆใ„ใ‚‹๏ผ็›ธๅฏพ้‡

  • ไป–ใฎใ‚‚ใฎใŒใชใ„ใจๅˆคๆ–ญใงใใชใ„(ๆญฃไพ‹ใ€่ฒ ไพ‹)
import std.stdio;
class BinaryIndexedTree {
int size;
int[] bits;
this(int l){
size = l;
bits.length = l+1;
}