Skip to content

Instantly share code, notes, and snippets.

View pzaich's full-sized avatar

Paul Zaich pzaich

View GitHub Profile
Download Virtual Box & Install http://download.virtualbox.org/virtualbox/5.1.6/VirtualBox-5.1.6-110634-OSX.dmg
curl -s https://raw.githubusercontent.com/xdissent/ievms/master/ievms.sh | env IEVMS_VERSIONS="9" bash
This failed for me w/ message:
MD5 check failed for unar1.5.zip (wanted fbf544d1332c481d7d0f4e3433fbe53b, got ae4362c240eb7909fcda1ce2f26cfb36)
Instead: brew install unar
Try again: curl -s https://raw.githubusercontent.com/xdissent/ievms/master/ievms.sh | env IEVMS_VERSIONS="9" bash
@pzaich
pzaich / gist:1cf15d8bd4b48449048f73d69091ca05
Created September 6, 2016 17:39
Sublime User Preferences
{
"color_scheme": "Packages/Theme - Cobalt2/cobalt2.tmTheme",
"file_exclude_patterns":
[
"*.pyc",
"*.pyo",
"*.exe",
"*.dll",
"*.obj",
"*.o",
@pzaich
pzaich / find_dupes.js
Created August 26, 2016 05:00
Find duplicates in a sorted array in Olog(n)
// Find duplicate in sorted array
var sortedArray = [1,2,3,3,4,5,6,7,8];
var sortedNoDupes = [1,2,3,,4,5,6,7,8];
// Binary search
function findDuplicate(arr) {
var midpoint = Math.floor(arr.length / 2);
var mid = arr[midpoint];
var left = arr[midpoint - 1];
var right = arr[midpoint + 1];
@pzaich
pzaich / gist:a9acbbc1b7efc781d2c32e164e2131d5
Created August 17, 2016 04:52
Find Rotation Point of mostly sorted array of words
// simple O(n), linear method
function linearFindRotationPoint(array) {
var rotationPointIndex;
for (var i = 1; i <= array.length; i++) {
if (array[i-1] > array[i]) {
rotationPointIndex = i;
break;
}
@pzaich
pzaich / binary_tree.js
Last active August 17, 2016 00:09
Is a given a binary tree superbalanced? A simple Javascript traversal of binary trees
// First Build binary trees from a pojo representation
// Find the max depths of the binary tree's "node leafs"
var _ = require('underscore');
function BinaryTreeNode(value) {
this.value = value;
this.left = null;
this.right = null;
}
@pzaich
pzaich / gist:1a6a01146312102729c942763186e697
Created July 12, 2016 03:56
Forward port 80 to 3000 using pfctl
echo "
rdr pass inet proto tcp from any to any port 80 -> 127.0.0.1 port 3000
" | sudo pfctl -ef -
@pzaich
pzaich / gist:38ece4135c37c149e474
Created May 3, 2015 16:14
library_controller.js
angular.module('example', [])
.controller('libraryController', function (Books) {
var initialize = function () {
$scope.books = Books
}
$scope.removeBook = function () {
// accessible to scope
}
@pzaich
pzaich / service_encapsulation.js
Created April 19, 2015 17:40
service encapsulation
angular.module('example', [])
.service('libraryService', function () {
var books = [];
this.searchBooks = function () {
// return books that match query
}
});
var library = libraryService;
@pzaich
pzaich / factory_encapsulation.js
Last active August 29, 2015 14:19
factory encapsulation
angular.module('example', [])
.factory('libraryFactorySingleton', function () {
var books = [];
return {
searchBooks: function (query) {
// return books that match query
}
};
})
@pzaich
pzaich / pojo.js
Created April 19, 2015 17:17
pojo_constructor
var Library = function (books) {
var books = [];
this.searchBooks = function (query) {
// return books that match query
}
}
var books = [];
var library = new Library(books);