Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
💻

Scott Humphries sscotth

🏠
💻
View GitHub Profile
@sscotth
sscotth / module1.vba
Last active Dec 11, 2015
vba_gist_test
View module1.vba
' Comment
Sub Mac1()
ActiveSheet.PageSetup.LeftFooter = "&08&A"
ActiveSheet.PageSetup.RightFooter = "&08&Z&F"
End Sub
View gist:8428202
How to remove consecutive new lines: search for ^(.*)(\r?\n\1)+$ and replacing with \1
View test.js
// 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" );
View 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 Dec 12, 2014
Firebase Security Rules: Grants read/write access to the owner of this user account whose uid must exactly match the key ($uid)
View security.json
{
"rules": {
"users": {
"$uid": {
".write": "auth !== null && auth.uid === $uid",
".read": "auth !== null && auth.uid === $uid"
}
}
}
}
View gist:c7ba00301eea3db21aa2
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 Aug 29, 2015
S3 Hosting with S3-CLI
View s3.md

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 Aug 29, 2015
S3 File upload
View s3.md

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 Aug 29, 2015
Game start
View game.js
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 Apr 24, 2015
Pirates vs Ninjas
View app.js
function Pirate() {
this.says = 'ARRRRRRRRRRRRRR!';
this.toString = function() { return 'Pirate'; };
}
function Ninja() {
this.says = '';
this.toString = function() { return 'Ninja'; };
}