Skip to content

Instantly share code, notes, and snippets.

View schalkneethling's full-sized avatar
🇺🇦
The world wants peace, not war ✌️

Schalk Neethling schalkneethling

🇺🇦
The world wants peace, not war ✌️
View GitHub Profile
@schalkneethling
schalkneethling / getEquilibriumIndexes.js
Created August 24, 2016 10:36
Using a data array of numbers returns an array of equilibrium indexes
var data = [-1, 3, -4, 5, 1, -6, 2, 1];
function upperTotal(index, data) {
var totalUpper = 0;
for (var i = index + 1, l = data.length; i < l; i++) {
totalUpper = totalUpper + data[i];
}
return totalUpper;
'use strict';
function getLargestBinaryGap(input) {
var binary = (input >>> 0).toString(2);
var longestGap = 0;
var matchArray = [];
var regexp = /1{1}(0+)(?=1)/g;
while ((matchArray = regexp.exec(binary)) !== null) {
let matchLength = matchArray[1].length;
@schalkneethling
schalkneethling / docker-compose.yml
Created November 14, 2016 15:38
Spin up a local docker for wordpress development
wpdb:
image: mysql
ports:
- "8081:3306"
environment:
MYSQL_ROOT_PASSWORD: p@33w0rd
wp:
image: wordpress
volumes:
@schalkneethling
schalkneethling / wesbos-drum-machine.js
Created January 3, 2017 16:33
My code tweak for the Javascript30 by Wes Bos day 1
let keys = document.querySelector('.keys');
keys.addEventListener('transitionend', function(e) {
if (e.propertyName === 'transform') {
e.target.classList.remove('playing');
}
});
function playPercussion(e) {
const audioTrack = document.querySelector(`audio[data-key="${e.keyCode}"]`);
@schalkneethling
schalkneethling / config.json
Created February 9, 2017 12:45
Base config file for testing the All Aboard add-on
{
"afterInteractionCloseTime": 5000,
"defaultSidebarInterval": 10,
"defaultSidebarCloseTime": 7000,
"timeElapsedFormula": 1000,
"nonuseDestroyTime": 120000,
"waitInterval": 10000
}
@schalkneethling
schalkneethling / recursive-func-tmpl.js
Created May 9, 2017 09:17
Recursive function template
let callMe = function() {
if (condition) {
// base case reached
} else {
// recursive case
callMe();
}
return;
};
@schalkneethling
schalkneethling / sketch001.pde
Created May 9, 2017 19:29
Simple drawing sketch for Processing
/*
* Creative Coding
* Week 1, 01 - Draw your name!
* by Indae Hwang and Jon McCormack
* Updated 2016
* Copyright (c) 2014-2016 Monash University
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
@schalkneethling
schalkneethling / bubbles.pde
Created May 11, 2017 15:40
Make bubble arrays, and art with Processing
/*
* Creative Coding
* Week 1, 02 - Draw your name! (part 2)
* by Indae Hwang and Jon McCormack
* Updated 2016
* Copyright (c) 2014-2016 Monash University
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
@schalkneethling
schalkneethling / lt_1000_ms.sql
Created October 28, 2017 11:42
Shows the percentage of users for which the page loads in 1 second or less
#standardSQL
SELECT
origin,
SUM(bin.density) * 100 AS `fraction_of_users_lt_1000`
FROM (
SELECT
origin,
first_contentful_paint.histogram.bin AS bins
FROM
`chrome-ux-report.chrome_ux_report.201710`
@schalkneethling
schalkneethling / nvm.sh
Created November 12, 2017 15:29
An attempt make nvm.sh runnable by fish-shell [WIP]
# Node Version Manager
# Implemented as a POSIX-compliant function
# Should work on sh, dash, bash, ksh, zsh
# To use source this file from your bash profile
#
# Implemented by Tim Caswell <[email protected]>
# with much bash help from Matthew Ranney
# "local" warning, quote expansion warning
# shellcheck disable=SC2039,SC2016,SC2001