Skip to content

Instantly share code, notes, and snippets.

View pdewouters's full-sized avatar
🌄
Working from home

Paul de Wouters pdewouters

🌄
Working from home
View GitHub Profile
@pdewouters
pdewouters / juggling_async.js
Created February 7, 2016 15:07
Handling multiple async requests in nodejs
var http = require('http')
var concat = require('concat-stream')
var urls = process.argv.slice(2)
var strings = []
function loadURls(){
var url = urls.shift()
if(!url){
strings.forEach(myString => {
console.log(myString)
@pdewouters
pdewouters / quotes.json
Created October 14, 2015 09:37
Quotes
[
{
"property1": "A quote by Hunter S. Thompson, 1937 - 2005",
"property2": "Whatever else might be said about Nixon — and there is still serious doubt in my mind that he could pass for human — he is a goddamned stone fanatic on every aspect of pro football.\nHunter S. Thompson",
"index": 1,
"url": "http://www.qotd.org/search/single.html?qid=1"
},
{
"property1": "A quote by Anonymous",
"index": 2,
@pdewouters
pdewouters / gist:5f915904c16056c22af8
Last active October 4, 2015 09:23
Secret santa and code pairing draws
var participants = ["Paul","Matt","Owain","Joe"],
results = [],
hat = _.shuffle(participants);
_.each(participants, function(participant){
var picked = _.sample(_.without(hat,participant));
results.push([participant,picked]);
hat = _.without(hat,picked);
});
function reverseArray(items){
var reversed = [];
for(var i=items.length;i>0;i--){
reversed.push(items.pop());
}
return reversed;
};
console.log(reverseArray(["A","B","C"]));
function reverseArrayInPlace(arrayItems){
if ( is_multisite() ) {
global $wpdb;
// get current blogs from DB
$blogs = $wpdb->get_results( "SELECT blog_id FROM {$wpdb->blogs} ORDER BY blog_id" );
foreach ( $blogs as $blog ) {
if ( is_main_site() ) {
@pdewouters
pdewouters / plugin.php
Last active August 29, 2015 14:16
CRON Conditional
// Don't load plugin unless we are in the admin or called by a cron or Ajax request
if ( ! is_admin()
|| ( ! defined( 'DOING_CRON' ) || ! DOING_CRON )
|| ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
return;
}
@pdewouters
pdewouters / footer-admin-timer.php
Created January 3, 2015 20:52
Display time to build and render admin page in seconds in the footer of the WordPress admin
@pdewouters
pdewouters / gist:d35c3e54679b058fc22c
Created December 24, 2014 10:39
Sensiolabs plugin error
Empty PSI elements should not be passed to createDescriptor. Start: PhpDocTagValue, end: PhpDocTagValue
java.lang.Throwable
at com.intellij.openapi.diagnostic.Logger.error(Logger.java:115)
at com.intellij.codeInspection.ProblemDescriptorBase.<init>(ProblemDescriptorBase.java:70)
at com.intellij.codeInspection.InspectionManagerBase.createProblemDescriptor(InspectionManagerBase.java:75)
at com.intellij.codeInspection.InspectionManagerBase.createProblemDescriptor(InspectionManagerBase.java:64)
at com.intellij.codeInspection.ProblemsHolder.registerProblem(ProblemsHolder.java:66)
at com.sensiolabs.insight.inspection.SensioLabsLocalXmlInspection$1.onLineMatch(SensioLabsLocalXmlInspection.java:51)
at com.sensiolabs.insight.psi.PsiViolationUtil.attachLineViolations(PsiViolationUtil.java:65)
at com.sensiolabs.insight.inspection.SensioLabsLocalXmlInspection.buildVisitor(SensioLabsLocalXmlInspection.java:47)
@pdewouters
pdewouters / gist:f353786df2d2cd1faead
Last active August 29, 2015 14:10
Unix permissions
var_dump(chmod( $this->path->get_default_path(), 0555 ));
var_dump("owner of the current PHP script " . get_current_user());
print_r(posix_getpwuid(fileowner($this->path->get_default_path())));
var_dump(substr(sprintf('%o', fileperms($this->path->get_default_path())), -4));
@pdewouters
pdewouters / npm-debug.log
Created November 29, 2014 16:57
Debug log for npm install -g browser-sync
This file has been truncated, but you can view the full file.
0 info it worked if it ends with ok
1 verbose cli [ 'node', '/usr/local/bin/npm', 'install', '-g', 'browser-sync' ]
2 info using npm@2.1.10
3 info using node@v0.10.33
4 verbose node symlink /usr/local/bin/node
5 silly cache add args [ 'browser-sync', null ]
6 verbose cache add spec browser-sync
7 silly cache add parsed spec { raw: 'browser-sync',
7 silly cache add scope: null,
7 silly cache add name: 'browser-sync',