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 / 0_reuse_code.js
Last active August 29, 2015 14:20
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@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 [email protected]: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 / file0.txt
Created February 7, 2015 22:48
GitHubのCompare View URLsから比較対象のSHA1を抽出する ref: http://qiita.com/nafu/items/7177c8818f00bc0fcdbd
var="https://github.com/user/repo/compare/049508ce0e26...286b18317092"
echo ${var#*compare/}
# 049508ce0e26...286b18317092
@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 / gist:f65cddde027224317157
Last active August 29, 2015 14:10
Class to String in Swift
class Model {
class func classString() -> String {
return NSStringFromClass(self.classFromCoder)
}
}
@nafu
nafu / gist:8ded244dd4f670563d1c
Created November 29, 2014 17:09
Swift Sequence
// Swift Sequence
import UIKit
var str = "Hello, playground"
class Cart<T> {
var items: [T]
init(items: [T]) {
@nafu
nafu / circle.yml
Created November 15, 2014 16:07
circle.yml for rails
deployment:
production:
branch: master
commands:
- heroku maintenance:on --app production
- heroku scale worker=0 --app production
- git push -f [email protected]:production.git $CIRCLE_SHA1:refs/heads/master
- heroku run 'rake db:migrate; rake db:seed' --app production
- heroku maintenance:off --app production
staging:
@nafu
nafu / werker.yml
Created November 15, 2014 16:04
werker.yml for rails
box: nafu/[email protected]
# 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 / wget_webserver.rb
Created October 13, 2014 16:01
WEBrick for Wget
require 'webrick'
class TestContentServlet < WEBrick::HTTPServlet::AbstractServlet
def do_GET(req, res)
res.body = get_body(req.path)
res.content_type = WEBrick::HTTPUtils.mime_type(
req.path_info, WEBrick::HTTPUtils::DefaultMimeTypes)
end
def get_body(path)
@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;