This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
import re | |
org_str = '2ABACBDEDFDFDFDCBACDAFB2' | |
candidates = ['0', '3', '4', '5', '6', '7', '8', '9'] | |
operators = ['+', '-', '*', '/', '='] | |
candidates.extend(operators) | |
simple_op_check = re.compile(r'[*+-/=][*+-/=0]') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash - | |
new_filename=`date +\%Y\%m\%d\%H\%M\%S`.jpg | |
old_filename=`ls *.jpg | tail -n 1` | |
old_md5=`md5sum $old_filename | cut -d ' ' -f 1` | |
DISPLAY=":1.0" import -w root $new_filename | |
new_md5=`md5sum $new_filename | cut -d ' ' -f 1` | |
if [ $old_md5 = $new_md5 ]; then | |
rm $new_filename | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from lxml import etree | |
from itertools import count, izip | |
if len(sys.argv) < 2: | |
print 'Usage: %s filename' % ( sys.argv[0] ) | |
exit() | |
doc = etree.parse(sys.argv[1]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#define MAX 1000000 | |
int is_prime(int n){ | |
for(int i = 6; (i-1) * (i-1) <= n; i+=6){ | |
if( n % (i-1) == 0 || n %(i+1) == 0) | |
return 0; | |
} | |
return 1; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def gen_fizz_buzz(n): | |
for i in xrange(1,n): | |
str = "" | |
if i % 3 == 0: | |
str += "Fizz" | |
if i % 5 == 0: | |
str += "Buzz" | |
yield str if str else i | |
for i in gen_fizz_buzz(100): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Initialize rbenv. | |
# "eval rbenv init -" is much heavy. use cached script. | |
if [ -n "$(printenv TMUX)" ]; then | |
source $ZSHHOME/rbenv.init-no-rehash | |
else | |
source $ZSHHOME/rbenv.init | |
fi | |
check_rbenv_init() { | |
rbenv init - | diff - $ZSHHOME/rbenv.init |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(){ | |
printf("Hello World!"); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int a[10]; //配列には適切な値が入っていると仮定する | |
int tmp; // 一時的に利用する変数.(temporaryの略でtmp) | |
// a[0]とa[3]を交換する. | |
tmp = a[0] | |
a[0] = a[3]; //a[0] = tmpでもよい | |
a[3] = tmp; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(){ | |
int n; | |
printf("配列のサイズを入力してください"); | |
scanf("%d", &n); | |
int array[n]; | |
int i; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Checking whther zplug is installed | |
if [[ ! -d ~/.zplug ]]; then | |
git clone https://github.com/zplug/zplug ~/.zplug | |
fi | |
cat <<EOT > ~/.zshrc | |
# Essential | |
source ~/.zplug/init.zsh | |
# zplug check returns true if all packages are installed |
OlderNewer