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
@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 / filesearch.php
Last active Dec 26, 2019
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 bezier.js
/* 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;
View rwebsocket.js
var http = require('http');
var https = require('https');
var websocket = require('websocket');
var util = require('util');
function _log(msg) {
console.log.apply(console, arguments);
console.log('');
}
@rudiedirkx
rudiedirkx / detect-history-state.js
Created Sep 4, 2014
Detect pushState and replaceState
View detect-history-state.js
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 / line-lengths.php
Last active Aug 14, 2018
Line lengths for controllers and views recursively in a folder.
View line-lengths.php
<?php
snap('init');
define('LL_TAB_SIZE', 4);
define('LL_TOO_LONG', 130);
define('LL_WAY_TOO_LONG', 220);
ini_set('html_errors', 0);
View packagist-dependees.js
var PACKAGE = 'rdx/db';
ghGrapQL(`query { viewer { login, repositories(first: 100, privacy: PUBLIC, orderBy: {direction: DESC, field: PUSHED_AT}) { nodes { name } } } }`).then(rsp => {
return rsp.data.viewer.repositories.nodes.map(repo => `${rsp.data.viewer.login}/${repo.name}`)
}).then(repos => {
return repos.map(repo => {
return (rsps) => {
console.log(repo);
return fetch(`https://rawgit.com/${repo}/master/composer.json`).then(rsp => rsp.ok ? rsp.json() : null).then(rsp => rsps.concat([[repo, rsp]]));
}
});
View mailtodisk.php
<?php
// sendmail_path="C:\XAMPP\php\php.exe C:\WWW\mailtodisk.php \"C:\XAMPP\mailoutput\__TIME__-__RAND__-__SUBJECT__.eml\""
// sendmail_path = "/usr/bin/php /var/www/mailtodisk.php \"/var/www/mailoutput/__TIME__-__RAND__-__SUBJECT__.eml\""
// file_put_contents(__DIR__ . '/mailtodisk.log', print_r($_SERVER, 1));
// Destination folder/filename is required
$destination = @$_SERVER['argv'][1];
if (!$destination) {
View ing-creditcard-export.js
javascript: (function(f, a) {
f = new Blob(['"Date","Description","Amount"\n', [].map.call(queryAllShadow('.trx-item', queryAllShadow('.ing-uif-card.credit-card:last-of-type')[0]), row => ([
row.closest('.date-item').querySelector('time').getAttribute('datetime'),
row.querySelector('h5').textContent.trim(),
row.querySelector('ing-uic-amount').value,
]).map(col => '"' + col.replace(/"/g, '""') + '"').join(',')).join('\n')], {type: 'text/plain'});
a = document.createElement('a');
a.download = 'trans.csv';
a.href = URL.createObjectURL(f);
a.click();
View background.js
const queue = [];
chrome.browserAction.onClicked.addListener(function(tab) {
var url = 'http://www.example.com/?x=' + String(Math.random()).substr(2);
queue.push(url);
console.log('queue', queue);
chrome.tabs.update({url});
});
chrome.runtime.onMessage.addListener(function(msg, sender, sendResponse) {
You can’t perform that action at this time.