Skip to content

Instantly share code, notes, and snippets.

@sramam
sramam / install-pt
Created September 17, 2020 21:15 — forked from brandonzylstra/install-pt
Easily install the Platinum Searcher (on Linux) (to your personal bin directory)
#!/usr/bin/env bash
OS_CODE="linux_amd64"
# TODO: check the OS and architecture and make this work across platforms
VERSION="v2.1.5"
# TODO: scrape the GitHub README for the latest version
TARGET=~/bin
# TODO: accept command line options, and prompt if nothing is specified
@sramam
sramam / update-and-publish.sh
Created April 25, 2020 23:52
Automated update and publish procedure
#!/usr/bin/env sh
banner()
{
echo "+------------------------------------------+"
printf "| %-40s |\n" "`date`"
echo "| |"
printf "|`tput bold` %-40s `tput sgr0`|\n" "$@"
echo "+------------------------------------------+"
}
git rebase -i e18577023fd5f5fa5a9d427f40d953c093f4d4d3 -x "git commit --amend --no-edit --no-verify --author -CHEAD "
@sramam
sramam / njb-tryouts-2018-gscript.gs
Last active September 29, 2018 22:26
Script to setup tryout spreadsheet from registration data. setting-sheet.tsv contains all the externalities that can be changed and must be put on a sheet called "Settings" (note capitalization). Also the registration information exported as a .csv file, is assumed to be present in a sheet called "CSV" (again, note capitalization).
function createForm() {
// global constants, that drive the script
var G = {
Settings: 'Settings',
CSV: 'CSV',
Grade: {}
};
var SS = SpreadsheetApp.getActive();
@sramam
sramam / pmap-test.js
Created August 21, 2018 12:43
p-map - testing concurrency when errors happen
const pmap = require('p-map');
const delay = (n) => new Promise(res => setTimeout(res, n));
const promises = [
new Promise(async (res) => {
await delay(20);
res('a')
}),
new Promise(async (res) => {
@sramam
sramam / fizzbizz.js
Last active May 14, 2018 10:42
fizzbizz
/**
A fizzbizz implementation in modern JavaScript
*/
const fizzbizz = (n) => {
const fz = (n) => {
switch(true) {
case (n%15 === 0): return 'fizzbizz';
case (n%5 === 0): return 'bizz';
case (n%3 === 0): return 'fizz';
@sramam
sramam / cli-spinners.js
Last active May 16, 2018 11:44
cross platform spinners - cli-spinners
/**
List of spinners that work on Windows (and mac)
*/
'line,pipe,star2,flip,balloon2,noise,boxBounce2,bouncingBar,shark,dqpb,layer'.split(',')
@sramam
sramam / updateOrRecreate.ts
Created March 26, 2018 20:15
Maps oldData, newData and associated json-schema, to determine if update/recreate/no-op - not perfect, but a start
import * as traverse from 'json-schema-traverse';
import * as jsonFilter from 'json-schema-filter';
import * as concordance from 'concordance';
import * as _ from 'lodash';
import * as jsonPtr from 'json-ptr';
export enum Modification {
Update = 'Update',
Recreate = 'Recreate',
Noop = 'Noop'

Keybase proof

I hereby claim:

  • I am sramam on github.
  • I am sramam (https://keybase.io/sramam) on keybase.
  • I have a public key ASCI8gYhUTm48z9FzuBDI_JvHuzIHiZ7PfN8FcLgwhlEsQo

To claim this, I am signing this object:

@sramam
sramam / bank-account.js
Created March 17, 2018 20:56
A simple bank-account FSM, implemented in javascript-state-machine
const StateMachine = require('javascript-state-machine');
const Account = StateMachine.factory({
init: 'open',
transitions: [
// open state
{name: 'deposit', from: 'open', to: 'open'},
{name: 'withdraw', from: 'open', to: 'open'},
{name: 'available', from: 'open', to: 'open'},