Skip to content

Instantly share code, notes, and snippets.

View aflc's full-sized avatar

Hiroyuki Tanaka aflc

  • Kanagawa, Japan
View GitHub Profile
@aflc
aflc / increase_memory_usage.py
Last active April 20, 2019 22:29
Linux+glibcで何故かメモリ消費が増える現象(Linux+glib)
import copy
import os
import random
import subprocess
import tracemalloc
pid = os.getpid()
buffer = b"0" * 100000000
@aflc
aflc / edit_distance.cpp
Last active May 4, 2019 18:38
fast implementation of the edit distance (levenshtein distance).
// Copyright (c) 2013 Hiroyuki Tanaka
// Released under the MIT license
#include <stdint.h>
#include <cstdlib>
#include <cstring>
#include <string>
#include <map>
#include <vector>
#include <iostream>
@aflc
aflc / file0.txt
Created May 17, 2013 13:02
UTCからローカル時間へのお手軽な変換 ref: http://qiita.com/items/5fcee53316fe49b6c550
import datetime
import calendar
import time
# utctime -> localtime
utcnow = datetime.datetime.utcnow()
local = datetime.datetime.fromtimestamp(calendar.timegm(utcnow.timetuple()))
# localtime -> utctime
localnow = datetime.datetime.now()
@aflc
aflc / file1.sh
Created January 26, 2013 15:10
SublimeText2とSublimeLinter - Python3の構文チェック - ref: http://qiita.com/items/f1bbd2917025494d021f
cd ~/Library/Application Support/Sublime Text 2/Packages/Python
cp Python.tmLanguage Python3.tmLanguage
@aflc
aflc / file0.txt
Created December 1, 2012 11:04
Pythonの例外処理を少し便利に ref: http://qiita.com/items/c39b462376a48eae3646
import functools
class MyException(Exception):
def __init__(self, original, *args, **kwargs):
super(MyException, self).__init__(str(original), *args, **kwargs)
self.original = original
def raise_as(except_classes, target_class):
def wrapper(f):
@functools.wraps(f)
@aflc
aflc / file0.txt
Created November 26, 2012 10:15
AdBlockを入れるとQiitaにログインできない件 ref: http://qiita.com/items/2243dfe2fb2b36bbc154
GET http://cdn.optimizely.com/js/52738645.js qiita.com:18
GET http://cdn.mxpnl.com/libs/mixpanel-2.1.min.js qiita.com:30
(anonymous function) qiita.com:30
(anonymous function) qiita.com:31
Port error: Could not establish connection. Receiving end does not exist. miscellaneous_bindings:235
chromeHidden.Port.dispatchOnDisconnect miscellaneous_bindings:235
Port error: Could not establish connection. Receiving end does not exist. miscellaneous_bindings:235
chromeHidden.Port.dispatchOnDisconnect miscellaneous_bindings:235
Unsafe JavaScript attempt to access frame with URL http://platform.twitter.com/widgets/tweet_button.1352365724.html#_=1353924677122&count=horizontal&id=twitter-widget-0&lang=ja&original_referer=http%3A%2F%2Fqiita.com%2F&size=m&text=Qiita%5B%E3%82%AD%E3%83%BC%E3%82%BF%5D%20-%20%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9E%E3%81%AE%E6%8A%80%E8%A1%93%E6%83%85%E5%A0%B1%E5%85%B1%E6%9C%89%E3%82%B5%E3%83%BC%E3%83%93%E3%82%B9&url=http%3A%2F%2Fqiita.com%2F&via=Qiita_jp from frame with URL http://qiita.c
@aflc
aflc / file0.rb
Created November 23, 2012 11:32
Ruby1.9のブロックについて勉強した ref: http://qiita.com/items/413f710b126a869cb797
(1..3).map {|x| x * 2} # => [2, 4, 6]
@aflc
aflc / index.html
Created December 3, 2011 08:56
jQuery tutorial
<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("a").click(function() {
alert("Hello world");
});
});
</script>