Skip to content

Instantly share code, notes, and snippets.

View nafu's full-sized avatar
🧗
Keep exploring

Fumiya Nakamura nafu

🧗
Keep exploring
View GitHub Profile
@nafu
nafu / KeychainOnlySwift.swift
Created December 20, 2014 14:49
Keychain sample
import Security
public class Keychain {
public class func save(str: String?, forKey: String) -> Bool {
if str == nil {
return false
}
let dataFromString: NSData = str!.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)!
let query = [
@nafu
nafu / werker.yml
Created November 15, 2014 16:04
werker.yml for rails
box: nafu/ubuntu12.04-ruby2.1.1@1.0.1
# Build definition
# See the Rails section on the wercker devcenter:
# http://devcenter.wercker.com/articles/languages/ruby/settingup-rails4.html
# You will want to define your database as follows:
services:
- wercker/postgresql
# See more about services on our devcenter:
# http://devcenter.wercker.com/articles/services/
build:
@nafu
nafu / ps4a.py
Created March 2, 2013 21:03
Word Game
# 6.00x Problem Set 4A Template
#
# The 6.00 Word Game
# Created by: Kevin Luu <luuk> and Jenna Wiens <jwiens>
# Modified by: Sarina Canelake <sarina>
#
#
# Implemented by: Fumiya Nakamura <nafu>
#
@nafu
nafu / circle.yml
Last active June 2, 2016 16:04
CircleCIでherokuのprebootの設定を自動で行う ref: http://qiita.com/nafu/items/4c480934871bbdfb56e9
deployment:
production:
branch: master
commands:
- NEED_MAINTENANCE_MODE=`./script/circleci.sh`; if [ $NEED_MAINTENANCE_MODE -eq 1 ]; then heroku features:disable preboot --app production; else heroku features:enable preboot --app production; fi
- NEED_MAINTENANCE_MODE=`./script/circleci.sh`; if [ $NEED_MAINTENANCE_MODE -eq 1 ]; then heroku maintenance:on --app production; fi
- NEED_MAINTENANCE_MODE=`./script/circleci.sh`; if [ $NEED_MAINTENANCE_MODE -eq 1 ]; then heroku scale worker=0 --app production; fi
- git push -f git@heroku.com:production.git $CIRCLE_SHA1:refs/heads/master
- NEED_MAINTENANCE_MODE=`./script/circleci.sh`; if [ $NEED_MAINTENANCE_MODE -eq 1 ]; then heroku run 'rake db:migrate' --app production; fi
- heroku run 'rake db:seed' --app production
@nafu
nafu / gist:5687843
Created May 31, 2013 20:44
Delete multiple line including specific word
WORD='XXX:'; FILE=`ack $WORD -l | head -1`; cat $FILE; sed '/'$WORD'/d' $FILE > tmp; mv tmp $FILE;
# 6.00x Problem Set 5
#
# Part 2 - RECURSION
#
# Problem 3: Recursive String Reversal
#
def reverseString(aStr):
"""
Given a string, recursively returns a reversed copy of the string.
# 6.00x Problem Set 5
#
# Part 1 - HAIL CAESAR!
import string
import random
WORDLIST_FILENAME = "words.txt"
# -----------------------------------
@nafu
nafu / ps3_hangman.py
Created February 22, 2013 17:48
Hangman game
# 6.00 Problem Set 3
#
# Hangman game
#
# -----------------------------------
# Helper code
# You don't need to understand this helper code,
# but you will have to know how to use the functions
# (so be sure to read the docstrings!)
<!DOCTYPE HTML>
<html lang="ja-JP">
<head>
<meta charset="UTF-8">
<script src="http://d3js.org/d3.v3.min.js"></script>
<title>D3Circle</title>
</head>
<body>
<div id="D3line"></div>
<script type="text/javascript">
@nafu
nafu / index.html
Last active December 14, 2015 01:39
<!DOCTYPE HTML>
<html lang="ja-JP">
<head>
<meta charset="UTF-8">
<script src="http://d3js.org/d3.v3.min.js"></script>
<title>D3line</title>
</head>
<body>
<div id="D3line"></div>
<script type="text/javascript">