Skip to content

Instantly share code, notes, and snippets.

@hirofumi
hirofumi / ExitPrevention.scala
Created June 20, 2018 11:59
prevent `System.exit()` during test
import java.security.Permission
import org.scalatest.{BeforeAndAfter, Suite}
final class ExitPreventionException(val status: Int)
extends SecurityException(s"System.exit($status) is called")
trait ExitPrevention extends BeforeAndAfter { self: Suite =>
before {
ExitPrevention.begin()
@hirofumi
hirofumi / !migration.md
Last active August 13, 2022 19:06
migration

Source

$ brew install rsync
$ /usr/local/opt/rsync/bin/rsync -az --info=progress2 ~/.ghq user@host:
$ /usr/local/opt/rsync/bin/rsync -az --info=progress2 ~/.ivy2 user@host:
$ /usr/local/opt/rsync/bin/rsync -az --info=progress2 ~/.sbt user@host:
$ scp -p .zsh_history user@host:
@hirofumi
hirofumi / Dockerfile
Created January 24, 2018 17:26
Dockerfile for sbt
FROM openjdk:8-jdk
ENV JAVA_OPTS -XX:MaxRAMFraction=1 -XX:MinRAMFraction=1 -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap
RUN echo 'deb http://dl.bintray.com/sbt/debian /' > /etc/apt/sources.list.d/sbt.list \
&& apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2EE0EA64E40A89B84B2DF73499E82A75642AC823 \
&& apt-get update \
&& apt-get -y sbt \
&& mkdir /tmp/x \
&& cd /tmp/x \
@hirofumi
hirofumi / jline-workarounds.sbt
Created January 11, 2018 02:55
~/.sbt/1.0/jline-workarounds.sbt
// from https://github.com/sbt/sbt/issues/3841#issuecomment-355794813
jlineWorkarounds
def jlineWorkarounds = Def.settings(
Seq(
console in Compile,
console in Test,
consoleProject in Compile,
consoleProject in Test,
) map { key =>
@hirofumi
hirofumi / HeadlessChromeFactory.scala
Created January 6, 2018 08:08
HeadlessChromeFactory.scala
import java.text.MessageFormat
import java.util.ResourceBundle
import org.openqa.selenium.WebDriver
import org.openqa.selenium.chrome.{ChromeDriver, ChromeOptions}
import org.scalatestplus.play.BrowserFactory
import org.scalatestplus.play.BrowserFactory.UnavailableDriver
trait HeadlessChromeFactory extends BrowserFactory {
def createWebDriver(): WebDriver =
function repo() {
local selected
selected=$(ghq list --full-path | grep "$1" | peco --query="$1" --select-1)
test -n "${selected}" && cd "${selected}"
}
function _repo() {
_values $(ghq list --unique)
}
compdef _repo repo
@hirofumi
hirofumi / private.xml
Last active February 4, 2016 16:40
My Karabiner Configuration for ThinkPad Compact USB Keyboard with TrackPoint
<?xml version="1.0"?>
<root>
<devicevendordef>
<vendorname>Lenovo</vendorname>
<vendorid>0x17ef</vendorid>
</devicevendordef>
<deviceproductdef>
<productname>ThinkPad_Compact_USB_Keyboard_with_TrackPoint</productname>
<productid>0x6047</productid>
@hirofumi
hirofumi / gist:f85460abad4514e2c474
Created July 2, 2015 04:36
disable "Delete on Termination"
aws ec2 modify-instance-attribute --instance-id INSTANCE_ID --block-device-mappings '[{"DeviceName":"/dev/sda1","Ebs":{"DeleteOnTermination":false}}]'
;; based on https://github.com/emacs-jp/migemo
(defun ag-migemo (regexp directory)
"Search using ag in a given DIRECTORY for a given migemo-ized REGEXP."
(interactive (list (read-from-minibuffer "[MIGEMO] Search regexp: " "")
(read-directory-name "Directory: ")))
(let* ((ag-highlight-search nil)
(ag-arguments (list "--line-number" "--ignore-case" "--nogroup" "--column" "--"))
(buffer (get-buffer-create " *ag-migemo*"))
(process (start-process "ag-migemo" buffer migemo-command "-q" "-d" migemo-dictionary))
(pattern (with-current-buffer (process-buffer process)