Skip to content

Instantly share code, notes, and snippets.

@yanolab
yanolab / asttest.go
Created February 17, 2019 12:12
go AST
package main
import (
"fmt"
"go/ast"
"go/parser"
"go/token"
"io/ioutil"
"os"
"os/exec"
@yanolab
yanolab / DI_sample.scala
Created May 2, 2017 10:58
Guice DI sample
import com.google.inject.{AbstractModule, Guice}
trait Service
trait Client
trait Factory {
def newClient(n: Node): Client
def newService(n: Node): Service
}
case class Node(host: String, port: Int)
@yanolab
yanolab / printnif.go
Created September 7, 2015 09:57
print network interfaces and mask.
package main
import (
"fmt"
"net"
)
func main() {
ifaces, err := net.Interfaces()
if err != nil {
@yanolab
yanolab / reverse-scrolling.ahk
Created August 24, 2015 03:40
Reverse scrolling likes MacOS X
WheelUp::
Send {WheelDown}
Return
WheelDown::
Send {WheelUp}
Return
@yanolab
yanolab / libgofib.go
Created May 21, 2015 00:32
sample of shared library for go1.5(cgo)
package main
import (
"C"
"log"
)
//export fib
func fib(n int) int {
if (n < 2) { return n }
@yanolab
yanolab / clip2img.py
Created August 27, 2014 05:24
Save image from clipboard to local file.
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import gtk
def save_clipimg(filename):
clipboard = gtk.clipboard_get()
image = clipboard.wait_for_image()
@yanolab
yanolab / .conkyrc
Last active August 29, 2015 14:05
My conkyrc file for dynabook KIRA
# .conkyrc
alignment bottom_left
gap_x 0
gap_y 0
background no
use_xft yes
xftfont Bitstream Vera Sans Mono:size=10:Bold
@yanolab
yanolab / coins.py
Created May 2, 2014 22:04
coins.py
# -*- coding: utf-8 -*-
def product(v, coins=[500, 100, 50, 10, 5, 1], used=[]):
if len(coins) == 1:
yield 1
else:
for i, coin in enumerate(coins):
diff = v - coin
if diff == 0:
yield 1
package main
import (
"fmt"
"sync"
)
var workerSize = 4
type Fetcher interface {
@yanolab
yanolab / gohttp.go
Last active December 24, 2015 21:29
Simple GO static web contents server.
package main
import (
"errors"
"flag"
"fmt"
"log"
"net"
"net/http"
"os"