Skip to content

Instantly share code, notes, and snippets.

Avatar

Justin Force e0da

View GitHub Profile
@e0da
e0da / ascii_only.rb
Created Jan 29, 2016
Report non-ASCII characters in a file
View ascii_only.rb
#!/usr/bin/env ruby
# x starts at 0 because we increment x BEFORE checking the character.
# y starts at 1 because we only increment it when we hit a newline.
x, y = 0, 1
puts 'Positions are 1-indexed, NOT 0-indexed.'
puts 'i.e. The first character in the file is at position 1:1'
puts
View concatenate-vs-join.rb
require 'benchmark/ips'
STRINGS = %w[
There's no beginning to this story. A bookshelf sinks into the sand. And a
language learned, a forgotten term, is studied once again. It's a shocking
bit of footage viewed from a shitty TV screen. Just squint at it, just snowy
static to make out the meaning. And keep on stretching the antenna hoping that
it will come clear. We need some reception, a higher message. Just tell us
what to fear 'cause I don't know what tomorrow brings. It's alive with such
possibility. All I know is I feel better when I sing.
View Fireworks!.markdown

Fireworks!

You can click and drag then release to fling them, or press F for a fireworks show. Pressing any key will detonate all currently visible fireworks. There's a commented bit that activates the game when the Konami code is entered on the keyboard.

A Pen by Justin Force on CodePen.

License.

View tmux_cheatsheet.markdown

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

View fast-rm
#!/bin/sh
readonly empty_dir=$(mktemp -d)
readonly target="$1"
rm -rf "$empty_dir"
mkdir "$empty_dir"
rsync --recursive --delete "$empty_dir"/ "$target"/
rmdir "$empty_dir" "$target"
View delete_merged_branches.sh
#!/bin/sh
# Attempt to delete every branch except master and the currently checked out
# branch. If the branch isn't merged, it won't delete, and it will be noted on
# STDERR.
git branch | grep -v '\bmaster\b\|^\*' | while read branch; do
git branch -d $branch
done
View lctl.sh
#!/bin/sh
# Example usage:
# lctl stop mysql
# lctl start solr
# lctl restart rabbitmq
# lctl rabbitmq <- no action argument is equivalent to a restart argument
set -ex
@e0da
e0da / README.md
Last active Aug 29, 2015
Audio notification of success or failure after a command finishes. Useful for long-running commands.
View README.md

ding

Audio notification of success or failure after a command finishes. Useful for long-running commands.

Usage

ding rake db:migrate
@e0da
e0da / fast-rm.sh
Last active Aug 29, 2015
rsync-ing an empty directory is waaayyyy faster than rm or find -exec or find -delete
View fast-rm.sh
#!/bin/sh
readonly empty_dir=$(mktemp -d)
readonly target="$1"
rm -rf $empty_dir
mkdir $empty_dir
rsync --recursive --delete $empty_dir/ "$target"/
rmdir $empty_dir "$target"
View cookie_clicker_autopilot.js
You can’t perform that action at this time.