Skip to content

Instantly share code, notes, and snippets.

View mikedamage's full-sized avatar

Mike Green mikedamage

View GitHub Profile
@mikedamage
mikedamage / stdin-bytes.js
Created April 25, 2022 20:06
Get size of piped STDIN in Node
#!/usr/bin/env node
// Borrowed and simplified from pretty-bytes by Sindre Sorhus
// https://github.com/sindresorhus/pretty-bytes/blob/main/index.js
function prettyBytes(num) {
const UNITS = [
'b',
'kb',
'mb',
'gb',

Keybase proof

I hereby claim:

  • I am mikedamage on github.
  • I am mikegreen (https://keybase.io/mikegreen) on keybase.
  • I have a public key whose fingerprint is 9D26 EDB9 CD61 8734 7B20 8B7F 5369 495C F7A1 2392

To claim this, I am signing this object:

@mikedamage
mikedamage / usb-phone-control.zsh
Created April 25, 2019 13:57
Control an Android phone over USB and toggle tethering
typeset -A keys
keys=(
power 26
home 3
up 19
down 20
left 21
right 22
enter 66
)
@mikedamage
mikedamage / matrix-beta-instructions.md
Last active June 26, 2017 14:24
Mikedamage.info Matrix Server Beta Instructions

Mikedamage.info Matrix Chat Server Instructions

I've decided to change the communication protocol used by the mikedamage.info chat server from XMPP to Matrix.org. I just finished setting up a Matrix instance on the chat server, and it's ready for some intrepid guinea pigs to kick the tires! There's a long winded explanation of why I'm switching us over to Matrix, but I put it below the instructions in case you don't really care.

TL;DR Matrix is easier for me to manage, more secure for you, and everybody can access the server using same app, with the same awesome features, on pretty much any device or operating system in existence.

Coming Soon: Once I set the Matrix server up properly, we'll be able to do real-time, person to person voice and video calls in addition to text chat!

How to Connect

@mikedamage
mikedamage / collatz.js
Created May 3, 2015 17:30
Collatz Conjecture in JS
#!/usr/bin/env node
'use strict'
function collatz(num) {
var result;
if (num % 2 === 0) {
result = num / 2;
} else {
@mikedamage
mikedamage / jquery.transitions.js
Created April 28, 2015 16:06
jQuery CSS Transition Callbacks Plugin (ES6)
/**
* jQuery Transition Callbacks Module
* by Mike Green <mike@fifthroomcreative.com>
*/
/* jshint esnext: true, globalstrict: true, browser: true */
'use strict';
import $ from 'jquery';
@mikedamage
mikedamage / gist.zsh
Created April 27, 2015 18:55
Quick and dirty time-based file removal
#!/usr/bin/env zsh
setopt NULL_GLOB EXTENDED_GLOB
# Files older than this will be deleted
KEEP_DAYS=30
files=($PWD/*(.Nmd+$KEEP_DAYS))
for f in $files; do
@mikedamage
mikedamage / rescan.sh
Created February 24, 2015 02:33
Force a WiFi scan
#!/bin/bash
gksudo iwlist wlan0 scan
zenity --info --title="WiFi Scan" --text="WiFi scan complete!"
@mikedamage
mikedamage / snip.html
Created February 17, 2015 14:26
Inline styles vs. classes and external stylesheets
<!-- This is bad for business: -->
<p style="margin: 15px;">
<strong style="color: #f00;">This is important!</strong>
<span style="color #ccc;">This isn't.</span>
</p>
<!-- Instead, define a class with a semantic, descriptive name, and style it in an external stylesheet: -->
<!-- in <head>: -->
<link rel="stylesheet" href="style.css">
@mikedamage
mikedamage / java-watcher.sh
Created February 6, 2015 15:08
Java class auto-compiler
#!/bin/bash
#
# Inotify Java Watcher
# by Mike Green <mike.is.green@gmail.com>
#
# Automatically compiles Java classes when their files are saved.
#
# = Installation: Save this script into the root folder of your Java projects, then run:
# $ cd whatever-your-folder-is-called && chmod +x java-watcher.sh
#