Skip to content

Instantly share code, notes, and snippets.

View rudiedirkx's full-sized avatar

Rudie Dirkx rudiedirkx

View GitHub Profile
@rudiedirkx
rudiedirkx / drupal.placeholder.js
Created October 24, 2014 10:59
Drupal placeholder polyfill
(function ($) {
Drupal.behaviors.placeholderScripts = {
attach: function(context, settings) {
/**
* Placeholder support
*/
if ( !('placeholder' in document.createElement('input')) ) {
function onFocus(e) {
@rudiedirkx
rudiedirkx / livelong.php
Created October 15, 2014 20:32
End request, but keep going (Apache)
<?php
_liveLongStart();
echo "Processing the hell outta everything....\n";
echo "\n";
echo "We'll email you as soon as this is done.\n";
_liveLongEnd();
@rudiedirkx
rudiedirkx / dabblet.css
Created October 12, 2014 23:12
Untitled
html, body, .container {
margin: 0;
height: 100%;
}
table {
width: 100%;
border-collapse: collapse;
}
th, td {
width: 33%;
<!doctype html>
<html lang="en">
<head>
<title>Multiplayer</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=300, height=500, initial-scale=1" />
<style>
* { box-sizing: border-box; font-size: 20px; font-family: arial; margin: 0; padding: 0; }
html { height: 100%; border: solid 20px black; }
@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);
{
"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" },
{
"scope": "source.php - variable.other.php",
"completions":
[
"php",
{ "trigger": "__METHOD__", "contents": "__METHOD__" },
{ "trigger": "__FUNCTION__", "contents": "__FUNCTION__" },
{ "trigger": "__CLASS__", "contents": "__CLASS__" },
@rudiedirkx
rudiedirkx / detect-history-state.js
Last active May 14, 2024 04:12
Detect pushState and replaceState
var _wr = function(type) {
var orig = history[type];
return function() {
var rv = orig.apply(this, arguments);
var e = new Event(type);
e.arguments = arguments;
window.dispatchEvent(e);
return rv;
};
};
@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
<?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());