Skip to content

Instantly share code, notes, and snippets.

@shnjp
shnjp / fastcgi_params
Created May 1, 2018
手元用nginx `./etc/`にいれて `nginx -p `pwd` -c `pwd`/etc/nginx.conf -g "daemon off;"` で起動
View fastcgi_params
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;
View web pack.config.bable.js
/* 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`],
},
View gist:8806f171ab8e96684221b2bd9a21beb8
class RefCounter {
constructor() {
this.counter = 0
this.decrementers = new WeakSet()
}
increment() {
this.counter += 1
const decrementer = () => {
@shnjp
shnjp / git-remaster-pr
Last active Feb 20, 2017
remoteブランチをmasterでrebaseしてpushしなおす糞コマンド
View git-remaster-pr
#!/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 Feb 14, 2017
テスト用のサンプル
View changed to dontwait
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
View deep daze
(.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
やりと一家助や奇怪暴自行動臣を受けながら、やっぱり、それっき女の事にやってしまったにちがいないのです
彼の幻暴力理もなければ、こんなものですわ
大声あげるようですね?」
僕たちの辺為に就いては僕と違うのです
浅田の霊濟まわりの奴リユの群節で、鳥へ演不文記にあきらめに珍野暮へ數を働住んでゐるのだ
View numpytest.py
import timeit
print 'pure sum', timeit.timeit('sum([1] * 10000)', number=100)
print 'numpy sum', timeit.timeit('numpy.sum([1] * 10000)', 'import numpy', number=100)
print 'pure sum', timeit.timeit('sum(x)', setup='x = [1] * 10000', number=100)
print 'numpy sum 1', timeit.timeit('numpy.sum(y)', 'import numpy; y = [1] * 10000', number=100)
print 'numpy sum 2', timeit.timeit('numpy.sum(z)', 'import numpy; z = numpy.array([1] * 10000)', number=100)
print 'numpy sum 3', timeit.timeit('numpy.sum(numpy.array(y))', 'import numpy; y = [1] * 10000', number=100)
@shnjp
shnjp / flask_test.py
Created Oct 19, 2015
flask's url_for with _scheme overwrite app's default scheme bug
View flask_test.py
# -*- coding: utf-8 -*_
from flask import Flask, url_for
def test():
# Building test app.
app = Flask('test')
app.config['SERVER_NAME'] = 'localhost'
@app.route('/')
View get_s3_object.sh
#!/bin/bash
S3_BUCKET=$1
S3_OBJECT=$2
S3CFG=S3-CONFIG-FILE
S3CMD="s3cmd -c $S3CFG"
TIMESTAMP=$((`date +%s` + 600))
can_string="GET\n\n\n${TIMESTAMP}\n/${S3_BUCKET}/${S3_OBJECT}"
# generate the signature
@shnjp
shnjp / yorosikuimage.py
Created Dec 10, 2013
iOS用の画像がどかっと渡された時に、いっぱつでImage.xcassetsを作ってくれるスクリプト
View yorosikuimage.py
#!/usr/local/bin/python3
# -*- coding:utf-8 -*-
"""
iOS用の画像がどかっと渡された時に、いっぱつでImage.xcassetsを作ってくれるスクリプ
python3 yorosikuimage [画像のディレクトリ] [Image.xcassetsのパス]
"""
from PIL import Image
import os
import json
You can’t perform that action at this time.