Skip to content

Instantly share code, notes, and snippets.

View pokle's full-sized avatar

Tushar Pokle pokle

View GitHub Profile
@pokle
pokle / jest-guard.js
Last active June 15, 2018 04:26
Guard against common Jest assertion testing shortcomings
// Unfortunately there's no global unhandledResolve handler :-(
process.on('unhandledRejection', error => {
console.error('unhandledRejection', error);
throw new Error('unhandledRejection' + error);
});
beforeEach(() => expect.hasAssertions());
@pokle
pokle / install-haskell-stack.sh
Created March 12, 2018 23:05
My Haskell stack setup
#!/usr/bin/env sh
# On Amazon Linux
sudo yum groupinstall 'development tools'
sudo yum install gmp-devel zlib-devel
# Everywhere
curl -sSL https://get.haskellstack.org/ | sh
stack config set system-ghc --global true

Keybase proof

I hereby claim:

  • I am pokle on github.
  • I am poklet (https://keybase.io/poklet) on keybase.
  • I have a public key ASASDjK9RkNJYIwYJwMonYejDqhbWHNl-wcupbDO_lnAsgo

To claim this, I am signing this object:

@pokle
pokle / hello.hs
Last active August 30, 2017 00:08
haskell stack shell script starter kit
#!/usr/bin/env stack
-- stack --resolver lts-9.2 script
main = putStrLn "Hello"
@pokle
pokle / ndjson-sample.js
Created August 23, 2017 12:15
nodejs neeson template with back pressure
// Try this with: seq 1 10 | node ndjson.js
// Don't forget to npm install ndjson
const ndjson = require('ndjson')
const parser = ndjson.parse();
const printer = ndjson.serialize();
printer.pipe(process.stdout);
process.stdin
@pokle
pokle / Makefile
Created August 11, 2017 23:14
Makefile to illustrate the difference between `=` and `:=`
TS = $(shell date)
# TS := $(shell date)
a: b
@sleep 1
@echo $(TS)
touch a
b: c
@pokle
pokle / my-software-development-toolchest.md
Last active April 2, 2017 08:20
My software development toolchest

Tried and tested tools:

  • React
  • Clojure (for the backend)
  • Firebase (Great for quick web prototypes and large web scale apps)
  • Cassandra (but will I ever host my own cluster again?)
  • JVM
  • Cloudformation (Yes, the syntax is annoying, but it's nice being able to delete an entire formation of AWS services off in one hit)

Tools I'd like to start a new project with:

(I have had minimal or no experience with these - they sound like a cool idea)

@pokle
pokle / indented.sh
Last active September 21, 2017 08:12
How to indent the output of a shell colorising stderr red
#!/usr/bin/env bash
#
# Based on http://stackoverflow.com/questions/9112979/pipe-stdout-and-stderr-to-two-different-processes-in-shell-script
set -e
function indented() {
echo RUnNINg: $@
(set -o pipefail; { "$@" 2>&3 | sed >&2 's/^/ | /'; } 3>&1 1>&2 | perl -pe 's/^(.*)$/\e[31m | $1\e[0m/')
}
@pokle
pokle / aws-kms-example.sh
Created June 29, 2016 11:56
How to encrypt / decrypt an Amazon KMS secret
#!/usr/bin/env bash
KEYID=f0f2af05-6530-4dcf-a7ef-602f5bb8f642
echo hello hello > ExamplePlaintextFile
aws kms encrypt --key-id f0f2af05-6530-4dcf-a7ef-602f5bb8f642 --plaintext fileb://ExamplePlaintextFile --output text --query CiphertextBlob | base64 --decode > ExampleEncryptedFile
aws kms decrypt --ciphertext-blob fileb://ExampleEncryptedFile --output text --query Plaintext | base64 --decode
#!/usr/bin/env osascript
tell application "Google Chrome" to reload active tab of window 1