Skip to content

Instantly share code, notes, and snippets.

@shnjp
shnjp / tunnel.py
Created March 5, 2011 06:29
ssh tunnel for Fabric
"""
Fabric tunneling utilities
by shn@glucose.jp
class ForwardServer and relates things are refere Robey Pointer's paramiko example.
(http://bazaar.launchpad.net/~robey/paramiko/trunk/annotate/head%3A/demos/forward.py)
usage::
with make_tunnel('user@192.168.0.2:10022') as t:
@shnjp
shnjp / fastcgi_params
Created May 1, 2018 03:40
手元用nginx `./etc/`にいれて `nginx -p `pwd` -c `pwd`/etc/nginx.conf -g "daemon off;"` で起動
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
/* eslint-disable require-jsdoc */
const SOURCE_DIR = `${__dirname}/src/js`
const DEST_DIR = `${__dirname}/static`
console.log(SOURCE_DIR)
console.log(DEST_DIR)
module.exports = {
entry: {
main: ['babel-polyfill', `${SOURCE_DIR}/main.es6`],
},
@shnjp
shnjp / gist:8806f171ab8e96684221b2bd9a21beb8
Created May 14, 2017 08:37
WeakSetの使いみち...
class RefCounter {
constructor() {
this.counter = 0
this.decrementers = new WeakSet()
}
increment() {
this.counter += 1
const decrementer = () => {
@shnjp
shnjp / git-remaster-pr
Last active February 20, 2017 09:30
remoteブランチをmasterでrebaseしてpushしなおす糞コマンド
#!/bin/sh
set -e
source "$(git --exec-path)/git-sh-setup"
USAGE="<remote> <branch>"
function _remaster_pr() {
local readonly remote=$1
local readonly branch=$2
@shnjp
shnjp / changed to dontwait
Last active February 14, 2017 04:32
テスト用のサンプル
def on_message(self, *args):
print('{:.3f}: on_message'.format(elapsed_time()))
try:
message = self._socket.recv(nnpy.DONTWAIT)
print('{:.3f}: subscribe> {!r}'.format(elapsed_time(), message))
except nnpy.NNError as exc:
if exc.error_no == nnpy.EAGAIN:
print('{:.3f}: subscribe> got EAGAIN. skip...'.format(elapsed_time()))
else:
raise
(.env) warmonger:shn% python lstm_test.py test --saved-model ./epochs_1000/epochs/014/ (master@nico)-[.]
load words
112764 words
load the model
load the optimizer
やりと一家助や奇怪暴自行動臣を受けながら、やっぱり、それっき女の事にやってしまったにちがいないのです
彼の幻暴力理もなければ、こんなものですわ
大声あげるようですね?」
僕たちの辺為に就いては僕と違うのです
浅田の霊濟まわりの奴リユの群節で、鳥へ演不文記にあきらめに珍野暮へ數を働住んでゐるのだ
@shnjp
shnjp / yorosikuimage.py
Created December 10, 2013 08:22
iOS用の画像がどかっと渡された時に、いっぱつでImage.xcassetsを作ってくれるスクリプト
#!/usr/local/bin/python3
# -*- coding:utf-8 -*-
"""
iOS用の画像がどかっと渡された時に、いっぱつでImage.xcassetsを作ってくれるスクリプ
python3 yorosikuimage [画像のディレクトリ] [Image.xcassetsのパス]
"""
from PIL import Image
import os
import json
class Fluent::UDPInput < Fluent::Input
Fluent::Plugin.register_input('udp_formatted', self)
config_param :port, :integer, :default => 5050
config_param :bind, :string, :default => '127.0.0.1'
config_param :tag, :string
def configure(conf)
super
"""
uwsgiのエントリポイントの中でコレを実行すれば、ファイルに変更があった時にリロードする。
"""
import uwsgi
from uwsgidecorators import timer
from werkzeug.serving import _iter_module_files, _log
import os
# TODO: uwsgi.optsから読み込む