Skip to content

Instantly share code, notes, and snippets.

Rudie Dirkx rudiedirkx

Block or report user

Report or block rudiedirkx

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View pre-commit
#!/bin/sh
#
# Read old version from file, make new version, save to file
# file VERSION should be in the root of the project, beside README
# VERSION should *always* be formatted according to GNU version scheme: major.minor.revision
version=$(< VERSION)
major=`echo $version | awk -F"." '{print $1}'`
minor=`echo $version | awk -F"." '{print $2}'`
@rudiedirkx
rudiedirkx / filesearch.php
Last active May 7, 2020
Search for/in (certain) files
View filesearch.php
<?php
class Filesearch {
// Config
public $string = '';
public $extensions = array();
public $dir = '';
public $exclude = array();
public $in_files = true;
public $matcher = 'ci';
View is_numeric_array.php
<?php
$a1 = array('x', 'a' => 'b', 'c', 'd', 'e');
print_r($a1);
var_dump(is_numeric_array($a1)); // false
$a2 = array('a', 'b', 'c', 'd', 'e');
print_r($a2);
@rudiedirkx
rudiedirkx / gist:1290931
Created Oct 16, 2011
setTimeout arguments polyfill
View gist:1290931
window.setTimeout(function() {
if ( !arguments.length ) {
// polyfill
var sto = window.setTimeout;
window.setTimeout = function(cb, speed) {
var args = [];
for ( var i=2; i<arguments.length; i++ ) {
args.push(arguments[i]);
}
sto(function() {
@rudiedirkx
rudiedirkx / time_ago.php
Created Dec 28, 2011
Time ago function
View time_ago.php
<?php
// Example: http://hotblocks.nl/tests/time_ago.php
function time_ago( $f_seconds, $f_size = 2, $f_factor = 1.6 ) {
$units = array(
86400*365.25 => array(' year', ' years'),
86400*30 => array(' month', ' months'),
86400*7 => array(' week', ' weeks'),
86400 => array(' day', ' days'),
View dabblet.css
/**
* Double Opacity
*/
body{background:green;}
#baz{
opacity: 0.6;
}
#foo{
height:150px;
@rudiedirkx
rudiedirkx / download.js
Created May 6, 2012
Download any File/Blob via JS
View download.js
/**
* `url` can be a data URI like data: or a blob URI like blob: or an existing, public resource like http:
* `filename` is the (default) name the file will be downloaded as
*/
function download( url, filename ) {
var link = document.createElement('a');
link.setAttribute('href',url);
link.setAttribute('download',filename);
var event = document.createEvent('MouseEvents');
event.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
@rudiedirkx
rudiedirkx / placeholder.js
Last active Oct 8, 2015
Placeholder polyfill (Drupal behavior)
View placeholder.js
// As seen in bozo/custom.js
(function($) {
Drupal.behaviors.placeholderPolyfill = {
attach: function(context, settings) {
if ( !('placeholder' in document.createElement('input')) ) {
var onFocus = function(e) {
this.$this || (this.$this = $(this));
@rudiedirkx
rudiedirkx / matchesSelector.js
Created Aug 15, 2012
JS polyfill for Element.matchesSelector
View matchesSelector.js
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;
});
@rudiedirkx
rudiedirkx / dbsecrets.js.php
Created Aug 26, 2012
Nodejs requirable secrets
View dbsecrets.js.php
// <?php /*
exports.user = 'root';
exports.password = 'secret password';
exports.database = 'games';
// */
You can’t perform that action at this time.