Skip to content

Instantly share code, notes, and snippets.

View mitsuse's full-sized avatar
💭
🐈🐈

mitsuse mitsuse

💭
🐈🐈
View GitHub Profile
@mitsuse
mitsuse / number.go
Created July 4, 2014 15:06
An interface named "Number" accepts numeric types such as "Int", "Float" and so on.
package main
import "fmt"
type Number interface {
Add(x Number) Number
Sub(x Number) Number
}
type Int int
@mitsuse
mitsuse / base-complete
Created September 13, 2014 22:00
A template for neocomplete source
let s:source = {
\ 'name': '{{_name_}}',
\ 'mark': '[{{_name_}}]',
\}
function! s:source.gather_candidates(context)
return []
endfunction
function! neocomplete#sources#{{_name_}}#define()
@mitsuse
mitsuse / kyushu.vim
Created September 14, 2014 11:10
A neocomplete source for people who live in Kyushu.
let s:source = {
\ 'name': 'kyushu',
\}
function! s:source.gather_candidates(context)
let l:candSeq = [
\ 'Fukuoka',
\ 'Saga',
\ 'Nagasaki',
\ 'Oita',
@mitsuse
mitsuse / coverage.bash
Created January 7, 2015 03:38
Shell scripts to calculate test coverage in Golang
#!/bin/bash
base_package=github.com/user_name/repo_name
base_path=${GOPATH}/src/${base_package}
package_list=(
${base_package}
)
if [ ! -d ${base_path}/coverprofile ]
@mitsuse
mitsuse / dissim.go
Created January 22, 2015 13:44
Calculate dissimlarities between the source image and target images.
package main
import (
"fmt"
"image"
"image/png"
"os"
"github.com/codegangsta/cli"
"github.com/mitsuse/mitsuse-go/image/similarity"
@mitsuse
mitsuse / main.go
Created February 19, 2015 01:12
An example of command-line tool implemented in Golang with codegangsta/cli.
package main
import (
"fmt"
"os"
"github.com/codegangsta/cli"
)
func main() {
@mitsuse
mitsuse / file0.go
Last active August 29, 2015 14:23
gocron でジョブスケジューリング ref: http://qiita.com/mitsuse/items/8669bf54d2310b3e68a1
package main
import (
"fmt"
"github.com/jasonlvhit/gocron"
)
func main() {
scheduler := gocron.NewScheduler()
@mitsuse
mitsuse / LICENSE.txt
Last active August 29, 2015 14:26
Watch updating a file written in DOT and generate the graph. This gist requires watchdog (https://github.com/gorakhargosh/watchdog).
The MIT License (MIT)
Copyright (c) 2015 Tomoya Kose.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@mitsuse
mitsuse / pre-push.py
Last active November 17, 2015 01:53
Forbid to push remote branches specified with an environment variable "GIT_PROTECTED_BRANCHES".
#!/usr/bin/env python3
# coding: utf-8
def main():
import sys
local_ref, local_sha1, remote_ref, remote_sha1 = sys.stdin.readline().split()
remote_branch = extract_branch(remote_ref)
if remote_branch in list_protected_branches():
@mitsuse
mitsuse / Tree.scala
Last active December 19, 2015 22:28
import scala.util.parsing.combinator._
class Tree[L](val label: L, val children: Seq[Tree[L]]) extends Traversable[Tree[L]] {
val numOfChildren = children.length
def this(label: L) = this(label, Seq[Tree[L]]())
override def toString: String = {
if (isTerminal) {
return label.toString