Skip to content

Instantly share code, notes, and snippets.

View yuchan's full-sized avatar

Yusuke Ohashi yuchan

View GitHub Profile
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import urllib
import sys
import os
import subprocess
import re
seed = sys.argv
#! /usr/bin/env python
import sys
from datetime import datetime
arguments = sys.argv
arg_date = arguments[1]
bd = datetime.strptime(arg_date, "%Y%m%d")
now = datetime.now()
#!/bin/bash
#today's coding fragment
string="path-to-something:$PATH"
if [[ $PATH =~ "path-to-something" ]]; then
echo "\$PATH contains it"
fi
#!/bin/bash
#Created and tested on Mac OS X only.
brew tap phinze/cask
brew install brew-cask
brew cask install basictex
if [[ $PATH =~ "texbin" ]]; then
@yuchan
yuchan / nl.py
Created April 29, 2014 13:41
python implementation of nl command(no options).
#! /usr/bin/env python
import sys
DEFAULT_INDENT = 4
def main():
argc = len(sys.argv)
f = None # File IO
@yuchan
yuchan / createram.bash
Last active August 29, 2015 14:00
Commands for Ramdisk for Mac
#! /bin/bash
# create 512MB RamDisk
# (0.512(GB) * (1024^3)) / 512
rm -rf ~/Library/Caches
diskutil erasevolume HFS+ 'RamDisk' `hdiutil attach -nomount ram://1073741`
ln -s /Volumes/Ramdisk ~/Library/Caches
@yuchan
yuchan / fizzbuzz.py
Last active August 29, 2015 14:00
fizzbuzz
#! /usr/bin/env python
def fb(n):
dic = {}
for num in range(1, n+1):
dic[num] = ""
for num in range(3, n+1)[::3]:
dic[num] += "Fizz"
for num in range(5, n+1)[::5]:
dic[num] += "Buzz"
@yuchan
yuchan / vagrant-provision.bash
Last active August 29, 2015 14:00
For Ubuntu 12.04 LTS.
#! /bin/bash
# Ubuntu Provisioning Script
# basic packages
sudo apt-get update
sudo apt-get install -y openssh-server git language-pack-ja libssl-dev libsqlite3-dev build-essential nginx python-software-properties memcached
# install mysql
# warning: change the password 'root' to something else.
@yuchan
yuchan / iOS_machine_name.m
Last active January 3, 2016 23:19
snippet for retreiving iOS machine name.
// This is pseudo code.
size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char *name = malloc(size);
sysctlbyname("hw.machine", name, &size, NULL, 0);
NSString *modelIdentifier = [NSString stringWithCString:name encoding:NSUTF8StringEncoding];
free(name);
@yuchan
yuchan / p2.cpp
Created November 21, 2012 14:59
project euler problem #2
#include <iostream>
using namespace std;
int fib(int _n){
if(_n <= 0)
return 0;
else if(_n == 1)
return 1;
else if(_n == 2)
return 2;