Skip to content

Instantly share code, notes, and snippets.

View kawakami-o3's full-sized avatar

Hayato Mikami kawakami-o3

  • Japan, Tokyo
View GitHub Profile
@kawakami-o3
kawakami-o3 / live_dead.sql
Last active August 29, 2015 14:27
live and dead
select relname,n_live_tup,n_dead_tup,last_vacuum,last_autovacuum from pg_stat_all_tables order by n_dead_tup desc limit 20;
select relname,(relpages/128) mbytes from pg_class order by mbytes desc limit 20;
@kawakami-o3
kawakami-o3 / incomplete_pattern.hs
Created June 16, 2016 04:53
ghc -fwarn-incomplete-patterns -fwarn-incomplete-uni-patterns incomplete_pattern.hs
data Hoge = Foo | Bar
-- to_s :: Hoge -> String
to_s Foo = "foo"
main = do
putStrLn $ to_s Foo
putStrLn $ to_s Bar
#!/usr/bin/env ruby
require 'optparse'
if not File.exist? ".vagrant"
puts "not vagrant directory"
return -1
end
if not File.exist? ".vagrant_ssh_config"
@kawakami-o3
kawakami-o3 / TestWhyNotPost.go
Last active October 15, 2017 16:24
Why not POST
func TestWhyNotPost(t *testing.T) {
testServerPort := 31337
testServerAddr := fmt.Sprintf("127.0.0.1:%d", testServerPort)
testServerRootURL := fmt.Sprintf("http://%s/", testServerAddr)
srv := &Server{}
listener, err := net.ListenTCP("tcp4", &net.TCPAddr{IP: net.IPv4(127, 0, 0, 1), Port: testServerPort})
if err != nil {
panic(err)
}
@kawakami-o3
kawakami-o3 / slice_copy.go
Created February 9, 2018 10:09
golang slice copy
package main
import "fmt"
func copyNg() {
src := []int{0, 1, 2, 3, 4}
dest := src[0:1]
dest = append(dest, src[4:5]...)
package main
import (
"fmt"
"net"
"net/http"
)
type MyMux struct {
}
@kawakami-o3
kawakami-o3 / hyperspec-examples.cl
Created March 21, 2018 15:32
Examples in HyperSpec
; HyperSpec/Body/s_flet_.htm
(defun foo (x flag)
(macrolet ((fudge (z)
;The parameters x and flag are not accessible
; at this point; a reference to flag would be to
; the global variable of that name.
` (if flag (* ,z ,z) ,z)))
;The parameters x and flag are accessible here.
(+ x
(fudge x)
require 'yaml'
def escape str
str = str.chars.map{|c|
if c == "\n"
"\\n"
elsif c == "\r"
"\\r"
elsif c == "\t"
"\\t"
package main
import (
"bytes"
"os"
"github.com/k0kubun/pp"
u "github.com/kawakami-o3/undergo"
)