Skip to content

Instantly share code, notes, and snippets.

View dylan-chong's full-sized avatar
💧
Elixiring

Dylan Chong dylan-chong

💧
Elixiring
View GitHub Profile
on run {input, parameters}
global currentProcess
tell application "System Events"
--set currentProcess to the name of the first process where it is frontmost
set currentProcess to (path to frontmost application as text)
end tell
activate application "VirtualBoxVM"
@dylan-chong
dylan-chong / perl-multiline.sh
Created January 9, 2018 23:10
Perl find and replace across multiple lines
# File
echo 'A' > test-file
echo 'B' >> test-file
perl -i -0 -pe 's/A\nB/REPLACEMENT/g' test-file
defprotocol P do
def x(p)
end
defimpl P, for: Integer do
def x(p) do
p + 1
end
end
@dylan-chong
dylan-chong / rename-files.sh
Created November 3, 2017 23:36
Batch rename files
find * | xargs rename -n 's/part-of-filename-to-replace/replacement/' # -n for dry run
# Dry run, print out results
find * -type f | xargs perl -0p -e 's/from/to/g'
# Do replace in files
find * -type f | xargs perl -0pi -e 's/from/to/g'
@dylan-chong
dylan-chong / assign_pipe.ex
Last active October 16, 2017 20:40
Elixir assign at end of pipe
defmodule AssignPipe do
# Source: https://groups.google.com/forum/#!topic/elixir-lang-core/SJUgN5enNhc
defmacro value ~> var do
{:=, [line: 1], [var, value]}
end
end
defmodule Test do
import AssignPipe