Skip to content

Instantly share code, notes, and snippets.

View jasonsperske's full-sized avatar

Jason Sperske jasonsperske

View GitHub Profile

Keybase proof

I hereby claim:

  • I am jasonsperske on github.
  • I am sperske (https://keybase.io/sperske) on keybase.
  • I have a public key ASDulU5JtSD8n6FbUOUc-Ew2aEepk77hUZO8-pUPKWGyJAo

To claim this, I am signing this object:

@jasonsperske
jasonsperske / deepestNode.js
Last active July 12, 2017 20:44
Find the deepest left most node in a binary tree (and it's depth). A working demo can be found at: http://jsfiddle.net/YfLx6/5/
var Node = function(name, left, right) {
this.name = name;
this.left = left;
this.right = right;
},
findDeepest = function(node, depth) {
var left, right, depth = depth || 0;
if(typeof node !== 'undefined') {
left = findDeepest(node.left, depth+1);
right = findDeepest(node.right, depth+1);
@jasonsperske
jasonsperske / index.html
Created June 21, 2017 18:24
Get Location Information
<!DOCTYPE html>
<html>
<head>
<meta http-equiv=content-type content="text/html;charset=UTF-8">
<title>GeoLocation Diagnostics</title>
<meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1">
<meta name=format-detection content="telephone=no">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
@jasonsperske
jasonsperske / SendVictory.js
Created March 24, 2017 18:59
Fetches a RandomVictory and sends it to a IFTTT Maker WebHook (defiend in envrionment varibles)
'use strict';
var https = require('https');
function fetchVictory(then, context, callback) {
var options = {
hostname: "randomvictory.com",
port: 443,
path: "/random.json",
method: "GET"
}
@jasonsperske
jasonsperske / index.js
Created March 20, 2017 18:00
Indexing to Algolia
'use strict';
const algoliasearch = require('algoliasearch'),
path = require('path'),
striptags = require('striptags'),
settings = require('nconf').argv().env().file({file: '../settings.json'}).defaults(),
localizations = require('../content/localizations.json'),
base_path = path.join(__dirname, '..'),
utils = require('../fileCMS-utils')(base_path),
algolia_settings = settings.get('algolia'),
client = algoliasearch(algolia_settings.id, algolia_settings.key, function(err, message) {
@jasonsperske
jasonsperske / README.MD
Last active March 1, 2017 01:00
AWS Status Page with fewer requests.

While waiting for the Amazon AWS Status page to report on the actual status of S3 (US-EAST-1) I saw this tweet (https://twitter.com/awscloud/status/836656664635846656)

The dashboard not changing color is related to S3 issue. See the banner at the top of the dashboard for updates.

After seeing this I started working out a way to generate the page from Gulp with as few HTTP requests as possible and thus as few depeancies as possible. This is that attempt (with some guessees as to their schema for status information). I also took the opporunity to fix some invalid HTML on thier site while retianing as close as possible the look and feel of their original site (though with this approach

@jasonsperske
jasonsperske / example.cpp
Created February 21, 2017 22:10
A simple answer to a quoar question
#include <iostream>
using namespace std;
int main() {
int x;
int y;
while(cin >> x >> y) {
cout << "x:" << x << " y:" << y << "\n";
}
return 0;
@jasonsperske
jasonsperske / index.html
Created January 24, 2017 19:17
BeanStream Dynamic Payform (not working)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="">
<title>Payform Demo</title>
function Parser() {
var int = function(n) {
//keep code readable
return parseInt(n, 10);
};
var def = function(field, source, defaults) {
return source[field] ? source[field] : (defaults ? defaults[field] : undefined);
};
var pad = function(number) {
if (number < 10) {
@jasonsperske
jasonsperske / trim.sh
Created April 20, 2016 21:38
Trim the first 3 characters from all filenames
for f in *; do mv "$f" "${f:3}"; done