Skip to content

Instantly share code, notes, and snippets.

View yuuichi-fujioka's full-sized avatar

yuuichi fujioka yuuichi-fujioka

View GitHub Profile
@yuuichi-fujioka
yuuichi-fujioka / stack.sh reclone(localrc)
Created April 15, 2013 02:42
devstackで常に最新ソース取得
RECLONE=yes
@yuuichi-fujioka
yuuichi-fujioka / grep examples.sh
Created April 15, 2013 03:13
grepいろいろ
# or
grep -e hogehoge -e fugafuga
# not
grep -v hogehoge
# ext
grep hoge --include="*.conf"
@yuuichi-fujioka
yuuichi-fujioka / string examples.py
Last active December 16, 2015 05:39
python 文字列のいろいろ
# combine
'foo' + 'bar' # foobar
'foo' 'bar' # foobar
# split
'hello world'.split() # ['hello', 'world']
'|foo|bar|'.split('|') # ['', 'foo', 'bar', '']
'alice, bravo, scot, tiger'.split(',', 2) # ['alice, 'bravo', 'scot, tiger']
# ゼロ埋め
@yuuichi-fujioka
yuuichi-fujioka / loop examples.py
Created April 15, 2013 06:21
ループのサンプルいろいろ
# 単純なループ
for i in range(5):
print i
'''
0
1
2
3
4
@yuuichi-fujioka
yuuichi-fujioka / reflection examples.py
Last active December 16, 2015 05:39
クラスからメソッド取得
class A:
def aaa(self):
''' instance method'''
print 'hello world'
@classmethod
def bbb():
'''class method'''
print 'this is pen'
import httplib
def http_req(host, port = 80, method = 'GET', uri = '', headers = {}, body=''):
con = httplib.HTTPConnection(host, port)
con.request(method, uri, body, headers)
resp = con.getresponse()
import argparse
def exist_user(string):
exist_users = ['taro','jiro','saburo','ichi','ni','san']
if string not in exist_users:
raise argparse.ArgumentTypeError("%s is not exist user"%(string))
return string
parser = argparse.ArgumentParser(prog='test command', description='this is description text.')
@yuuichi-fujioka
yuuichi-fujioka / function pointer.cpp
Created April 18, 2013 00:54
function pointer example
#include <stdio.h>
typedef void (*FUNC)(const char*);
void printmsg(const char* msg) {
printf("print message is '%s'\n", msg);
}
int main(int argc, char** argv) {
FUNC f = &printmsg;
@yuuichi-fujioka
yuuichi-fujioka / subdir.mk
Created April 18, 2013 11:46
サブディレクトリにソースとヘッダを置いている場合のMakefile
DESTDIR = bin
PROGRAM = $(DESTDIR)/test
SRCS = main.cpp sub.cpp
OBJS = $(SRCS:.cpp=.o)
DEPS = $(SRCS:.cpp=.d)
VPATH = src
CXXFLAGS = -I include/
git submodule add git://github.com/submodule/url.git submodule