Skip to content

Instantly share code, notes, and snippets.

Raine Revere raineorshine

Block or report user

Report or block raineorshine

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@raineorshine
raineorshine / java-exception-handling-best-practices.md
Last active Nov 16, 2019
5 Great Resources for Exception Handling Best Practices in Java
View java-exception-handling-best-practices.md

General Tip

"The trick is to catch exceptions at the proper layer, where your program can either meaningfully recover from the exception and continue without causing further errors, or provide the user with specific information, including instructions on how to recover from the error. When it is not practical for a method to do either of these, simply let the exception go so it can be caught later on and handled at the appropriate level."

Resources

Advantages of Exceptions
Excellent example of separating error-handling code from program logic

Three Rules for Effective Exception Handling
Longer explanation and case study of exception use, including the basic principles of "throw early" and "catch late". Clear and thorough.

@raineorshine
raineorshine / sendRawTransaction.js
Last active Nov 15, 2019
Sends a raw transaction with web3 v1.2.2, ethereumjs-tx v2.1.1, and Infura
View sendRawTransaction.js
const Web3 = require('web3')
const Tx = require('ethereumjs-tx').Transaction
// connect to Infura node
const web3 = new Web3(new Web3.providers.HttpProvider('https://mainnet.infura.io/INFURA_KEY'))
// the address that will send the test transaction
const addressFrom = '0x1889EF49cDBaad420EB4D6f04066CA4093088Bbd'
const privateKey = new Buffer('PRIVATE_KEY', 'hex')
@raineorshine
raineorshine / MyContract.sol
Last active Nov 7, 2019
Generate an AST for an Ethereum Solidity contract with the solidity-parser module.
View MyContract.sol
contract MyContract {
uint counter = 0;
function Count() {
counter++;
}
function CallCount() {
Count();
}
@raineorshine
raineorshine / cheatsheet-git.sh
Last active Oct 20, 2019
Cheatsheet: git commands
View cheatsheet-git.sh
# adding and committing
git add -A # stages All
git add . # stages new and modified, without deleted
git add -u # stages modified and deleted, without new
git commit --amend # Add staged changes to previous commit. Do not use if commit has been pushed.
git commit --amend --no-edit # Do so without having to edit the commit message.
# remotes - pushing, pulling, and tracking
git fetch # gets remote objects and refs. Needed if new branches were added on the remote.
git remote -v # Lists all remotes (verbose)
@raineorshine
raineorshine / test.txt
Created Oct 4, 2019
Test gist linkability
View test.txt
This is a sample sentence.
That is a tample tentence.
@raineorshine
raineorshine / bash-essentials.sh
Created Mar 31, 2014
Bash Cheat Sheet: Just the Essentials (13 Commands). See https://gist.github.com/6927510 for more.
View bash-essentials.sh
man COMMAND # Look up help for the given command
pwd # Print working directory
cd MYDIR # Change directory to MYDIR
cd ~/ # Change directory to user root (/Users/USERNAME)
cd .. # Change directory up a level
mkdir NEWDIR # Create a new directory in the current folder called NEWDIR
cp FROM_FILE TO_FOLDER # Copy FROM_FILE into TO_FOLDER
cp -r FROM_DIR TO_FOLDER # Copy FROM_DIR into TO_FOLDER
@raineorshine
raineorshine / memrise-export.js
Created Oct 22, 2016
Export Memrise course words to CSV
View memrise-export.js
/*
Export Memrise course words to CSV.
1. Log into memrise.com
2. Navigate to course home page (e.g. http://www.memrise.com/course/335725/comprehensive-german-duolingo-vocabulary/)
3. Open Developer Console
4. Paste below script and hit enter
5. After all urls have been fetched, copy final word list into spreadsheet.
View new-package.json
{
"name": "",
"description": "",
"version": "0.0.0",
"author": {
"name": "Raine Revere",
"email": "raineorshine@gmail.com",
"url": "https://github.com/raineorshine"
},
"license": "ISC",
@raineorshine
raineorshine / _chrome-ext-auth-identity.md
Last active Aug 18, 2019
How to set up user authentication for a Chrome Extension using the Chrome Identity API
View _chrome-ext-auth-identity.md

How to set up user authentication for a Chrome Extension using the Chrome Identity API

  1. Create a private key file, from which you can create the manifest key and Application ID, as detailed here: https://stackoverflow.com/questions/23873623/obtaining-chrome-extension-id-for-development
  2. Add the manifest key to "key" in manifest.json
  3. Create a new project in Google Developer Console https://console.developers.google.com/project
  4. Go to "APIs & auth > Credentials" and create new client id for a Chrome Application using the Application ID generated in step 3.
  5. Copy the Client ID to oauth2.client_id in the manifest.json

Deprecated?

You can’t perform that action at this time.