Skip to content

Instantly share code, notes, and snippets.

View hhatto's full-sized avatar
⛰️
enjoy

Hideo Hattori hhatto

⛰️
enjoy
View GitHub Profile
@hhatto
hhatto / gist:ea6ce22403cf24e160d7
Created June 24, 2014 14:52
benchmark with scale image
## benchmarker: release 3.0.1 (for python)
## python platform: linux2 [GCC 4.8.2]
## python version: 2.7.6
## python executable: /usr/bin/python
## user sys total real
kaa.imlib2 0.8500 0.1300 0.9800 0.9883
PIL 8.6100 0.9400 9.5500 9.5611
PIL(fast) 1.0900 0.4500 1.5400 1.5460
pgmagick(blob-read) 0.2300 0.0200 0.2500 0.2500
@hhatto
hhatto / gist:423be867f462823ffd41
Created June 24, 2014 16:55
install libvips on Ubuntu14.04
- on Ubuntu 14.04
- apt-get install gtk-doc-tools swig gobject-introspection libgsf-1-dev ¥
libopenslide-dev libwebp-dev libcfitsio3-dev libmatio-dev libopenexr-dev ¥
libfftw3-dev libmagickcore-dev liborc-0.4-dev
- ./configure && make
@hhatto
hhatto / smartcropgo.go
Last active August 29, 2015 14:05
smartcrop.go cli
package main
import (
"fmt"
"image"
"image/jpeg"
_ "image/png"
"log"
"os"
@hhatto
hhatto / gist:a959428f8e8f59672bc2
Created February 25, 2015 04:37
python pow bench
===== =====
(slow) 0.481754[sec]
math.pow(13 * 0.3, 2)
math.pow(2 * 1, 0.5)
math.pow(0.2 * 0.2, 0.5)
(fast) 0.026431[sec]
(13 * 0.3) ** 2
(2 * 1) ** 0.5
@hhatto
hhatto / gist:604e066cbb6cbe26bc27
Created March 3, 2015 03:13
python "not (x in list)" vs "x not in list"
import slowfast
N = 5000000
setup = """\
t = 11
tt = [22, 11, 55]
"""
one = """\
if not (t in tt):
@hhatto
hhatto / reverse-reverse-proxy.go
Last active August 29, 2015 14:17
reverse-reverse-proxy, that image rotate proxy.
//
// ## reverse-reverse-proxy
// This is reverse(rotate) image proxy server.
// This is my toy Go project:-)
//
// ```
// +-----------+ request +--------------+ request +-------------+
// | client |----------->| rrp |----------->| target host |
// | (browser) |<-----------| |<-----------| |
// +-----------+ response +--------------+ response +-------------+
@hhatto
hhatto / gen_polyline.cpp
Created April 3, 2015 11:32
generate image for stroke width 2.0 and 3.0 on C++
#include <stdio.h>
#include <Magick++.h>
using namespace Magick;
void gen_line_png(float line_width)
{
Image image = Image(Geometry(200, 200), Color("white"));
char filename[50];
CoordinateList coords;
@hhatto
hhatto / gen_polyline.py
Created April 30, 2015 01:37
generate image for stroke width 2.0 and 3.0 on Python (pgmagick)
import pgmagick as pg
def gen_line_png(line_width):
img = pg.Image(pg.Geometry(200, 200), "white")
img.type(pg.ImageType.TrueColorMatteType)
coords = pg.CoordinateList()
drawables = pg.DrawableList()
blankColor = pg.Color()
package main
import (
"flag"
"fmt"
"os"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/service/s3"
@hhatto
hhatto / grin_rev80_force-word-match.patch
Created September 18, 2010 08:17
patch of grin force word regex match
Index: grin.py
===================================================================
--- grin.py (revision 80)
+++ grin.py (working copy)
@@ -762,6 +762,8 @@
help="show program's version number and exit")
parser.add_argument('-i', '--ignore-case', action='append_const',
dest='re_flags', const=re.I, default=[], help="ignore case in the regex")
+ parser.add_argument('-w', '--word-regexp', action='store_true', default=False,
+ dest='is_matchword', help="force regex to match only whole words")