Skip to content

Instantly share code, notes, and snippets.

@EricLondon
EricLondon / imessage.sh
Last active October 20, 2022 15:51
imessage.sh
#!/bin/sh
if [ "$#" -eq 1 ]; then stdinmsg=$(cat); fi
exec <"$0" || exit; read v; read v; read v; exec /usr/bin/osascript - "$@" "$stdinmsg"; exit
on appIsRunning(appName)
application appname is running
end appIsRunning
-- taken from:
-- http://stackoverflow.com/questions/11812184/how-to-send-an-imessage-text-with-applescript-only-in-provided-service
@EricLondon
EricLondon / setenv.sh
Created April 8, 2022 19:23
set environment variable outside script
#!/bin/sh
# Usage:
# . ./setenv.sh
#
# echo $ENV1
# blah1
#
# echo $ENV2
# blah2
@EricLondon
EricLondon / ruby-encoded-text.rb
Created October 29, 2021 12:07
Ruby Encoded Text
i=44
s="We; n7trangMsL8loT63Ke rules5s8d8I
AJull commit4nt'sChatFKink: of6CHldn'tRetKisJrom<ny@Ruy-/A= if?<sk 42DS'tLE 4?;Lo8bli=L7ee..
O,R1)O,R001)/-.."
"
I justCannaLE?2Gotta >u=Msta=.|
Ng1Nlet? downNrun<rH=5desMt?N>cryNsayRoodbyeNtE< lie5hurt?|
We'T3n each@Jor s8lSg6r hear9<ch: but6;Lo7hyL7BInsideCe both3Cha9Ro: S
We3KeRa45we;QplB|1)O)NgiT, nPgiT
@EricLondon
EricLondon / helpers.rb
Created February 19, 2019 20:25
RSpec helper capture stdout
module Helpers
def with_captured_stdout
original_stdout = $stdout
$stdout = StringIO.new
yield
$stdout.string
ensure
$stdout = original_stdout
end
end
@EricLondon
EricLondon / color.rb
Created February 13, 2019 17:31
Rails other/remaining scopes
# frozen_string_literal: true
class Color < ApplicationRecord
scope :red, -> { where(color: 'red') }
scope :yellow, -> { where(color: 'yellow') }
scope :blue, -> { where(color: 'blue') }
scope :non_primary, -> { where.not(id: red).where.not(id: yellow).where.not(id: blue) }
end
@EricLondon
EricLondon / launch.json
Created December 19, 2018 14:33
VSCode debug nodejs with NVM launch config
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/test.js",
"runtimeExecutable": "${workspaceRoot}/node.sh"
}
@EricLondon
EricLondon / .ruby-gemset
Created November 9, 2018 13:41
Ruby populate person objects in S3
person-data
@EricLondon
EricLondon / .nvmrc
Last active October 23, 2018 16:21
Lamba, NodeJS, API Gateway, Terraform
8.10.0
@EricLondon
EricLondon / .terraform-version
Created October 18, 2018 10:34
Terraform S3 backend
0.11.8
@EricLondon
EricLondon / pipe-count.sh
Last active September 21, 2018 13:52
Shell script to append missing character to end of line based on count of occurrence
#!/usr/bin/env bash
INPUT_FILE=some-input-file.txt
OUTPUT_FILE=output.txt
while read p; do
pipecount=$(echo $p | awk -F"|" '{print NF}')
if [ $pipecount == 45 ]; then
echo "$p|" >> $OUTPUT_FILE
else