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 / 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,

Keybase proof

I hereby claim:

  • I am pdewouters on github.
  • I am pauldewouters (https://keybase.io/pauldewouters) on keybase.
  • I have a public key ASCKDMtJTY4jVSGWFMfIiGE8JeIHEXe-7jNOynTApklIeQo

To claim this, I am signing this object:

@pdewouters
pdewouters / redux_promise_example
Last active May 4, 2016 17:09
Redux Promise Middleware and Thunk example
// actions.js
// Gets list of venues for a city from Foursquare API, then fetches all attendees for those venues from an express server API with mongoDB backend
export const fetchVenues = (city) => {
return (dispatch, getState) => {
return dispatch({
type: FETCH_VENUES,
payload: {
promise: getVenues(city)
}
}).then(
@pdewouters
pdewouters / gist:e797d028cbc5cf14d71afe9db6ac8a66
Last active April 27, 2016 16:01
Ensure array property value is unique when updating a doc
Venue.findOneAndUpdate(
{venue: venueParam},
{$addToSet: {going: req.user.email}}, // $addToSet will only add if not already existing
{safe: true, upsert: true},
function(err, existingVenue){
if(err) return err
res.json(existingVenue)
})
@pdewouters
pdewouters / redux_container.js
Last active March 27, 2016 11:16
Redux Container
// containers/Container.js
import React, { Component } from 'react'
import { connect } from 'react-redux'
import actionCreator from './actions/index'
import { bindActionCreators } from 'redux'
class Container extends React.Component {
render(){
return (
<div>Hello World</div>
@pdewouters
pdewouters / gist:2929833
Created June 14, 2012 11:50
add sencha.io to image tag and remove width/height attributes
add_filter( 'get_image_tag', 'secundo_get_image_tag', 10 );
add_filter( 'image_send_to_editor', 'secundo_get_image_tag', 10 );
// Genesis framework only
add_filter( 'genesis_get_image', 'secundo_get_image_tag', 10 );
function secundo_get_image_tag( $html, $id, $alt, $title, $align, $size ) {
list( $img_src, $width, $height ) = image_downsize( $id, $size );
$class = 'align' . esc_attr( $align ) . ' size-' . esc_attr( $size ) . ' wp-image-' . $id;
$class = apply_filters( 'get_image_tag_class', $class, $id, $align, $size );
@pdewouters
pdewouters / demo.php
Created March 4, 2016 12:04
archive contents of directory
use League\Flysystem\Filesystem;
use League\Flysystem\Adapter\Local;
use League\Flysystem\ZipArchive\ZipArchiveAdapter;
use Symfony\Component\Finder\Finder;
add_action( 'plugins_loaded', function(){
require_once __DIR__ . '/vendor/autoload.php';
$zip_archive = new Filesystem( new ZipArchiveAdapter( __DIR__ . '/archive.zip' ) );
@pdewouters
pdewouters / uppercaserer.js
Created February 7, 2016 19:46
Convert incoming chunks to uppercase
var http = require('http')
var fs = require('fs')
var map = require('through2-map')
var server = http.createServer((req, res) => {
res.writeHead(200,{'Content-type':'text/plain'})
if(req.method != 'POST'){
return res.end('send me a POST\n')
}
req.pipe(map(chunk=>{
@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 / gist:8372778
Created January 11, 2014 16:08
Error when running grunt watch with grunt-contrib-compass - occurs when an scss file is changed and grunt watch detects the change
Running "compass:dist" (compass) task
/Users/pauldewouters/.rbenv/versions/2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/dependency.rb:298:in `to_specs': Could not find 'ffi' (>= 0.5.0) - did find: [ffi-1.9.3-x64-mingw32] (Gem::LoadError)
from /Users/pauldewouters/.rbenv/versions/2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/specification.rb:1265:in `block in activate_dependencies'
from /Users/pauldewouters/.rbenv/versions/2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/specification.rb:1254:in `each'
from /Users/pauldewouters/.rbenv/versions/2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/specification.rb:1254:in `activate_dependencies'
from /Users/pauldewouters/.rbenv/versions/2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/specification.rb:1236:in `activate'
from /Users/pauldewouters/.rbenv/versions/2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/specification.rb:1268:in `block in activate_dependencies'
from /Users/pauldewouters/.rbenv/versions/2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/specification.rb:1254:in