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
| ssh() { | |
| if [ -z "$SSH_AGENT_PID" ]; then | |
| eval "$(ssh-agent -s)" | |
| # ssh-add OTHER_KEYS | |
| fi | |
| command ssh $@ | |
| kill $SSH_AGENT_PID | |
| unset SSH_AGENT_PID | |
| } |
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
| // | |
| // ViewController.m | |
| // ScienceHackDay | |
| // | |
| // Created by Genki Sugimoto on 24/10/2015. | |
| // Copyright © 2015 Genki Sugimoto. All rights reserved. | |
| // | |
| #import "ViewController.h" |
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
| require 'sinatra' | |
| require 'json' | |
| require 'droplet_kit' | |
| DO_TOKEN = 'YOUR_TOKEN' | |
| DATA_JSON_FILE = './data.json' | |
| set :bind, '0.0.0.0' | |
| def do_client |
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
| function docker() { | |
| local st | |
| st=$(boot2docker status) | |
| if [ "$st" != "running" ]; then | |
| boot2docker start | |
| fi | |
| if [ -z "$DOCKER_HOST" ]; then | |
| $(boot2docker shellinit) | |
| fi | |
| command docker "$@" |
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 <iostream> | |
| #include <map> | |
| using namespace std; | |
| template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) { | |
| s << "{" << endl; | |
| for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr) { | |
| s << "\t" << (*itr).first << " : " << (*itr).second << endl; | |
| } | |
| s << "}" << endl; |
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
| require 'coverage' | |
| Coverage.start | |
| require './a_method.rb' # => true | |
| a_method | |
| p Coverage.result # => {"/Users/.../a_method.rb"=>[1, 1, 1, 10, nil, 1, nil]} | |
| # Does not produce coverage because `Coverage.result` clears out the coverage | |
| # p Coverage.result # coverage measurement is not enabled (RuntimeError) |
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 a_method | |
| s = 0 | |
| 10.times do |x| | |
| s += x | |
| end | |
| s | |
| end |
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
| (let ((physmem (car (split-string (shell-command-to-string "top -l 1 | head -n 10 | grep PhysMem") "\n"))) | |
| (mem-used nil) | |
| (mem-unused nil)) | |
| (save-match-data (and (string-match "PhysMem: \\([0-9]+[MG]\\) used (\\([0-9]+[MG]\\) wired), \\([0-9]+[MG]\\) unused." physmem) | |
| (setq mem-used (match-string 1 physmem) | |
| mem-unused (match-string 3 physmem)))) |
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
| # Show sushi if current second is 29 | |
| show_niku() { | |
| local sec=$(date +%S) | |
| if [ $sec -eq 29 ]; then | |
| echo "🍣" | |
| fi | |
| } | |
| # it goes well with zsh precmd hook | |
| add-zsh-hook precmd show_niku |
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
| number_to_fizzbuzz() | |
| { | |
| if [ $# -ne 1 ]; then | |
| echo "Usage: $FUNCNAME NUMBER" | |
| return 1 | |
| fi | |
| local output="" | |
| local number=$1 | |
| if [ $(($number % 3)) -eq 0 ]; then |
NewerOlder