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
{"features":[{"id":"5943b3abda50f","name":"Documents","type":"feature-about","icon":"35","sorting":"manual","sections":[{"id":"592","type":"about-section","title":"Despatch letters","content":"<p><a href=\"https:\/\/www.unison.org.uk\/content\/uploads\/2017\/05\/2017-NDC-first-despatch-letter.pdf\">First despatch letter<\/a><\/p>\n"},{"id":"589","type":"about-section","title":"Standing orders","content":"<p>Standing orders will appear here<\/p>\n"},{"id":"586","type":"about-section","title":"Key Documents","content":"<p><a href=\"https:\/\/www.unison.org.uk\/content\/uploads\/2017\/06\/24415.pdf\"><br \/>\nAbout conference<\/a><\/p>\n<p><a href=\"https:\/\/www.unison.org.uk\/content\/uploads\/2017\/06\/24394.pdf\">Conference document<\/a><\/p>\n<p><a href=\"https:\/\/www.unison.org.uk\/content\/uploads\/2017\/06\/2017-National-Delegate-Conference_Composite_Booklet_Final4.pdf\">Conference composite booklet<\/a><\/p>\n<p><a href=\"https:\/\/www.unison.org.uk\/content\/uploads\/2017\/05\/UNISONAnnual-Report-2017
{
"features": [
{
"id": "592fcb6e9243f",
"name": "Venue A-Z",
"type": "feature-about",
"icon": "36",
"sorting": "manual",
"sections": [
{
{
"features": [
{
"id": "1234",
"name": "about test",
"type": "feature-about",
"icon": "26",
"sorting": "manual",
"sections": [
{

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 / 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_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 / 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 / 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)