Skip to content

Instantly share code, notes, and snippets.

Avatar

Rudie Dirkx rudiedirkx

View GitHub Profile
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('');
}
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 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) {
View ss.bookmarklet.js
javascript:
document.addEventListener('mousedown', e => {
if (e.button == 2 && e.target.nodeName == 'SELECT') {
window.sst = setTimeout(function() {
var q = prompt('Search what?', '');
if (q === '') {
[].forEach.call(e.target.options, o => o.style.display = '');
}
else if (q != null) {
[].forEach.call(e.target.options, o => o.style.display = o.textContent.toLowerCase().indexOf(q) >= 0 ? '' : 'none');
View xmlencode.php
<?php
/**
* Converts UTF-8 to XML-safe HTML entities: Изложение => &#1048;&#1079;&#1083;&#1086;&#1078;&#1077;&#1085;&#1080;&#1077;
*/
function xmlencode($string) {
$string = (string) $string;
// Replace < and ' and & etc.
$string = htmlspecialchars($string, ENT_XML1 | ENT_QUOTES);
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 inc.explorer.php
<?php
$utcStart = microtime(true);
// Last modified timestamp
defined('TIMESTAMP') or define('TIMESTAMP', 'D d-M-Y H:i');
// Permissions
defined('ENABLE_DOWNLOAD') or define('ENABLE_DOWNLOAD', false);
defined('ENABLE_SOURCE') or define('ENABLE_SOURCE', false);
View SendUserInvitationJob.php
<?php
class SendUserInvitationJob {
protected $user;
protected $tests;
function __construct(User $user, array $tests) {
$this->user = $user;
$this->tests = $tests;
}
View behat.sh
# all at once:
vendor/bin/behat
# per feature:
find features/ -type f -name *.feature | xargs -n 1 vendor/bin/behat
@rudiedirkx
rudiedirkx / query.sql
Created May 24, 2016
SELECT ANY, multi UPDATE, multi DELETE
View query.sql
-- SELECT
SELECT *
FROM orders O
WHERE 5 <= ANY(SELECT amount FROM order_lines WHERE order_id = O.id);
SELECT *
FROM orders O
WHERE id IN (SELECT order_id FROM order_lines WHERE amount >= 5);
You can’t perform that action at this time.