Skip to content

Instantly share code, notes, and snippets.

@nikushi
nikushi / webpack_dev_server.rb
Last active January 16, 2024 05:10
Rails HMR with rack-proxy and webpack-dev-server, not using Webpacker
# config/initializers/webpack_dev_server.rb
if Rails.development?
Rails.application.config.middleware.use WebpackDevServerProxy, dev_server_host: "localhost:9000"
end
@nikushi
nikushi / gist:b5888a4c7b76069c14335c8acef989fc
Created July 22, 2019 12:33
RubyMine toolbox -- got error on starting rspec : cannot load such file -- teamcity/spec/runner/formatter/teamcity/formatter (LoadError)
```
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 / tmux-multi-ssh
Created November 6, 2014 01:31
tmuxで複数にsshしてコマンドシンクするスクリプト by @mikeda
#!/bin/bash
#
# http://tech.naviplus.co.jp/2014/01/09/tmuxで複数サーバの同時オペレーション/
#
if [ -n "$SESSION_NAME" ];then
session=$SESSION_NAME
else
session=multi-ssh-`date +%s`
fi
@nikushi
nikushi / gh-md-toc-gen.js
Last active January 4, 2019 05:21
Bookmarklet to generate TOC foro github wiki on cursor point in text area
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 / instag.rb
Created March 20, 2012 12:45
A Liquid tag for Jekyll sites that allows embedding image file on Instagram.
# Title: A Liquid tag for Jekyll sites that allows embedding image file on
# Instagram.
# Authors: Nobuhiro Nikushi https://twitter.com/#!/niku4i
# Description: Easily embed image file on Instagram page.
#
# Syntax {% instag [class name(s)] http://instagr.am/p/IYYs5bo0jd/ [width [height]] [title text | "title text" ["alt text"]] %}
#
# Examples:
# {% instag http://instagr.am/p/IYYs5bo0jd/ %}
# {% instag left half http://instagr.am/p/IYYs5bo0jd/ my title %}
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 November 23, 2016 14:20
Here are some things you can do with Gists in GistBox.
// 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 July 12, 2016 02:14
logging when methods begin and when methods end by prepending
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}"
<?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 / gas-memo.md
Last active January 5, 2016 07:57
Google Apps Script For Beginnerを読んでいる。途中のメモ書き

chapter 1

簡単なデバッグ

*Logger.log('message') コンソールログ

  • throw('message') flash alert的なポップアップ
  • SpreadsheetApp.getActiveSpreadsheet().toast('message') Spreadsheet等の右側にポップアップメッセージ
  • Browser.msgBox('hello world'); 中央にポップアップメニュー + button。Browerクラスでは文字列入力などのポップアップも出せる

スプレッドシートの自動整形