Skip to content

Instantly share code, notes, and snippets.

@mostlylikeable
mostlylikeable / AtomicCyclicCounter.groovy
Created February 14, 2018 14:34
AtomicCyclicCounter
import java.util.concurrent.atomic.AtomicInteger
/**
* A cyclic counter that is backed by an {@code AtomicInteger}.
*
* This counter will return integers starting at {@code start} up to {@code max}, then starting over (cycling).
*/
class AtomicCyclicCounter {
int max
int start = 1
// match html class
class=\"(footer|.+ footer)( |\")
@mostlylikeable
mostlylikeable / test_sftp_connection.groovy
Created September 27, 2018 15:25
test sftp connection
@Grab(group='com.jcraft', module='jsch', version='0.1.46')
import com.jcraft.jsch.*
java.util.Properties config = new java.util.Properties()
config.StrictHostKeyChecking = "no"
JSch ssh = new JSch()
Session session = ssh.getSession(user, host, port)
session.config = config
@mostlylikeable
mostlylikeable / git-migrate-up.sh
Created March 6, 2021 03:40
Push all the things from local to remote fork
#!/bin/bash
# script for stashing and pushing all changes, stashes, local branches to remote/fork (origin)
# so they can be pulled down on another machine.
function _gm_not_dry_run() {
return 1 # set to 0 to run
}
# recursively stash any pending changes for all subdirs where this is run
function rstash() {
@mostlylikeable
mostlylikeable / git-migrate-down.sh
Created March 8, 2021 22:27
Pull down things created with git-migrate-up.sh
#!/usr/bin/env bash
# git-migrate-down.sh
function _gm_not_dry_run() {
return 1 # set to 0 to run
}
# pulls all stashes down, re-stashes, and deletes local branch.
# - can uncomment line to also delete remote tmp stash branch
function pull_stashes() {
@mostlylikeable
mostlylikeable / go_tpl_random.go
Created March 24, 2021 05:38
Go Template Randomness
// Comment
`{{/* TODO: add more useful things */}}`
// Ternary var def with or
// $somevar := (.x ? .x : "")
`{{ $somevar := or .x "" }}`
// Ternary var def with and
// $somevar := (.x ? "" : .x)
`{{ $somevar := and .x "" }}`

Keybase proof

I hereby claim:

  • I am mostlylikeable on github.
  • I am mostlylikeable (https://keybase.io/mostlylikeable) on keybase.
  • I have a public key whose fingerprint is C217 F90F 1D51 FA20 97D8 5177 453A 7829 F617 92B8

To claim this, I am signing this object:

@mostlylikeable
mostlylikeable / ts_monorepo.md
Last active April 27, 2022 14:12
typescript monorepo setup with yarn workspaces

Project Setup

Initial setup

# yarn 2
npm install -g yarn
yarn set version berry && yarn set version latest
@mostlylikeable
mostlylikeable / kotlin-mascot-ascii.txt
Last active April 27, 2022 13:59
Kotlin Mascot ASCII
# https://kotlinlang.org/docs/kotlin-mascot.html
,_ _
.H$H$L ╭H$$.
|HHHHHHL, ╭$HHHH:
|HHHHHHHH$>v$HHHHHH:
|HHHHHH .**. .**.`?:
|HHHHHH | | | | ?:
,?H|HHHHHH.`^^' `^^'.?:
.$H` "*HHHHHH$$$$$HHHHHH╯
@mostlylikeable
mostlylikeable / dynamo-example.ts
Created August 18, 2022 02:53
DynamoDb TypeScript Example
import { DynamoDB } from '@aws-sdk/client-dynamodb';
import { DynamoDBDocument } from '@aws-sdk/lib-dynamodb';
const tableName = 'discography';
const artistAlbumsIndex = 'artist-albums';
const table = {
TableName: tableName,
BillingMode: 'PAY_PER_REQUEST',
AttributeDefinitions: [
{ AttributeName: 'pk', AttributeType: 'S' },