$ brew tap homebrew/science
$ brew install octave
$ brew uninstall gnuplot
$ brew install Caskroom/cask/xquartz
$ brew cask install aquaterm
$ brew install gnuplot --with-aquaterm --with-x11
$ gnuplot
This file contains 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
package main | |
// NOTE: change to event driven | |
import ( | |
"fmt" | |
"io" | |
"io/ioutil" | |
"os" | |
"strings" |
This file contains 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 Array | |
# avoid to conflict `#to_enum` | |
def to_enumerator | |
enum = Object.const_set('Enum', Module.new) | |
enum.tap do | |
each_with_index do |e, idx| | |
enum.define_singleton_method(e) { idx } | |
end | |
end | |
end |
This file contains 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
#!/bin/bash | |
IFS=$'\n' | |
since_date='2010-01-01' | |
git_authors() { | |
git log --shortstat --since="${since_date}" | grep -e '^Author' | awk -F' ' '{$1="";$NF=""; print}' | sort | uniq | sed -e 's/^ //g' | |
} | |
git_stat() { |
This file contains 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 'securerandom' | |
require 'base64' | |
# https://github.com/rails/rails/blob/master/actionview/lib/action_view/helpers/csrf_helper.rb#L20-L27 | |
# token = 'jYZcRG05o2IRERhLVqwNVZREdUe4XB0okJRcBUrBQlQ=' | |
# <meta name="csrf-param" content="authenticity_token" /> | |
# <meta name="csrf-token" content="sZu120+MWcK2pEomGML/5SsRSgmGaYOwt0ABKTu663MV0FPC2ssoQuhRl2FXRAn+jEreDewPRIq0ZRh4AoTfxA==" /> | |
class Csrf | |
AUTHENTICITY_TOKEN_LENGTH = 32 |
This file contains 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 'benchmark' | |
require 'concurrent' | |
require 'net/http' | |
require 'uri' | |
require 'webmock' | |
class AsyncHttp | |
include Concurrent::Async # important | |
def initialize(base_uri) |
This file contains 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
if (!window.jQuery) { | |
document.body.appendChild((function(){ | |
var s = document.createElement("script"); | |
s.type = "text/javascript"; | |
s.src = "https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"; | |
return s; | |
})()); | |
} |
This file contains 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
retries = 0 | |
begin | |
service.update(record) | |
rescue VendorDeadlockError => e | |
raise if retries >= 3 | |
retries += 1 | |
logger.warn("API failure: #{e}, retrying...") | |
sleep(5**retries) | |
retry |
This file contains 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 Lock | |
def self.acquire | |
lock = new # リソース初期化 | |
lock.exclusive_lock! | |
if block_given? | |
yield(lock) | |
else | |
lock | |
end |
This file contains 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 Version | |
include(Compareble) | |
attr_accessor(:major, :minor, :patch) | |
def initialize (version) | |
@major, @minor, @patch = | |
version.split('.').map(&:to_i) | |
end | |
def <=> (other) |
NewerOlder