Skip to content

Instantly share code, notes, and snippets.

View johnbocook's full-sized avatar
💯
I come here for the dark theme.

John Bocook johnbocook

💯
I come here for the dark theme.
View GitHub Profile
@johnbocook
johnbocook / bash-alphanumeric-generator.sh
Created December 22, 2016 08:47
Alphanumeric string generator in Bash
#!/bin/bash
# bash alphanumeric string generator
#
# bash generate random 32 character alphanumeric string (upper and lowercase) and
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# bash generate random 32 character alphanumeric string (lowercase only)
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1
@johnbocook
johnbocook / Bash S3 Upload.sh
Last active December 10, 2018 04:56
AWS S3 Upload
S3KEY="my aws key"
S3SECRET="my aws secret"
function uploadS3
{
path=$1
file=$2
aws_path=$3
bucket='aws-bucket-name'
date=$(date +"%a, %d %b %Y %T %z")
@johnbocook
johnbocook / System Design.md
Created May 3, 2016 19:58 — forked from vasanthk/System Design.md
System Design Cheatsheet

#System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

##Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@johnbocook
johnbocook / student_level.sql
Created March 8, 2016 20:53
Calculate Students Level. Level_ table is usually accurate, You can also do the calculation based on number of credits received 0-29 is freshman, 30-59 is sophomore, 60-89 is junior and 90+ is senior.
(COUNT cred_rec FROM nmcrs
INNER JOIN grades ON grades.grade=nmcrs.grade AND grades.pass = 1
WHERE enrolled = "EN")
@johnbocook
johnbocook / nested_sql_loops.sql
Created March 7, 2016 17:07
Declare two temporary tables, loop over both data-sets while running update query.
-- Created 3/7/2016
-- Author: John Bocook
-- Updates prospects agencies. Loops user id's and selects new agency_cod round robin style.
DECLARE @ids table(tmp_rid int identity(1,1), soc_sec VARCHAR(9), agency CHAR(10))
DECLARE @recruiters table(rec_tmp_rid int identity(1,1), agency CHAR(10))
INSERT INTO @ids (soc_sec)
-- Change select query to pull your user ids
SELECT soc_sec FROM prospect WHERE agency_cod like 'something'
@johnbocook
johnbocook / pocket app - full width article.js
Created January 13, 2016 20:41
Userscript Tamper Monkey Grease Monkey - Makes pocket app (getpocket.com) articles full width.
// ==UserScript==
// @name GetPocket - Page adjustments
// @namespace https://getpocket.com/a/read/
// @description Fixes page layout
// @author jbocook
// @copyright 2015
// @version 1.0.0
// @include *getpocket.com/a/read/*
// @grant none
// ==/UserScript==
@johnbocook
johnbocook / playSound.js
Created November 12, 2015 20:51
$.playSound('http://example.org/sound'); File name must be set without the file extension and should in .mp3 and .ogg format
// Usage: $.playSound('http://example.org/sound.mp3');
(function($){
$.extend({
playSound: function(){
return $("<embed src='"+arguments[0]+".mp3' hidden='true' autostart='true' loop='false' class='playSound'>" + "<audio autoplay='autoplay' style='display:none;' controls='controls'><source src='"+arguments[0]+".mp3' /><source src='"+arguments[0]+".ogg' /></audio>").appendTo('body');
}
});
@johnbocook
johnbocook / UnbounceDynamicDegrees.js
Last active November 5, 2015 18:45
If AGS page, Auto-selects Bachelor Degree and hides/shows programs based on degree_interest selection. Built for unbounce landing pages.
<script type="text/javascript">
lp.jQuery(function($) {
//If not a trad page, run code
if (!(window.location.href.indexOf("trad") > -1 || window.location.href.indexOf("music") > -1)) {
$('#container_degree_interest option[value="Bachelors Degree"]').attr("selected", "selected");
$("#program option:not(:contains('Bachelor of'))").hide();
// Hide/Show program options based on degree selection
@johnbocook
johnbocook / BrownPaperTicketsDonationHide.js
Last active November 5, 2015 14:06
Placed in the Brown Paper Ticket events custom header section to hide the donation text on the checkout page.
$(document).ready(function(){
var url = window.location.href;
if (url.search("checkout.html") >= 0) {
$('td:contains("A portion of Brown Paper Tickets profits"):last').hide();
$('td:contains("This sale should benefit "):last').parent().hide();
}
});
@johnbocook
johnbocook / PhoneFormatter.cfc
Last active November 5, 2015 13:23
Cold Fusion Componet to Clean and Format Phone Numbers
<cfscript>
function formatPhone(varInput) {
var curPosition = "";
var i = "";
var varMask = "(xxx) xxx-xxxx";
var newFormat = "";
var startpattern = "";
//Remove all non digits
varInput = ReReplace(trim(varInput), "[^[:digit:]]", "", "all");