Skip to content

Instantly share code, notes, and snippets.

@kurtroberts
kurtroberts / userscript.js
Last active June 5, 2018 18:22
Are you also sick of getting video ads about Wordpress from Lynda.com in your Linked In Feed?
// ==UserScript==
// @name Brutally remove Lynda updates from linkedin
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Because srsly, what have I ever done to deserve bombardment by wordpress ads?
// @author You
// @match https://www.linkedin.com/feed/
// @grant none
// ==/UserScript==
@kurtroberts
kurtroberts / console
Created June 2, 2018 19:46
Srsly Adobe?!?!?!?!
$ ps aux | grep dobe
root 45838 0.0 0.0 4332424 576 ?? Ss 17May18 0:00.26 /Library/PrivilegedHelperTools/com.adobe.ARMDC.SMJobBlessHelper
root 45837 0.0 0.0 4331920 588 ?? Ss 17May18 0:00.16 /Library/PrivilegedHelperTools/com.adobe.ARMDC.Communicator
hyxf 32829 0.0 0.1 4981964 7072 ?? S 4May18 0:14.98 /Applications/Utilities/Adobe Creative Cloud/CCLibrary/CCLibrary.app/Contents/MacOS/../libs/node /Applications/Utilities/Adobe Creative Cloud/CCLibrary/CCLibrary.app/Contents/MacOS/../js/server.js
hyxf 32749 0.0 0.1 5019532 8556 ?? S 4May18 0:37.82 /Applications/Utilities/Adobe Creative Cloud/CCXProcess/CCXProcess.app/Contents/MacOS/../libs/node /Applications/Utilities/Adobe Creative Cloud/CCXProcess/CCXProcess.app/Contents/MacOS/../js/main.js
hyxf 640 0.0 0.4 5250672 36188 ?? S 25Apr18 3:03.46 /Library/Application Support/Adobe/Adobe Desktop Common/HEX/Adobe CEF Helper.app/Content
@kurtroberts
kurtroberts / index.js
Created January 24, 2018 02:36
The end of PERL slang in JS
//JSHint brought my attention to the fact that some PERLisms are just not cool in JS anymore...
//This is cool with JSHint:
console.time('if1');
for (var i = 0; i < 100000; i++) {
if(1) { //nice and safe, and don't even THINK of skipping those {}s, even though you don't need them either...
console.log(1 + 1);
}
}
console.timeEnd('if1');
@kurtroberts
kurtroberts / index.php
Created January 22, 2018 20:20
PHP code to cause @dakhran to sigh in despair.
<?php
//if your permissions are set insecurely, he can't prove you did it either!
echo "Let's do this!!!";
ob_start();
echo "exec('rm index.php');";
eval(ob_get_clean());
@kurtroberts
kurtroberts / gist:316b6cf89442d4fd3b7c7467e884a7af
Last active January 10, 2018 15:34
More fun with PHP's lack of type safety...
$ php -a
php > echo ('' == (string)$some ? 1 : 0);
1
php > echo ('' == $some ? 1 : 0);
1
php > echo ('' === $some ? 1 : 0);
0
php > echo ('' === (string)$some ? 1 : 0);
1
@kurtroberts
kurtroberts / index.js
Created November 12, 2017 02:14
One-stop understanding of Promises...
//TL;DR - Read the MDN page and skip all the tutorials:
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
//ES6
var x = new Promise((resolve, reject) => {
setTimeout(function () { resolve('test'); }, 5000);
});
x.then((msg) => console.log(msg));

Keybase proof

I hereby claim:

  • I am kurtroberts on github.
  • I am kurtroberts (https://keybase.io/kurtroberts) on keybase.
  • I have a public key ASA70wmzqCJjoErdlX8kpu7lj9CdWPXYcWL_lHdFwa7EIgo

To claim this, I am signing this object:

@kurtroberts
kurtroberts / workDays.js
Created February 24, 2016 18:28
Fun with Generators
var getNextDay = function (initialDate) {
initialDate.setDate(initialDate.getDate() + 1);
return initialDate;
},
dayOff = function (day) {
if (day.getDay() == 0 || day.getDay() == 6) {
return true;
}
return false;
@kurtroberts
kurtroberts / integers-in-js.md
Last active July 3, 2018 14:53
Understanding Integers and Performance in JS

Understanding Integers and Performance in JS

This is just an interactive node session, not really a code snippet.

But it's pretty instructive.

Implicit Casting

kroberts-macpro:~ kroberts$ node
> 23|0
@kurtroberts
kurtroberts / test.js
Created October 13, 2015 17:26
I really thought at the level of abstraction we typically work (Node.js) the idea of "write combining" wasn't going to make a difference. I was wrong.
//To understand how I started down this rabbit hole, go here: http://mechanical-sympathy.blogspot.com/2011/07/write-combining.html
var iterations = parseInt(2147483647 / 128);
//Base case, no optimization
function runCaseOne () {
console.time('caseOne');
var i = iterations,
arrayA = [],
arrayB = [],