Skip to content

Instantly share code, notes, and snippets.

@keeganbrown
keeganbrown / binary-search.js
Last active June 17, 2020 15:17
quicksort, mergesort, heapsort, binary search, depth-first, and breadth-first search
function binarySearch(target, sortedArray, start = -1, end = -1) {
if (start < 0) {
start = 0;
}
if (end < 0) {
end = sortedArray.length;
}
let halfDist = sortedArray.length;
let centerIndex = 0;
let center = 0;
@keeganbrown
keeganbrown / bulk-apply-stage-to-wrike-tasks.js
Last active June 14, 2018 22:47
bulk-apply-stage-to-wrike-tasks.js
// To be executed from a task overlay, with subtasks shown.
$('a[wrike-task-view-row-info-plate]')
.map((i, ele) => {
var eleid = ele.href.replace('https://www.wrike.com/open.htm?id=','');
$.ajax({
url: '/ui/batch_task_save',
method: 'POST',
headers: {
'wrike-client-id': 'web-[your wrike id here]',
@keeganbrown
keeganbrown / index.html
Created July 23, 2017 22:32
[v2] Brute Force Random Traveling Salesman solver
<div class="left">
<h1>Input</h1>
<div id="input"></div>
<hr />
<h1>Distance Table</h1>
<div id="distance"></div>
<hr/>
<div class="left">
<h1>Lowest Solution:</h1>
<p id="lowestSolution"></p>
@keeganbrown
keeganbrown / wordpress.gitignore
Last active August 22, 2016 20:39
Sample wordpress gitignore
# INVERTED STYLE GITIGNORE -- ALL FILES/FOLDERS ARE IGNORED UNLESS SPECIFIED.
# Ignore everything in the root except the "wp-content" directory.
/*
!.gitignore
!wp-content/
!resources/
!favicon.ico
# Ignore everything in the "wp-content" directory, except the "plugins" and "themes" directories.
wp-content/*
@keeganbrown
keeganbrown / 1-euler-problem-1-cleaner.js
Last active November 21, 2015 17:13
Stuff I did hanging out at smashing boxes
"use strict";
function findMult ( limit ) {
let mulOfX = ( num, x ) => { return !(num % x) }
let multiples = [];
while ( --limit ) {
if ( mulOfX(limit, 5) || mulOfX( limit, 3 ) ) {
multiples.push( limit );
}
}
var $window = $(window); //Window object
var scrollTime = 1.2; //Scroll time
var scrollDistance = 270; //Distance. Use smaller value for shorter scroll and greater value for longer scroll
$window.on("mousewheel DOMMouseScroll", function(event){
event.preventDefault();
var delta = event.originalEvent.wheelDelta/120 || -event.originalEvent.detail/3;
$(document).on('cbox_complete', function(){
if ( $('#colorbox').find('video').length > 0 ) {
$('#colorbox').find('video')[0].play();
}
});
@keeganbrown
keeganbrown / mobile-master-timeline-scrub.js
Last active August 29, 2015 14:27
mobile master timeline scrub
var scrubpoint = 0;
var isScrolling = null;
$('body').hammer().on('pan', function (e) {
var deltaY = e.gesture.deltaY;
if ( deltaY != 0 && Math.abs(deltaY) > 2 ) {
if ( !isScrolling ) {
$('video').each( function (i, ele) { ele.pause() } );
}
master.pause();
scrubpoint = ( deltaY / Math.abs(deltaY) );
@keeganbrown
keeganbrown / scene-skip.js
Last active August 29, 2015 14:27
master timeline scene skip
$(document).off('mousewheel');
var isScrolling = null;
$(document).on('mousewheel', function (e) {
if ( e.deltaY != 0 && Math.abs(e.deltaY) > 5 ) {
if ( !isScrolling ) {
$('video').each( function (i, ele) { ele.pause() } );
var _label = '';
if ( e.deltaY > 0 ) {
_label = master.getLabelBefore();
var scrubpoint = 0;
var isScrolling = null;
$(document).on('mousewheel', function (e) {
e.preventDefault();
if ( e.deltaY != 0 && Math.abs(e.deltaY) > 5 ) {
if ( !isScrolling ) {
$('video').each( function (i, ele) { ele.pause() } );
}
master.pause();
scrubpoint = ( e.deltaY / Math.abs(e.deltaY) );