Skip to content

Instantly share code, notes, and snippets.

View rudiedirkx's full-sized avatar

Rudie Dirkx rudiedirkx

View GitHub Profile
#!/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 July 10, 2021 18:19
Search for/in (certain) files
<?php
class Filesearch {
// Config
public $string = '';
public $extensions = array();
public $dir = '';
public $exclude = array();
public $in_files = true;
public $matcher = 'ci';
@rudiedirkx
rudiedirkx / is_numeric_array.php
Created October 8, 2011 12:12
is_numeric_array
<?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 October 16, 2011 14:33
setTimeout arguments polyfill
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 December 28, 2011 17:06
Time ago function
<?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'),
@rudiedirkx
rudiedirkx / dabblet.css
Created January 5, 2012 18:04 — forked from anonymous/dabblet.css
Double Opacity
/**
* Double Opacity
*/
body{background:green;}
#baz{
opacity: 0.6;
}
#foo{
height:150px;
@rudiedirkx
rudiedirkx / download.js
Created May 6, 2012 16:55
Download any File/Blob via 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 October 8, 2015 15:18
Placeholder polyfill (Drupal behavior)
// 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 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;
});
@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';
// */