Skip to content

Instantly share code, notes, and snippets.

@nobonobo
nobonobo / broadway_test.sh
Last active December 16, 2015 01:09
GTK3アプリをブラウザの中で動かそう! 今のubuntu系ならbroadway(GTKアプリのHTML5バックエンド)のお試しが簡単にできちゃうね!
#!/bin/sh
# for ubuntu 12.xx
sudo add-apt-repository ppa:malizor/gtk-broadway
sudo apt-get update
sudo apt-get upgrade
GDK_BACKEND=broadway UBUNTU_MENUPROXY= LIBOVERLAY_SCROLLBAR=0 python sample.py &
sensible-browser http://localhost:8080/
@nobonobo
nobonobo / Py2AppTips.rst
Last active June 21, 2016 02:54
メモ:py2appのコツ

Py2AppのTips

  • 直接import記述していないパッケージが取り込まれない場合がある。
  • 動作するときのsys.modulesと動作しない時のsys.modulesをよく見比べましょう。
  • pngだろうがなんだろうが、「tiff2icns」でicnsファイルは作れる。
  • OS-X内蔵Pythonはアプリ内に複製できない(py2appの仕様)ので、別途Pythonをインストールする必要がある。 (portsサンプル多いが、brewでもできたー。)

for PyQt or PySide

@nobonobo
nobonobo / sample.py
Created June 13, 2013 09:21
subprocessで子プロセス起こすとき、「, close_fds=True, preexec_fn=os.setsid」つけるとプロセスグループが独立するみたい。
# encoding: utf-8
import os
import signal
from subprocess import Popen
cmd = ['python', '-c', 'import time; time.sleep(1); print "Hello."']
if 0:
proc = Popen(cmd, close_fds=True, preexec_fn=os.setsid)
@nobonobo
nobonobo / pycap.py
Created July 27, 2013 12:29
pythonでpcapファイルを書き出すのをやってみた。意外と簡単だった。
#!/usr/bin/env python
# encoding: utf-8
import os
import time
import struct
FileHeader = struct.Struct(format="<LHHlLll")
PacketHeader = struct.Struct(format="<LLLL")
@nobonobo
nobonobo / install.sh
Last active December 20, 2015 10:49
unqliteのPythonバインディングctypes版を作ってみた。 libunqlite.soが検索可能な状態(インストール済み)であることが必要です。
#!/usr/bin/env bash
# Before executing it, you must download UnQLite source code (http://www.unqlite.org/downloads.html)
# unzip all the files and execute this script inside the unzipped folder. For example:
# mkdir /tmp/unqlite; cd /tmp/unqlite; unzip ~/Downloads/unqlite-db-116.zip
gcc -DUNQLITE_ENABLE_THREADS=1 -Wall -fPIC -c *.c
gcc -shared -Wl,-soname,libunqlite.so.1 -o libunqlite.so.1.0 *.o
sudo cp `pwd`/libunqlite.so.1.0 /usr/local/lib/
sudo cp `pwd`/unqlite.h /usr/local/include/
sudo ln -sf /usr/local/lib/libunqlite.so.1.0 /usr/local/lib/libunqlite.so.1
@nobonobo
nobonobo / .bashrc
Created August 24, 2013 11:09
OS-XにてOpenWRTのビルドメモ
PATH=/usr/local/opt/coreutils/libexec/gnubin:$PATH
@nobonobo
nobonobo / eapol_test.build.sh
Created September 4, 2013 09:31
eapol_testツールのビルドとインストール
sudo apt-get install --yes libnl-dev
wget http://hostap.epitest.fi/releases/wpa_supplicant-2.0.tar.gz
cd wpa_supplicant-2.0/wpa_supplicant
cat defconfig | sed -e "s/#CONFIG_EAPOL_TEST=y/CONFIG_EAPOL_TEST=y/" > .config
make eapol_test
sudo cp eapol_test /usr/local/bin/
@nobonobo
nobonobo / gist:7596271
Created November 22, 2013 07:39
SymPyで綺麗な表示

SymPyで綺麗な表示

ubuntuの場合、 $ sudo apt-get install python-sympy ipython-qtconsole python-matplotlib $ ipython qtconsole

from sympy import *
@nobonobo
nobonobo / Makefile
Created January 20, 2014 00:21
dockerで開発環境メンテ用Makefile
# depends: docker, fabric
.PHONY: help build run start commit stop stop-all ssh shell clean
TAG=nobonobo/ubuntu
help:
@echo "USAGE:"
@echo " make build ... image build"
@echo " make run ... container run"
@nobonobo
nobonobo / kvs_test.go
Last active August 29, 2015 13:56
golang KVS Insertion Benchmark
package main
import (
"database/sql"
"encoding/gob"
"fmt"
_ "github.com/mattn/go-sqlite3"
"github.com/nobonobo/unqlitego"
"github.com/peterbourgon/diskv"
"github.com/steveyen/gkvlite"