Skip to content

Instantly share code, notes, and snippets.

View adamsoutar's full-sized avatar
:atom:

Adam Soutar adamsoutar

:atom:
View GitHub Profile
const WORK_COUNT = 1000
const EXAMPLE_PACKET = {
action: 'news/latest/onWebSocketNewsItemUpdate',
data: 1234,
type: 'INSERT'
}
// This represents some synchronous busy-work in JS, like calling ws.write.
// The original code doesn't do anything async or wait on any callbacks.
function writePacket(packet) {
@adamsoutar
adamsoutar / logcat.txt
Last active August 24, 2021 16:57
Logcat output for a Sentry-induced hang on a Moto G
08-24 17:15:58.360 2605 2643 I ActivityManager: Displayed me.overflo.mastermine/com.unity3d.player.UnityPlayerActivity: +262ms
08-24 17:15:58.374 14159 14174 I Unity : MemoryManager: Using 'Dynamic Heap' Allocator.
08-24 17:15:58.391 14159 14174 I zygote : Rejecting re-init on previously-failed class java.lang.Class<com.unity3d.player.AssetPackManagerWrapper$b>: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/play/core/assetpacks/AssetPackStateUpdateListener;
08-24 17:15:58.391 14159 14174 I zygote : at boolean com.unity3d.player.UnityPlayer.nativeRender() ((null):-2)
08-24 17:15:58.391 14159 14174 I zygote : at boolean com.unity3d.player.UnityPlayer.access$300(com.unity3d.player.UnityPlayer) ((null):-1)
08-24 17:15:58.391 14159 14174 I zygote : at boolean com.unity3d.player.UnityPlayer$e$1.handleMessage(android.os.Message) ((null):-1)
08-24 17:15:58.391 14159 14174 I zygote : at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102)
08-24 17:
@adamsoutar
adamsoutar / wave.py
Created February 11, 2020 17:43
Creates an awesome sine wave in your terminal
from math import *
from time import sleep
from shutil import get_terminal_size
i = 0
w = 103
while True:
w = get_terminal_size((80, 20)).columns
for x in range(1, floor((sin(i) + 1) * (w / 2))): print(" ", end='')
print("█")
sleep(0.01)
@adamsoutar
adamsoutar / fastLinks.js
Created January 13, 2020 17:26
Makes <a> tags seem faster by navigating on mousedown instead of up. Yes, it's stupid, but it actually works.
@adamsoutar
adamsoutar / songGenerator.js
Created October 11, 2019 09:23
Continually generates and plays a piano tune. Relies on mudcube/MIDI.js
// MIDI song genereator
const notePallette = [44, 46, 49, 51, 53, 56]
function getPallette () {
return notePallette
}
// eslint-disable-next-line
class Song {
constructor (bpm) {
@adamsoutar
adamsoutar / curve.js
Created September 10, 2019 18:09
Find the curve from a set of straight lines http://overflo.me/finding-the-curve
const div = document.querySelector('div')
const cnv = document.querySelector('canvas')
const ctx = cnv.getContext('2d')
let parts = 10
function draw () {
div.innerHTML = `n = ${parts}`
ctx.clearRect(0, 0, cnv.width, cnv.height)
@adamsoutar
adamsoutar / backupAndRemoveS3.js
Created September 3, 2019 13:35
Locally clone all of your s3 buckets and then delete them. Useful if your S3 storage trial just ran out :)
// Very hacky script written quickly, but it works.
// Didn't feel like taking the time to get billed for more GB-Months
// Requires aws CLI installed and configured with auth - must use output type json
// Usage:
// aws s3api list-buckets --query "Buckets[].Name" | xargs node backupAndRemoveS3.js
const { spawn } = require('child_process')
const { existsSync, mkdirSync } = require('fs')
@adamsoutar
adamsoutar / wtf.sh
Created July 19, 2019 20:59
Put in your path to type 'wtf' when your node project stops working
sudo rm -rf node_modules && npm i
@adamsoutar
adamsoutar / React-Shimmer.js
Created May 18, 2019 16:36
Create an animation similar to facebook/Shimmer in React web
import styled, { keyframes } from 'styled-components'
const shimg = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAANcAAAABCAYAAABNGjuHAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTC