Skip to content

Instantly share code, notes, and snippets.

@s-shin
s-shin / detect-square-markers.py
Last active January 11, 2018 13:58
A tutrial in which square markers in an image are detected with OpenCV 2.4 in Python 2.7.
# -*- coding: utf-8 -*-
"""Tutrial: Detect square markers with OpenCV 2.4 in Python 2.7.
(C) 2013 Shintaro Seki
MIT License
The marker used in this program can be generated by the following script.
cv2.imwrite("marker.png", cv2.resize(np.array([
[0, 0, 0, 0],
@s-shin
s-shin / io
Last active December 22, 2017 15:15
#!/bin/bash
set -eu
: ${IO_RUNNING_FILE:=.io_running}
: ${IO_STDIN_FILE:=.io_stdin}
: ${IO_STDOUT_FILE:=.io_stdout}
io.help() {
cat <<EOT
Usage: io <command> [<args>]
@s-shin
s-shin / amazon-wishlist-discount-checker.js
Last active November 28, 2017 14:02
Copy, paste and run in dev console.
(function() {
const THRESHOLD = 400;
function isEndOfList() {
return document.querySelector("#endOfListMarker") !== null;
}
function scroll(top) {
document.scrollingElement.scrollTop = top;
package main
import (
"bufio"
"bytes"
"compress/gzip"
"encoding/binary"
"fmt"
"io"
"log"
package main
import (
"bufio"
"bytes"
"encoding/binary"
"fmt"
"io"
"log"
"net"
package main
import (
"compress/gzip"
"io"
"log"
"net"
)
type hello struct {
@s-shin
s-shin / yml2sh
Created May 18, 2017 06:52
Example: `echo "$(eval "$(echo "{ foo: { bar: [fizz, buzz] } }" | yml2sh)"; echo "$(foo.bar)")"` => fizz\tbuzz
#!/usr/bin/env ruby
require 'yaml'
def puts_sh_kv(key, value)
escaped_value = value.gsub(/"/, '\\"')
puts %(function #{key}() { echo "#{escaped_value}"; })
end
def print_sh(data, key_prefix: '')
data.each do |key, value|
#!/usr/bin/env ruby
require 'optparse'
# @param bytes [String] Byte sequence as needle.
# @param io [IO] IO object as haystack.
# @param max [Integer, nil] Stop search when `max` number of `bytes` are found.
# @return [Array<Integer>]
def search(bytes, io, max = nil)
buf_size = bytes.size * 10
buf = ''
@s-shin
s-shin / a.cpp
Last active April 24, 2017 04:09
#include "foo.h"
int get_foo_a() { return foo; }
package main
import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/http/httptest"