Skip to content

Instantly share code, notes, and snippets.

View bendman's full-sized avatar
🏠
Working from home

Ben Duncan bendman

🏠
Working from home
View GitHub Profile
{
"basics": {
"name": "Ben Duncan",
"label": "Senior Web Developer",
"picture": "https://example.com/photo.jpg",
"email": "[email protected]",
"phone": "+33 6 95 67 69 23",
"website": "https://thomasedison.com",
"summary": "I am a web developer with over 15 years of real-world experience, and have built production features serving millions of users. I am a based in France and am comfortable with remote work. I am particularly interested in improving user experiences on an ambitious and healthy remote-first team.",
"location": {
@bendman
bendman / .tmux.conf
Created October 3, 2020 17:30
My tmux config
# reload configs
bind r source-file ~/.tmux.conf
# increase the scroll buffer size
set -g history-limit 10000
# add the prefix key Ctrl+J
set-option -g prefix C-j
set-option -g prefix2 C-b
@bendman
bendman / api-example.js
Last active February 6, 2017 19:46
Proxy `fetch` in a way that automatically handles file uploads and/or JSON parsing/serializing
import fetch from './fetch-proxy.js';
export async function saveImage(imageURI) {
return await fetch('user/picture', {
method: 'PUT',
body: { photoContent: imageURI },
fileKeys: ['photoContent'],
});
}
@bendman
bendman / createAction.js
Created February 2, 2017 18:22
Abstract creating an action that has a type and a payload
// Abstract creating an action that has a type and a payload:
// const addTodo = createAction(ADD_TODO);
// is equivalent to
// const addTodo = (payload) => ({ type: ADD_TODO, payload });
//
// Optionally you can pass in a payloadMap when defining an action
// to reshape the payload before storing it on the action.
import { identity } from 'lodash';
@bendman
bendman / iterate-promises.js
Created June 30, 2016 20:48
Using generators and promises for more understandable async pipelines.
// This demo uses Babel for es2015 compilation and Promises, and superagent for requests.
// An example async pipeline, using a demo API
document.getElementById('run').addEventListener('click', (evt) => {
iteratePromises(function* () {
log('Requesting list of posts');
let postsResponse = yield superagent.get(
'http://jsonplaceholder.typicode.com/posts/');
log('Requesting author of first post');
@bendman
bendman / symlinkFixer.js
Created December 10, 2015 03:26
Fix broken symlink binaries to be relative symlinks
// Find symlinks that don't work and fix them.
//
// This is done by:
// 1. Getting a list of all file paths in a directory
// 2. Filtering for broken symlinks by reading binary content as unicode
// 5. Determining relative path between source and target
// 6. Deleting old link file
// 7. Creating new relative link file
var fs = require('fs');
@bendman
bendman / progress-plugin.js
Created July 20, 2015 17:51
Return a plugin which logs initial build progress in webpack with live updates.
/**
* getProgressPlugin
* Return a progress plugin instance which outputs build progress percentages in realtime
*
* @return {Object} A ProgressPlugin instance
*/
function getProgressPlugin() {
var chars = 0, lastState, lastStateTime;
return new webpack.ProgressPlugin(function(percentage, msg) {
var state = msg;
@bendman
bendman / gist:74f2b5ec66889c5466ce
Created June 4, 2014 15:36
Check if the current frame has access to the top frame
var crossDomain = (function(){
var top = null;
try {
top = window.top.location.host;
} catch(err) {}
return (top === null);
}());
@bendman
bendman / jsbin-settings.json
Last active August 29, 2015 14:01
JS Bin Settings
settings = {
jshint: true,
editor: {
theme: "monokai",
indentUnit: 4,
smartIndent: true,
lineWrapping: true,
lineNumbers: true,
matchBrackets: true
}