Skip to content

Instantly share code, notes, and snippets.

View siburu's full-sized avatar

YOSHIDA Masanori siburu

View GitHub Profile
@siburu
siburu / Zundoko.java
Last active March 18, 2016 15:14
No tricky zundoko program in Java
class Zundoko {
public static void main(String args[]) {
java.util.Random rnd = new java.util.Random();
int zun;
do {
for (zun = 0; rnd.nextBoolean(); zun++) {
System.out.println("ズン");
}
System.out.println("ドコ");
} while (zun < 4);

Test of Slideck

hoge


Foo

foo


(* How to build: corebuild -pkg lwt.unix,lwt.syntax zundoko.native *)
open Lwt.Infix
let print_zundoko x =
Lwt_io.printl (if x then "Zun" else "Doko")
let print_kiyoshi () =
Lwt_list.iter_s
(fun (d,s) -> Lwt_unix.sleep d >> Lwt_io.print s)
package main
type recFunc func(int, recFunc)
func call(n int, f recFunc) {
defer println("r", n)
println(n)
if n > 0 {
f(n-1, f)
}
@siburu
siburu / printf-is-calculator.zsh
Last active December 14, 2015 01:22
Zsh's printf is more useful than that of Bash.
#!/bin/zsh
printf '%d\n' '12+34'
printf '%d\n' '1<<10'
printf '%d\n' '5^11'
printf '%d\n' '3**5'
@siburu
siburu / what-mmap-does.go
Last active December 11, 2015 03:26
Test code for investigating Golang's mmap behaviour
package main
import (
"fmt"
"syscall"
"unsafe"
)
type slice struct {
addr uintptr
@siburu
siburu / package-renaming.go
Created December 10, 2015 10:13
You can rename packages and omit package names.
package main
import (
. "fmt"
log4j "log"
)
func main() {
Printf("Hello, %s.\n", "today")
log4j.Println("Printing a log.")
@siburu
siburu / go-delete-slice-elements-in-loop.go
Created December 7, 2015 07:31
You must use a downward loop
// http://stackoverflow.com/questions/29005825/how-to-remove-element-of-struct-array-in-loop-in-golang
package main
func correctDeletion() {
var array [10]int
for i, _ := range array {
array[i] = i
}
s := array[:]
@siburu
siburu / go-unexpected-infinite-loop.go
Created December 7, 2015 07:22
In select statement, reading from a closed channel is selected immediately without going to a default case.
package main
func main() {
ch := make(chan struct{})
close(ch)
/*
for _ = range ch {
}
*/

Must configure

sudo sysctl -w net.core.somaxconn=65535
sudo sysctl -w net.ipv4.tcp_max_syn_backlog=65535

Also important

net.ipv4.tcp_syncookies