Skip to content

Instantly share code, notes, and snippets.

@stigok
stigok / githook.js
Last active July 30, 2023 09:46
Verify GitHub webhook signature header in Node.js
/*
* Verify GitHub webhook signature header in Node.js
* Written by stigok and others (see gist link for contributor comments)
* https://gist.github.com/stigok/57d075c1cf2a609cb758898c0b202428
* Licensed CC0 1.0 Universal
*/
const crypto = require('crypto')
const express = require('express')
const bodyParser = require('body-parser')
A
A + Certified
A-110
A-122
A-123
A-133
A-frames
A-GPS
A/B Testing
A/R analysis
@Rich-Harris
Rich-Harris / service-workers.md
Last active April 21, 2024 16:24
Stuff I wish I'd known sooner about service workers

Stuff I wish I'd known sooner about service workers

I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.

I'll add to this list over time – suggested additions welcome in the comments or via twitter.com/rich_harris.

Use Canary for development instead of Chrome stable

Chrome 51 has some pretty wild behaviour related to console.log in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.

@flipace
flipace / replacePropertyValue.js
Created November 29, 2015 19:46
Deep replace a value within an object or array (using lodash or underscore)
/**
* Deep search and replaces the given property value "prevVal" with "newVal"
* @param {any} prevVal [description]
* @param {any} newVal [description]
* @param {object|array} object the original object or array in which the values should be replaced
* @return {object|array} the new object or array
*/
function replacePropertyValue(prevVal, newVal, object) {
const newObject = _.clone(object);
@kshiteesh
kshiteesh / urlsafari
Last active March 8, 2024 22:11
This AppleScript saves all the tabs open in all Safari windows to a Markdown file.
(*
Export All Safari Tabs in All Open Windows to a Markdown File
July 13, 2015
// SCRIPT PAGE
http://hegde.me/urlsafari
// ORIGINAL SCRIPT ON WHICH THIS SCRIPT IS BUILT
http://veritrope.com/code/export-all-safari-tabs-to-a-text-file
@nolanlawson
nolanlawson / protips.js
Last active February 4, 2024 18:06
Promise protips - stuff I wish I had known when I started with Promises
// Promise.all is good for executing many promises at once
Promise.all([
promise1,
promise2
]);
// Promise.resolve is good for wrapping synchronous code
Promise.resolve().then(function () {
if (somethingIsNotRight()) {
throw new Error("I will be rejected asynchronously!");
@aponxi
aponxi / sql-mongo_comparison.md
Last active February 21, 2024 11:56
MongoDb Cheat Sheets

SQL to MongoDB Mapping Chart

SQL to MongoDB Mapping Chart

In addition to the charts that follow, you might want to consider the Frequently Asked Questions section for a selection of common questions about MongoDB.

Executables

The following table presents the MySQL/Oracle executables and the corresponding MongoDB executables.

@lancejpollard
lancejpollard / node-folder-structure-options.md
Created November 28, 2011 01:50
What is your folder-structure preference for a large-scale Node.js project?

What is your folder-structure preference for a large-scale Node.js project?

0: Starting from Rails

This is the reference point. All the other options are based off this.

|-- app
|   |-- controllers
|   |   |-- admin
@solenoid
solenoid / gist:1372386
Created November 17, 2011 04:49
javascript ObjectId generator
var mongoObjectId = function () {
var timestamp = (new Date().getTime() / 1000 | 0).toString(16);
return timestamp + 'xxxxxxxxxxxxxxxx'.replace(/[x]/g, function() {
return (Math.random() * 16 | 0).toString(16);
}).toLowerCase();
};