Skip to content

Instantly share code, notes, and snippets.

James Firth James-Firth

View GitHub Profile
@James-Firth
James-Firth / readme.md
Created Oct 16, 2018
Why you need to re-assign promises
View readme.md

This is an example of why you need to re-assign promises in a chain to keep the chain in order. They've been given different variables so you can copy & paste both examples into the same terminal.

Note: You'll need to hit <ENTER> again quickly to see the results properly.

@James-Firth
James-Firth / ssudo.sh
Created Jun 20, 2017
Practice safe-sudo'ing with ssudo. Removes elevated priveleges after a command is run to avoid those accidental shutdowns.
View ssudo.sh
# Throw this in your .zshrc (.bashrc may work too)
safe_sudo() {
cmd="${@: 1}"
if [ "" = "$cmd" ]; then
echo "Missing parameters!";
return 1
fi
sudo ${@: 1};
sudo -k;
View Signal Logcat
D/StatusBar.NetworkController( 914): dumpIcon[(gone) stat_sys_5signal_2|null stat_sys_wifi_signal_in_4 (gone) F]
W/RecipientPreferenceDatabase(31082): Muted until: 0
W/PhoneNumberFormatter(31082): Got local CC: CA
W/TextSecureSessionStore(31082): No existing session information found.
W/RecipientPreferenceDatabase(31082): Muted until: 0
@James-Firth
James-Firth / morse-code.json
Created Oct 15, 2015 — forked from mohayonao/morse-code.json
Morse code and reverse lookup
View morse-code.json
{
"0": "-----",
"1": ".----",
"2": "..---",
"3": "...--",
"4": "....-",
"5": ".....",
"6": "-....",
"7": "--...",
"8": "---..",
@James-Firth
James-Firth / File_Format_CSVs.md
Last active Aug 29, 2015
File Format CSVs - A quick list of common file types to make file parsing easier. Comma and newline delimited for easier human parsing. Still working on adding more data. Data initiailly seeded with data from online-convert.com
View File_Format_CSVs.md

File Format CSVs - A quick list of common file types to make file parsing easier. Comma and newline delimited for easier human parsing. Still working on adding more data. Data initiailly seeded with data from online-convert.com

Currently copying files from my other gist. WIP.

@James-Firth
James-Firth / Am_I_Root.sh
Last active Aug 29, 2015 — forked from PerpetualBeta/gist:6653157
Bash script header to elevate a script that needs to run as "root" if it is run without sudo. Background here: http://darkblue.sdf.org/weblog/post/got-root
View Am_I_Root.sh
# /bin/sh
if [[ $EUID -ne 0 ]]; then
echo 'This script must be run as "root".'
echo 'Enter password to elevate privileges:'
SCRIPTPATH=$( cd $(dirname $0) ; pwd -P )
SELF=`basename $0`
sudo $SCRIPTPATH'/'$SELF
exit 1
fi
@James-Firth
James-Firth / Audio
Last active Aug 29, 2015
File Format CSVs - A quick list of common file types to make file parsing easier. Comma and newline delimited for easier human parsing. Still working on adding more data. Data initiailly seeded with data from online-convert.com
View Audio
"3ga",
"aac",
"aif",
"aiff",
"amr",
"au",
"aup",
"caf",
"flac",
"gsm",
@James-Firth
James-Firth / keybase.md
Created Jan 23, 2015
For keybase.io verification
View keybase.md

Keybase proof

I hereby claim:

  • I am james-firth on github.
  • I am jamesfirth (https://keybase.io/jamesfirth) on keybase.
  • I have a public key whose fingerprint is 2598 E5AD E3EB 0C48 0731 96B0 2844 086A 557B 9B3F

To claim this, I am signing this object:

@James-Firth
James-Firth / tv_renamer.py
Last active Aug 29, 2015
Rename a folder of tv show files.
View tv_renamer.py
#############################################################################################
# The MIT License (MIT)
# Copyright (c) 2014 James Firth
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
@James-Firth
James-Firth / hardlink_checker
Last active Jan 3, 2016 — forked from hollobon/gist:7579947
Forked from https://gist.github.com/hollobon/7579947/ This script recursively checks a directory's files for hardlinks. If there's no other links to a file the name is printed. TODO: Add flags to only print filenames above or below a link count threshold. Add a flag to be recursive.
View hardlink_checker
You can’t perform that action at this time.