Skip to content

Instantly share code, notes, and snippets.

View vipickering's full-sized avatar
🦧
Contemplating things

Vincent Pickering vipickering

🦧
Contemplating things
View GitHub Profile
@dougalcampbell
dougalcampbell / utfluv.js
Created March 12, 2012 19:44
Handle invalid JS character sequences
/**
* encode to handle invalid UTF
*
* If Chrome tells you "Could not decode a text frame as UTF-8" when you try sending
* data from nodejs, try using these functions to encode/decode your JSON objects.
*
* see discussion here: http://code.google.com/p/v8/issues/detail?id=761#c8
* see also, for browsers that don't have native JSON: https://github.com/douglascrockford/JSON-js
*
* Any time you need to send data between client and server (or vice versa), encode before sending,
@malarkey
malarkey / Contract Killer 3.md
Last active April 16, 2024 21:44
The latest version of my ‘killer contract’ for web designers and developers

When times get tough and people get nasty, you’ll need more than a killer smile. You’ll need a killer contract.

Used by 1000s of designers and developers Clarify what’s expected on both sides Helps build great relationships between you and your clients Plain and simple, no legal jargon Customisable to suit your business Used on countless web projects since 2008

…………………………

@zachleat
zachleat / reading_time.rb
Last active October 21, 2020 23:00
Read this in X minutes Liquid Filter Plugin (for Jekyll)
# Outputs the reading time
# Read this in “about 4 minutes”
# Put into your _plugins dir in your Jekyll site
# Usage: Read this in about {{ page.content | reading_time }}
module ReadingTimeFilter
def reading_time( input )
words_per_minute = 180
@brock
brock / nodereinstall.sh
Last active April 17, 2024 08:26
Complete Node Reinstall. I've moved this to a repo at http://git.io/node-reinstall
#!/bin/bash
# node-reinstall
# credit: http://stackoverflow.com/a/11178106/2083544
## program version
VERSION="0.0.13"
## path prefix
PREFIX="${PREFIX:-/usr/local}"
var mediumIntegrationToken = "REPLACE_WITH_YOUR_MEDIUM_INTEGRATION_TOKEN";
// That's it. No need to edit anything else below.
// split the comma-separated tags string into an array then remove any whitespace
@jaredpalmer
jaredpalmer / tweet.js
Created April 6, 2016 22:45
send-tweet.js
/*
* Code snippet for posting tweets to your own twitter account from node.js.
* You must first create an app through twitter, grab the apps key/secret,
* and generate your access token/secret (should be same page that you get the
* app key/secret).
* Uses oauth package found below:
* https://github.com/ciaranj/node-oauth
* npm install oauth
* For additional usage beyond status updates, refer to twitter api
* https://dev.twitter.com/docs/api/1.1
@JamieMason
JamieMason / get-in.js
Last active March 4, 2023 10:15
Access deeply nested value in JavaScript: get, getIn, deepGet, getDeep, pluckDeep, deepPluck, getNested, getProp, getDeepProp, getDescendant
const isWalkable = value => value !== null && typeof value !== 'undefined';
const getChild = (parent, child) => (isWalkable(parent) ? parent[child] : undefined);
const getIn = (descendants, origin) => descendants.split('.').reduce(getChild, origin);
@cookie-ag
cookie-ag / app.js
Created November 17, 2017 10:47
Multiple Requests (Promisified)
var __request = require('./logic.js').__request;
var urls = ["http://www.example.com/firts", "http://www.example.com/second", "http://www.example.com/third"];
__request(urls, 'GET', false);
var mediumIntegrationToken = "REPLACE_WITH_YOUR_MEDIUM_INTEGRATION_TOKEN";
// That's it. No need to edit anything else below.
// split the comma-separated tags string into an array then remove any whitespace
var tagsArray = input.medium_tags.split(',');
for (var i = 0; i < tagsArray.length; i++) {
tagsArray[i] = tagsArray[i].trim();
}
@kevinmarks
kevinmarks / diffdata.js
Last active December 26, 2018 16:52
Diff data stripped - compare objects and show only the inner bits that differ
function diffdatastripped(legacy,shiny) {
let delta={},allgood=true;
for (const key in legacy){
const oldval = legacy[key];
const newval = shiny[key];
if (typeof(oldval)==='object' && typeof(newval)==='object'){
delta[key] = diffdatastripped(oldval,newval)
if (delta[key] !="✅") {
allgood=false;
}