Skip to content

Instantly share code, notes, and snippets.

@edvakf
edvakf / heapq.go
Created October 27, 2014 01:07
heapq.go
package heapq
import "errors"
type intMaxHeap struct {
buf []int
length int
}
func (h *intMaxHeap) Cap() int {
@edvakf
edvakf / go.md
Last active June 28, 2017 02:46

golang使いまわせる処理一覧

md5

func md5hash(text []byte) string {
	h := md5.New()
	h.Write(text)
	return fmt.Sprintf("%x", h.Sum(nil))
}
// ==UserScript==
// @name AutoPagerizeSITEINFOLoader.js
// @author edvakf
// @namespace http://d.hatena.ne.jp/edvakf/
// @description Help loading AutoPagerize SITEINFO
// @license The MIT License
// @version 0.2
// @include *
// @released 2010-06-06
// @updated 2010-06-06
// ==UserScript==
// @name iframe-addressbar
// @namespace http://d.hatena.ne.jp/edvakf/
// @description Show pseudo address-bars for iframes on load and mouseover
// @include *
// ==/UserScript==
(function(win) {
if (win.top === win.self) return;
@edvakf
edvakf / log.txt
Created September 1, 2016 18:05
nvidia-docker run --rm --cap-add=SYS_PTRACE --security-opt seccomp:unconfined -it waifu2x strace th waifu2x.lua --help
This file has been truncated, but you can view the full file.
execve("/root/torch/install/bin/th", ["th", "waifu2x.lua", "--help"], [/* 14 vars */]) = 0
brk(0) = 0x7fb106960000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb105f57000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/root/torch/install/lib/tls/x86_64/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/root/torch/install/lib/tls/x86_64", 0x7ffc979386c0) = -1 ENOENT (No such file or directory)
open("/root/torch/install/lib/tls/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/root/torch/install/lib/tls", 0x7ffc979386c0) = -1 ENOENT (No such file or directory)
// ==UserScript==
// @include http://www.youtube.com/*
// ==/UserScript==
(function() {
var clip = document.getElementsByClassName('clip');
var timer;
function handleScroll() {
@edvakf
edvakf / sjis.js
Created September 25, 2011 09:14
function sjisArrayToString(ary) {
var res = [];
for (var i = 0, code; code = ary[i++]; ) {
if (single_byte.hasOwnProperty(code)) {
res.push(single_byte[code]);
} else {
code = (code << 8) + ary[i++];
if (double_byte.hasOwnProperty(code)) {
res.push(double_byte[code]);
} else {
# /etc/nginx/nginx.conf
http {
# http://www.xmisao.com/2014/05/09/fluentd-elasticsearch-nginx-log.html
log_format ltsv 'time:$time_iso8601\t'
'remote_addr:$remote_addr\t'
'request_method:$request_method\t'
'request_length:$request_length\t'
'request_uri:$request_uri\t'
'https:$https\t'
# sudo vi /etc/systemd/system/rack-test.service
[Unit]
Description=rack-test
After=syslog.target
[Service]
User=admin
Group=admin
WorkingDirectory=/home/admin/rack-test
Environment=PATH=/usr/local/bin:/usr/bin:/bin:/home/admin/local/bin
@edvakf
edvakf / A
Last active April 28, 2016 02:19
$ mkdir rack-test
$ cd rack-test
$ vi Gemfile
$ vi config.ru
$ vi unicorn_config.rb
$ bundle install --path=.bundle
$ bundle exec unicorn -c ./unicorn_config.rb