Skip to content

Instantly share code, notes, and snippets.

View noblejasper's full-sized avatar
🐇
CTO風

noblejasper noblejasper

🐇
CTO風
View GitHub Profile
@noblejasper
noblejasper / slice_or_pop.py
Created May 10, 2014 10:25
list[-100:] if len(list) > 100 と list.pop(0) while len(list) > 100 はどっちが早いの?
import time
nums = range(10000)
limit_num = 100
def check_1():
stime = time.time()
tmp_nums = []
for i in nums:
tmp_nums.append(i)
@noblejasper
noblejasper / mongodb
Created May 9, 2014 03:36
init.d/mongodb
#!/bin/sh
#
# init.d script with LSB support.
#
# Copyright (c) 2007 Javier Fernandez-Sanguino <jfs@debian.org>
#
# This is free software; you may redistribute it and/or modify
# it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2,
# or (at your option) any later version.
@noblejasper
noblejasper / config_manager.py
Created April 28, 2014 13:14
fabricとConfigParserの相性がとてもいい件
# coding: utf-8
import os
from fabric.api import prompt,env,abort
from fabric.colors import *
import ConfigParser
class LocalConfigManager(object):
CONFIG_FILENAME = ".nobjas_cnf"
# TODO: typeがないから今全部str
@noblejasper
noblejasper / fabfile.py
Created April 28, 2014 13:13
LocalConfigManagerのサンプル
# coding: utf-8
from fabric.colors import *
from config_manager import LocalConfigManager
def build_iphone():
local_config = LocalConfigManager()
print blue(local_config.get("test_nobjas_project_path"))
@noblejasper
noblejasper / fix_crlf_utf8_bom.sh
Last active August 29, 2015 13:55
カレントディレクトリ以下の *.cs ファイルをCRLF改行&BOM付きUTF8に変換するシェルスクリプト
#!/bin/sh
## https://gist.github.com/noblejasper/8701401
[ -r ~/bin/init_sh.sh ] && . ~/bin/init_sh.sh
## FYI http://anchan828.tumblr.com/post/20713455281/unity-mono-mac-windows
filepath=`pwd`
colorecho "Search "${filepath} blue
for f in `find ${filepath} -name '*.cs'`
@noblejasper
noblejasper / init_sh.sh
Last active August 29, 2015 13:55
シェルスクリプト書くときに頭で読み込む標準セット的な(.bashrcに書けよ的な)スクリプト
#!/bin/sh
COLOREND="\033[0m"
function blackecho() { echo "\033[30m"${1}${COLOREND}; }
function redecho() { echo "\033[31m"${1}${COLOREND}; }
function greenecho() { echo "\033[32m"${1}${COLOREND}; }
function yellowecho() { echo "\033[33m"${1}${COLOREND}; }
function blueecho() { echo "\033[34m"${1}${COLOREND}; }
function purpleecho() { echo "\033[35m"${1}${COLOREND}; }
function cyanecho() { echo "\033[36m"${1}${COLOREND}; }
function lgrayecho() { echo "\033[1;30m"${1}${COLOREND}; }
@noblejasper
noblejasper / file0.sh
Created November 1, 2013 03:06
MarvericksにしてPILのインストールがコケる件 ref: http://qiita.com/noblejasper/items/797849a6c3c603016166
$ sudo pip install PIL
@noblejasper
noblejasper / gist:3383711
Created August 18, 2012 00:53
Google shortener API を python から叩く
def get_qrcode_path(self):
import urllib2, json
from StringIO import StringIO
base_url = 'http://google.com'
api_key = 'hoge'
request_url = "https://www.googleapis.com/urlshortener/v1/url?key=" + api_key
headers = {
'Content-Type' : 'application/json',
}
values = json.dumps({'longUrl' : base_url})
@noblejasper
noblejasper / python_boto_to_amazon_dynamodb.py
Created April 20, 2012 10:26
pythonからbotoを使ってAmazonDynamoDBを叩いてみた。
>>> import boto.dynamodb
>>> boto.dynamodb.regions()
[RegionInfo:us-east-1, RegionInfo:ap-northeast-1, RegionInfo:eu-west-1]
>>> boto.dynamodb.regions()[1]
RegionInfo:ap-northeast-1
>>> type(boto.dynamodb.regions()[1])
<class 'boto.regioninfo.RegionInfo'>
>>> region_info = boto.dynamodb.regions()[1]
>>> conn = region_info.connect(aws_access_key_id='', aws_secret_access_key='')
>>> conn
<?php
$word = 'そうだ京都へ行こう'. "\n";
$word = strtolower($word);
$word = mb_convert_encoding($word, "EUC-jp", "UTF-8");
$descriptorspec = array(
0 => array("pipe", "r"),
1 => array("pipe", "w"),
);