Skip to content

Instantly share code, notes, and snippets.

Avatar

nikushi nikushi

  • Tokyo, Japan
View GitHub Profile
@nikushi
nikushi / gist:b5888a4c7b76069c14335c8acef989fc
Created Jul 22, 2019
RubyMine toolbox -- got error on starting rspec : cannot load such file -- teamcity/spec/runner/formatter/teamcity/formatter (LoadError)
View gist:b5888a4c7b76069c14335c8acef989fc
```
cannot load such file -- teamcity/spec/runner/formatter/teamcity/formatter (LoadError)
```
* RubyMine (installed by toolbox)
* rbenv
# workaround
found `teamcity/spec/runner/formatter/teamcity/formatter.rb` under `~/Library/Application\ Support/JetBrains/Toolbox/apps/RubyMine/ch-0/191.7479.66/RubyMine.app/Contents/rb/testing/patch/bdd`.
@nikushi
nikushi / gh-md-toc-gen.js
Last active Jan 4, 2019
Bookmarklet to generate TOC foro github wiki on cursor point in text area
View gh-md-toc-gen.js
javascript: (() => {
const e = document.querySelector('#gollum-editor-body');
const re = /^(#+)\s*(.+)$/;
const beginToc = '<!-- BEGIN TOC -->';
const endToc = '<!-- END TOC -->';
const lists = e.textContent.split("\n").filter(line => re.test(line)).map((line) => {
const m = line.match(re);
const tag = m[1].replace(/#$/, '*').replace(/#/g, ' ');
const desc = m[2];
@nikushi
nikushi / webpack_dev_server.rb
Last active Nov 21, 2018
Rails HMR with rack-proxy and webpack-dev-server, not using Webpacker
View webpack_dev_server.rb
# config/initializers/webpack_dev_server.rb
if Rails.development?
Rails.application.config.middleware.use WebpackDevServerProxy, dev_server_host: "localhost:9000"
end
View memory-reak-check.rake
desc "Memory growth test"
task :mem_benchmark do
require 'testlib'
N = (ENV['N'] || 100_000).to_i
N.times do |i|
Testlib::do_something
if (i%10_000) == 0
GC.start
ruby_mem = ObjectSpace.memsize_of_all / 1_000
@nikushi
nikushi / 0_reuse_code.js
Created Nov 23, 2016
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@nikushi
nikushi / before-after-method-logging.rb
Created Jul 12, 2016
logging when methods begin and when methods end by prepending
View before-after-method-logging.rb
require 'logger'
module Logging
def self.prepended(base)
target_methods = base.instance_methods - Object.methods
target_methods.each do |method|
define_method(method) do |*args|
log.debug "[Start] #{base}##{method}"
ret = super(*args)
log.debug "[End] #{base}##{method}"
View private.xml
<?xml version="1.0"?>
<root>
<appdef>
<appname>ATOM</appname>
<equal>com.github.atom</equal>
</appdef>
<list>
<item>
<name>Command_R to Control_L (TERMINAL ONLY)</name>
<only>TERMINAL</only>
@nikushi
nikushi / gist:acc807136df9ac722d16
Last active Aug 29, 2015
smokepingをインストールする。perlbrew + Alien::RRDtool + fpingバイナリ
View gist:acc807136df9ac722d16
smokepingをインストールする。
* perlはperlbrewを使いたい
* rrdtool rrdtool-devel rrdtool-perl をシステムパッケージで入れたくない
* つまりAlien::RRDtoolを使う
* fpingがCentOSのrpmで提供されていないのでソースからコンパイルする
* fpingのバイナリだけあればいいので、buildサーバでコンパイルしたfpingバイナリだけ使う
* SmokePingはバージョン固定のためgitで管理
View migration.md

Yohoushi travis rails if running with Rails 2.2.0:

== 20140501115735 AddPathIndexToNodes: migrating ==============================
-- add_index(:nodes, :path, {:length=>255})
rake aborted!
StandardError: An error has occurred, all later migrations canceled:
Index name 'index_nodes_on_path' on table 'nodes' already 
@nikushi
nikushi / Gemfile
Last active Aug 29, 2015
Google Spreadsheet を Ruby で OAuth を使って操作するサンプル
View Gemfile
source 'http://rubygems.org'
gem 'google-api-client', '>= 0.6'
gem 'google_drive'
You can’t perform that action at this time.