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
| class Bingo | |
| def self.generate | |
| [*1..75] | |
| .each_slice(15) | |
| .map { |v| v.sample(5) } | |
| .tap { |a| | |
| a[2][2] = nil # (´;ω;`) | |
| break a.unshift('BINGO'.chars) | |
| } | |
| .map { |v| |
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
| cond1 = false | |
| cond2 = true | |
| # nested ternary operater | |
| cond1 ? 'piyo' : (cond2 ? 'baz' : 'bar') | |
| # use lambda | |
| [->{'piyo' if cond1}, ->{'baz' if cond1 and cond2}, ->{'bar'}].lazy.map(&:call).select(&:present?).first | |
| => 'bar' |
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
| # OSX | |
| git status | gsed -n '/orig$/p' | gsed -e 's/\t//g' | xargs rm |
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(length) { | |
| var range = function(start, end) { | |
| var result = []; | |
| for(var i=start; i<=end; i++) { | |
| result.push(i); | |
| } | |
| return result; | |
| }; | |
| var source = (function(src, count) { |
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
| #pythonっぽくない | |
| def reverse1(data): | |
| result = "" | |
| for letter in list(data): | |
| result = letter + result | |
| return result | |
| # 標準 | |
| def reverse2(data): |
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
| 00-58/2 * * * * sh /home/vagrant/tmp/test.sh >> /home/vagrant/tmp/test.txt | |
| 01-59/2 * * * * sh /home/vagrant/tmp/test2.sh >> /home/vagrant/tmp/test.txt |
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
| # coding: utf-8 | |
| # python 2.7.5 / fabric 1.7.0 | |
| from fabric.api import env, run | |
| from fabric.decorators import roles, task | |
| from fabric.decorators import parallel | |
| env.use_ssh_config = True | |
| env.colorize_errors = True | |
| env.warn_only = True |
NewerOlder