Skip to content

Instantly share code, notes, and snippets.

View uiur's full-sized avatar

Kazato Sugimoto uiur

View GitHub Profile
@uiur
uiur / 0.js
Created September 22, 2015 12:45
aws lambda mp4 -> gif
var aws = require('aws-sdk')
var s3 = new aws.S3()
var exec = require('child_process').exec
var fs = require('fs')
exports.handler = function (event, context) {
console.log(JSON.stringify(event, null, 2))
var bucket = event.Records[0].s3.bucket.name;
var key = decodeURIComponent(event.Records[0].s3.object.key.replace(/\+/g, " ")) ;
@uiur
uiur / private.xml
Created November 2, 2015 08:50
full gyazo
<?xml version="1.0"?>
<root>
<vkopenurldef>
<name>KeyCode::VK_OPEN_URL_GYAZO</name>
<url type="shell">
<![CDATA[ /usr/sbin/screencapture /tmp/gyazo-fullscreen.png; /Applications/Gyazo.app/Contents/MacOS/Gyazo /tmp/gyazo-fullscreen.png ]]>
</url>
</vkopenurldef>
<list>
@uiur
uiur / topic.py
Created November 7, 2015 06:02
lda livedoor news
# coding: utf-8
import glob
import MeCab
import gensim
from gensim import corpora, matutils
import numpy as np
import codecs
import sys
sys.stdout = codecs.getwriter('utf_8')(sys.stdout)
@uiur
uiur / 0.rb
Created December 11, 2015 09:11
[[k, v] ...] -> tsv and copy
`echo "#{CSV.generate(col_sep: "\t") {|r| a.to_a[1..-1].each{|ar| r << ar} }}" | pbcopy`
@uiur
uiur / gist:3e05024bc7fbed09a9fa
Created December 16, 2015 08:08
apple script file path
set filePath to ""
tell application "QuickTime Player"
try
if file path of front document is not equal to missing value then
set filePath to file path of front document
end if
end try
try
if path of front document is not equal to missing value then
set filePath to path of front document
@uiur
uiur / 0.sh
Last active February 17, 2016 10:58
show ruby ast
cat app/models/comment.rb | ruby -r pp -r ripper -e 'pp Ripper.sexp(ARGF.read)'
@uiur
uiur / 0.go
Created April 8, 2016 01:44
go/scanner + goyacc sample
%{
package main
import (
"fmt"
"go/scanner"
"os"
"go/token"
)
def pi(n):
half_pi = 0
for k in range(n + 1):
m = 1.0
for i in range(1, k + 1):
m *= float(2 * i - 1) / (2 * i)
half_pi += m / (2 * k + 1)
return 2 * half_pi
@uiur
uiur / 0.sh
Created June 16, 2016 14:37
edit pdf using pdftk
pdftk a.pdf dump_data_utf8 output data.txt
vi data.txt
pdftk a.pdf update_info_utf8 data.txt output b.pdf
@uiur
uiur / mser.py
Created July 4, 2016 10:14
extract regions and save by MSER
import sys
import numpy as np
import cv2
def extract_region(img, region):
top_left = np.min(region, axis=0)
bottom_right = np.max(region, axis=0)
margin = 2
region_of_image = img.copy()[top_left[1]-margin:bottom_right[1]+margin, top_left[0]-margin:bottom_right[0]+margin]