Skip to content

Instantly share code, notes, and snippets.

View shouhei's full-sized avatar

Shouhei shouhei

  • japan
View GitHub Profile
@shouhei
shouhei / git-merge-dq.rb
Last active August 27, 2015 17:54
git mergeにしっぱいしたらmp3を流す
#! /usr/bin/env ruby
# coding: utf-8
args = ""
ARGV.each do |str|
args += (" " + str)
end
`git merge #{args} 2> /dev/null`
conflicts = `git ls-files -u`
unless conflicts.empty? then
puts ""
@shouhei
shouhei / app.py
Created July 25, 2015 02:27
flask-Classyのregisterをリフレクションで一括実行する奴
import re
import inspect
import os
from flask import Flask
import controller # FlaskViewを継承したViewがあるパッケージ
# prepare application
app = Flask(__name__)
app.config.from_object('config.Config')
@shouhei
shouhei / sample.py
Last active September 26, 2019 08:19
SQLAlchemy Python3 MySQL Geometroy
# Geometory型の設定
from sqlalchemy import func
from sqlalchemy.types import UserDefinedType
class Geometory(UserDefinedType):
def get_col_spec(self):
# カラムの型
return "GEOMETRY"
def bind_expression(self, bindvalue):
@shouhei
shouhei / rand_str.py
Last active December 11, 2015 05:44
ランダム文字列python
import string
from random imoprt randint
def rand_str(length):
return ''.join(map(str,[source[randint(0, len(source) -1) ] for x in range(0,length)]))
@shouhei
shouhei / .vimrc
Last active August 29, 2015 14:25
vimを使いこなせるようになるやーつ。
inoremap <left> <esc>:q!<cr>
inoremap <right> <esc>:q!<cr>
inoremap <up> <esc>:q!<cr>
inoremap <down> <esc>:q!<cr>
inoremap <BS> <esc>:q!<cr>
inoremap <delete> <esc>:q!<cr>
nnoremap <left> <esc>:q!<cr>
nnoremap <right> <esc>:q!<cr>
nnoremap <up> <esc>:q!<cr>
nnoremap <down> <esc>:q!<cr>
@shouhei
shouhei / postcat_jp.sh
Created July 8, 2015 16:47
postfixのキューに入っているメールがISO-2022-JPだった時のコマンド
postcat -q $1 | nkf -wmQ
@shouhei
shouhei / for_sqlalchemy.py
Created July 7, 2015 10:50
既存のDBからテーブル情報を持ってくる奴
from sqlalchemy import *
db = create_engine('sqlite:///test.db')
metadata = MetaData(bind=db, reflect=True)
for tables in metadata.tables:
for row in tables.select().execute():
print(row)
@shouhei
shouhei / freeze.txt
Created July 7, 2015 04:41
for flask project
astroid==1.3.6
decorator==3.4.2
Flask==0.10.1
Flask-Classy==0.6.10
gnureadline==6.3.3
ipython==3.2.0
itsdangerous==0.24
Jinja2==2.7.3
logilab-common==0.63.2
MarkupSafe==0.23
@shouhei
shouhei / gulpfile.js
Last active August 29, 2015 14:23
composer dump-autoload を自動で実行するやーつ
var elixir = require('laravel-elixir');
var gulp = require('gulp');
// npm install --save-dev gulp-shell
var shell = require('gulp-shell');
/*
|--------------------------------------------------------------------------
| Elixir Asset Management
|--------------------------------------------------------------------------
|
@shouhei
shouhei / gem_remover.sh
Created June 20, 2015 16:36
This script remove all gems
for GEM in `gem list | awk '{print($1)}'`
do
gem uninstall $GEM
echo "gem $GEM is uninstalled"
done