Skip to content

Instantly share code, notes, and snippets.

View sumomoneko's full-sized avatar

sumomoneko

View GitHub Profile
@sumomoneko
sumomoneko / getColor.py
Last active January 13, 2018 12:07
画像からいくつかのピクセルを抜き取り平均の色を得る
def getColor():
r = requests.get("http://example.jp/live.jpg")
if r.ok:
image = PIL.Image.open(io.BytesIO(r.content))
# 座標 x,y = (10,10), (100, 10), ..., (600, 20) の平均 r,g,b を得る
return map(statistics.mean,
zip(*(image.getpixel(pos) for pos in itertools.product((10, 100, 200, 300, 400, 500, 600), (10, 20)))))
@sumomoneko
sumomoneko / coroutine.hpp
Created January 18, 2018 05:04
stackless coroutine
//
// coroutine.hpp
// ~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
@sumomoneko
sumomoneko / bt.py
Last active February 22, 2018 03:53
backtrace with gdb-python-pyelftools
#!/bin/env python3
import posixpath
from elftools.dwarf.descriptions import describe_form_class
from elftools.elf.elffile import ELFFile
from elftools.dwarf.compileunit import CompileUnit
from elftools.dwarf.die import DIE
from elftools.dwarf.lineprogram import (LineProgram, LineProgramEntry)
from elftools.dwarf.dwarfinfo import DWARFInfo
from elftools.dwarf.callframe import (RegisterRule, CFARule)
;; from: uim/scm/elatin-rules.scm
;;
;; Copyright (c) 2003-2013 uim Project https://github.com/uim/uim
;;
;; All rights reserved.
;; The translation tables in this file were derived from the
;; emacs-lisp source files latin-pre.el, latin-post.el, latin-alt.el,
;; and latin-ltx.el, included in GNU Emacs. The following is the
;; original copyright notice therein.