Skip to content

Instantly share code, notes, and snippets.

@kurtroberts
kurtroberts / gist:a5c630792e786313e0e1
Last active July 3, 2018 14:54
When only the least elegant solution will do...
<?php
//I have made a lot of nice things with PHP. But this isn't one of them.
if (!function_exists('lets_confuse_strings_and_symbols')) {
function lets_confuse_strings_and_symbols ($funny_function_name) {
return eval($$funny_function_name);
}
}
@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 / elk-zentral.txt
Created June 20, 2018 17:27 — forked from jbaker10/elk-zentral.txt
Setup ELK stack in Zentral
## To install Kibana
sudo docker pull sebp/elk:latest
## To run the link on your localhost just to test
docker run --link zentral_elastic_1:elasticsearch -p 127.0.0.1:5601:5601 --net zentral_default kibana
## After this, you should be able to access the Kibana dashboard from 127.0.0.1:5601
## Edit the base.json under conf/start/zentral/base.json
vi ./conf/start/zentral/base.json
@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: