Skip to content

Instantly share code, notes, and snippets.

View sscotth's full-sized avatar
🏠
𝄆 🍽 🛌 👨‍💻 𝄇

Scott Humphries sscotth

🏠
𝄆 🍽 🛌 👨‍💻 𝄇
View GitHub Profile
@sscotth
sscotth / module1.vba
Last active December 11, 2015 05:19
vba_gist_test
' Comment
Sub Mac1()
ActiveSheet.PageSetup.LeftFooter = "&08&A"
ActiveSheet.PageSetup.RightFooter = "&08&Z&F"
End Sub
How to remove consecutive new lines: search for ^(.*)(\r?\n\1)+$ and replacing with \1
// Cross-browser xml parsing
var parseXML = function( data ) {
var xml, tmp;
if ( !data || typeof data !== "string" ) {
return null;
}
try {
if ( window.DOMParser ) { // Standard
tmp = new DOMParser();
xml = tmp.parseFromString( data , "text/xml" );
@sscotth
sscotth / keybase.md
Created October 28, 2014 03:16
keybase.md

Keybase proof

I hereby claim:

  • I am sscotth on github.
  • I am sscotth (https://keybase.io/sscotth) on keybase.
  • I have a public key whose fingerprint is 61AD 95F1 60FF C3FA A93A 0C86 E12E C4E0 BACA 0F74

To claim this, I am signing this object:

@sscotth
sscotth / security.json
Created December 12, 2014 21:20
Firebase Security Rules: Grants read/write access to the owner of this user account whose uid must exactly match the key ($uid)
{
"rules": {
"users": {
"$uid": {
".write": "auth !== null && auth.uid === $uid",
".read": "auth !== null && auth.uid === $uid"
}
}
}
}
@sscotth
sscotth / gist:c7ba00301eea3db21aa2
Created December 15, 2014 18:11
Display Timer
var beginTime = new Date()
function displayTimer(){
var secondsSinceBegin = moment.duration( Date.now() - beginTime ).asSeconds();
var formatAsTimer = moment().hour(0).minute(0).second(secondsSinceBegin).format('H:mm:ss');
console.log(formatAsTimer);
}
setInterval(displayTimer, 1000);
@sscotth
sscotth / s3.md
Last active August 29, 2015 14:11
S3 Hosting with S3-CLI

S3 Hosting notes

Install s3cmd

OSX: brew install s3cmd
Debian/Ubuntu: apt-get install s3cmd
Other: Download from http://s3tools.org/s3cmd

use s3cmd to create your .s3cfg config file

s3cmd --configure

@sscotth
sscotth / s3.md
Last active August 29, 2015 14:11
S3 File upload

Generate encoded policy and form signature

Run irb and execute the following commands with your bucket name and AWS secret key. You will need to save the encoded_policy string and the signature.

require 'base64'
require 'openssl'
require 'digest/sha1'

aws_secret_key = 'SKYBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXJoYL'
@sscotth
sscotth / game.js
Last active August 29, 2015 14:13
Game start
function Game(numberOfPlayers){
this.weapons = [];
this.weapons.push(new Weapon({name: 'Sword', damage: 0.2, ammo: Infinity}));
this.weapons.push(new Weapon({name: 'Shotgun', damage: 0.6, ammo: 1}));
this.weapons.push(new Weapon({name: 'Fist', damage: 0.05, ammo: Infinity}));
this.players = [];
for (var i=0; i < numberOfPlayers; i++){
var player = new Player;
@sscotth
sscotth / app.js
Created April 24, 2015 20:53
Pirates vs Ninjas
function Pirate() {
this.says = 'ARRRRRRRRRRRRRR!';
this.toString = function() { return 'Pirate'; };
}
function Ninja() {
this.says = '';
this.toString = function() { return 'Ninja'; };
}