Skip to content

Instantly share code, notes, and snippets.

View rudiedirkx's full-sized avatar

Rudie Dirkx rudiedirkx

View GitHub Profile
javascript:
jQuery('select').each(function(i, el) {
el.selectedIndex = 1 + parseInt(Math.random() * (el.options.length-1));
});
jQuery('input:not([type]), input[type="text"], textarea').val(function() {
return ['Lorem', 'Ipsum', 'Dolor'][ parseInt(Math.random() * 3) ];
});
void(0);
@rudiedirkx
rudiedirkx / test.css
Last active December 20, 2015 15:59
Saving a custom attribute into a link_field value.
.form-type-link-field {
display: -webkit-flex;
}
.form-item.form-type-link-field > :last-child {
-webkit-order: -1;
}
@rudiedirkx
rudiedirkx / site.css
Last active December 20, 2015 14:59
rweb://twitter.com
html, body {
background: white !important;
line-height: 1.4;
}
.wrapper, .wrapper-narrow, .wrapper-permalink {
width: 1100px;
}
.content-main {
width: 787px;
<?php
writeln();
writeln('starting...');
write('Progress: [ 0 % ]');
for ( $i=1; $i<=100; $i++ ) {
usleep(rand(100, 100000));
<?php
$files = glob('*');
$sizes = array_map('filesize', $files);
$count_sizes = array_count_values($sizes);
$doubles = count($sizes) - count($count_sizes);
// var_dump($doubles);
@rudiedirkx
rudiedirkx / line-lengths.php
Last active August 14, 2018 21:22
Line lengths for controllers and views recursively in a folder.
<?php
snap('init');
define('LL_TAB_SIZE', 4);
define('LL_TOO_LONG', 130);
define('LL_WAY_TOO_LONG', 220);
ini_set('html_errors', 0);
/* From https://gist.github.com/MadRabbit/996893 */
function Bezier(p1, p2, p3, p4) {
var Cx = 3 * p1,
Bx = 3 * (p3 - p1) - Cx,
Ax = 1 - Cx - Bx;
var Cy = 3 * p2,
By = 3 * (p4 - p2) - Cy,
Ay = 1 - Cy - By;
window.requestAnimationFrame || (window.requestAnimationFrame = window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(cb) {
return setTimeout(cb, 1000 / 60);
});
@rudiedirkx
rudiedirkx / dbsecrets.js.php
Created August 26, 2012 12:17
Nodejs requirable secrets
// <?php /*
exports.user = 'root';
exports.password = 'secret password';
exports.database = 'games';
// */
@rudiedirkx
rudiedirkx / matchesSelector.js
Created August 15, 2012 11:06
JS polyfill for Element.matchesSelector
Element.prototype.matchesSelector || (Element.prototype.matchesSelector = Element.prototype.webkitMatchesSelector || Element.prototype.mozMatchesSelector || function(selecta) {
var els = document.querySelectorAll(selecta);
for ( var i=0, L=els.length; i<L; i++ ) {
if ( els[i] == this ) {
return true;
}
}
return false;
});