- ある程度新しいMac(ここではdarwin-amd64を想定)
- go1.9
- dicebattle/slack-dump
あらかじめgoをインストールしてpathが通った状態にしておいた上で以下を実行(以下はgeneral, random, support, developmentという4つのチャネルをエクスポートしたい場合の例):
require "compute_runtime" | |
req = ComputeRuntime::Request.new | |
resp = ComputeRuntime::Response.new | |
begin | |
req.method = "GET" | |
req.uri = "https://www.ruby-lang.org/en/" | |
result = req.send ComputeRuntime::Body.new.handle, "origin_0" | |
resp.send_downstream ComputeRuntime::Body.new(result[1]) | |
rescue Exception => e |
# worked with ruby 2.3.3 && byebug 10.0.2 | |
# Usage: | |
# ruby byebug_test.rb & byebug -R localhost:8080 | |
require 'byebug' | |
require 'byebug/core' | |
Byebug.wait_connection = true | |
Byebug.start_server('127.0.0.1', 8080) | |
puts 1234 |
あらかじめgoをインストールしてpathが通った状態にしておいた上で以下を実行(以下はgeneral, random, support, developmentという4つのチャネルをエクスポートしたい場合の例):
#include <iostream> | |
#include <iomanip> | |
#include <random> | |
#include <unistd.h> | |
using namespace std; | |
const int MAX_FLOOR = 14; | |
const int ELEVATOR_COUNT = 4; | |
const int RAISING_PROBABILITY = 10; |
skl = VirtualModule.new(:lang=>:python, :pkgs=>["sklearn"=>["datasets", "svm", "grid_search", "cross_validation"]]) | |
include skl | |
iris = datasets.load_iris(:_) | |
clf = grid_search.GridSearchCV(svm.LinearSVC(:_), {'C':[1, 3, 5],'loss':['hinge', 'squared_hinge']}, verbose:0) | |
clf.fit(iris.data, iris.target) | |
p "Best Parameters: #{best_params = clf.best_params_}" #"Best Parameters: {\"loss\"=>\"squared_hinge\", \"C\"=>1}" | |
score = cross_validation.cross_val_score(svm.LinearSVC(loss:'squared_hinge', C:1), iris.data, iris.target, cv:5) | |
p "Scores: #{[:mean,:min,:max,:std].map{|e| e.to_s + '=' + score.send(e, :_).to_s }.join(',')}" # "Scores: mean=0.9666666666666668,min=0.9,max=1.0,std=0.04216370213557838" |
jl = VirtualModule.new(:julia=>["Clustering"]) | |
r = jl.Clustering.kmeans(jl.rand(5, 1000), 20, maxiter:200, display: :iter) | |
p jl.Clustering.assignments(r) # [3, 13, 2, 7, 15, 12, 10, ... 13, 1, 8] |
require 'natto' | |
manpages={} | |
natto = Natto::MeCab.new | |
%w"ps ls cat cd top df du touch mkdir".each do |cmd| | |
list = [] | |
natto.parse(`man #{cmd} | col -bx | cat`) do |n| | |
list << n.surface | |
end | |
manpages[cmd] = list | |
end |
set urlList to {"http://b.hatena.ne.jp/entry/", "https://www.reddit.com/submit?url=", "https://hn.algolia.com/?sort=byPopularity&prefix&page=0&dateRange=all&type=story&query="} | |
set numURLs to (count urlList) | |
open location (item 1 of urlList) & (get the clipboard) | |
tell application "Safari" | |
activate | |
tell window 1 | |
repeat with i from 2 to (numURLs) | |
set current tab to (make new tab) | |
set URL of document 1 to (item i of urlList) & (get the clipboard) | |
end repeat |
require 'benchmark/ips' | |
Benchmark.ips do |x| | |
command = "bundle version" | |
yomikomu = "export RUBYOPT='-ryomikomu' && export YOMIKOMU_AUTO_COMPILE='true'" | |
yomikomanai = "export RUBYOPT='' && export YOMIKOMU_AUTO_COMPILE='false'" | |
x.report("yomikomanai") { p `#{yomikomanai} && #{command}` } | |
x.report("yomikomu(fs)") { p `#{yomikomu} && export YOMIKOMU_STORAGE='fs' && #{command}` } | |
x.compare! | |
end |