Skip to content

Instantly share code, notes, and snippets.

View rudiedirkx's full-sized avatar

Rudie Dirkx rudiedirkx

View GitHub Profile
@rudiedirkx
rudiedirkx / getTextNodes.js
Created February 14, 2014 12:35
Return child text nodes of a given Dom Element
Element.prototype.getTextNodes = function(trim) {
return [].slice.call(this.childNodes).filter(function(node) {
return node.nodeType == 3 && ( !trim || node.textContent.trim() != '' );
});
};
<?php
class Oele {
function __construct() {
echo __METHOD__ . "\n";
}
function __wakeup() {
echo __METHOD__ . "\n";
}
}
@rudiedirkx
rudiedirkx / read-selection.js
Last active August 29, 2015 13:57
Create a new popup to read the current selection
(function() {
function parents(node) {
var el = node,
els = [];
while ( el && (el = el.parentNode) ) {
els.push(el);
}
return els;
}
function isPrime(n) {
var b = Math.sqrt(n);
if (Math.floor(b) == b) return false;
b = Math.floor(b);
while (b-- > 2) {
var a = n/b;
if (Math.floor(a) == a) return false;
}
return true;
}
@rudiedirkx
rudiedirkx / BOOK.md
Created May 4, 2014 23:28
Ten days in a mad-house

INTRODUCTION.

SINCE my experiences in Blackwell's Island Insane Asylum were published in the World I have received hundreds of letters in regard to it. The edition containing my story long since ran out, and I have been prevailed upon to allow it to be published in book form, to satisfy the hundreds who are yet asking for copies.

I am happy to be able to state as a result of my visit to the asylum and the exposures consequent thereon, that the City of New York has appropriated $1,000,000 more per annum than ever before for the care of the insane. So I have at least the satisfaction of knowing that the poor unfortunates will be the better cared for because of my work.

TEN DAYS IN A MAD-HOUSE.

<?php
$years = array_reverse(range(date('Y')-5, date('Y')));
$years = array_reduce(range(0, 60), function($months, $offset) {
$utc = strtotime('-' . $offset . ' months');
$offset % date('n') == 0 and $months += array(date('Y', $utc) => date('Y', $utc));
$months += array(date('Y-m', $utc) => strtolower(date('Y - M', $utc)));
return $months;
}, array());
@rudiedirkx
rudiedirkx / wtframework.js
Created August 20, 2014 00:11
Old WTFramework bookmarklet
javascript:
(function(){
var m,n=[],j,c,t=document.getElementById("_wtframework"),q=0;c=function(){document.body.removeChild(m);};if(t){document.body.removeChild(t);return;}var b=["MooTools.version","MooTools.More.version","base2.version","dojo.version","Ext.version","jQuery.fn.jquery","$.ui.version","MochiKit.MochiKit.VERSION","Prototype.Version","Scriptaculous.Version","YAHOO.VERSION","S2.Version"];var r=["MooTools Core","MooTools More","Base2","Dojo","Ext JS","jQuery","jQuery UI","MochiKit","Prototype","Script.aculo.us","Yahoo UI","Scripty2"];var k={cursor:"pointer",textAlign:"left",padding:"8px 10px",margin:"0 0 5px",listStyle:"none",font:"bold 11px Lucida Grande",backgroundColor:"rgba(0, 0, 0, 0.7)",color:"#fff",BorderRadius:"5px",MozBorderRadius:"5px",WebkitBorderRadius:"5px",borderTop:"solid%201px%20rgba(255,%20255,%20255,%200.4)",borderLeft:"solid%201px%20rgba(0,%200,%200,%200.8)",borderRight:"solid%201px%20rgba(0,%200,%200,%200.8)",borderBottom:"solid%201px%20#000",textShadow:"0%201px%200
{
"scope": "source.php - variable.other.php",
"completions":
[
"php",
{ "trigger": "__METHOD__", "contents": "__METHOD__" },
{ "trigger": "__FUNCTION__", "contents": "__FUNCTION__" },
{ "trigger": "__CLASS__", "contents": "__CLASS__" },
{
"scope": "source.php - variable.other.php",
"completions":
[
"php",
/* db_* */
{ "trigger": "db_select", "contents": "db_select('${1:table}', '${2:sql}');$0" },
{ "trigger": "db_select_one", "contents": "db_select('${1:table}', '${2:column}', '${3:sql}');$0" },
@rudiedirkx
rudiedirkx / yt-share-blur.js
Created September 22, 2014 22:26
Blur YouTube share input
var el = document.querySelector('#watch7-content');
var mo = new MutationObserver(function(muts) {
muts.forEach(function(mut) {
[].forEach.call(mut.addedNodes, function(node) {
var el = node.querySelector && node.querySelector('input[name="share_url"]');
if ( el ) {
setTimeout(function() {
el.blur();
}, 1);