Skip to content

Instantly share code, notes, and snippets.

var urls = ['http://www.google.com', 'http://www.twitter.com'];
function get_request(url) {
return new Promise(function (resolve, reject) {
...
});
}
Error: write EPROTO
at Object.exports._errnoException (util.js:874:11)
at exports._exceptionWithHostPort (util.js:897:20)
at WriteWrap.afterWrite (net.js:763:14)
Error: write EPROTO
at Object.exports._errnoException (util.js:874:11)
at exports._exceptionWithHostPort (util.js:897:20)
at WriteWrap.afterWrite (net.js:763:14)
var Schema = function (input) {
var output = {};
Object.keys(input).forEach(function (key) {
if (input[key] === Number) {
output[key] = 'REAL';
}
else if (input[key] === String || input[key] === 'TEXT') {
output[key] = 'TEXT';
@brandonros
brandonros / countries+states.json
Created August 25, 2016 19:27
Two/three letter country codes with provinces/states
[
{
"code": "AF",
"name": "Afghanistan",
"provinces": [
{
"code": "BDS",
"name": "Badakhshān"
},
{
PROJECT = hello_erlang
DEP_PLUGINS = cowboy hexpm.mk
BUILD_DEPS = hexpm.mk
dep_hexpm.mk = git https://github.com/botsunit/mix.mk.git master
dep_cowboy_commit = 2.1.0
dep_pgapp = hex 0.0.2
dep_poison = hex 3.1.0
dep_epgsql = hex 3.4.0
@brandonros
brandonros / bmw-esys-series-codes.java
Last active April 1, 2024 13:10
Extracted BMW F series ESYS commands (DME/ECU/Tune/Code)
// Random code sequences I found throughout a flashing tool
D = new hs("RCS_EraseCoding", "31 01 0F 01", 3, false);
e = new ha("DSC_DS", "10 01");
f = new ha("DSC_ES", "10 03");
g = new ha("DSC_PS", "10 02");
h = new ha("DSC_DEVS", "10 4F");
i = new ha("DSC_CS", "10 41");
j = new ku("RCS_SEMD", "31 01 0F 0C 00");
k = new ku("RCS_SEMF", "31 01 0F 0C 03");
// mandeljit.c
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <stdarg.h>
typedef struct {
char *dest;
} microasm;
// this makes it more obvious what we're doing later on
@brandonros
brandonros / blueGreenDeployment.js
Created December 17, 2018 01:42
node.js + nginx + PM2 rolling release/blue green deployments (zero downtime)
const Promise = require('bluebird');
const fs = require('fs');
const execa = require('execa');
class BlueGreenDeployment {
constructor({appName, blueProxyPassPattern, greenProxyPassPattern, nginxConfigFile}) {
this.appName = appName;
this.blueProxyPassPattern = blueProxyPassPattern;
this.greenProxyPassPattern = greenProxyPassPattern;
this.nginxConfigFile = nginxConfigFile;
@brandonros
brandonros / cookies.js
Created February 21, 2019 06:04
Vanilla JavaScript frontend client cookie manipulation
const getCookie = (name) => {
var value = '; ' + document.cookie
var parts = value.split('; ' + name + '=')
if (parts.length === 2) {
return parts.pop().split(';').shift()
}
}
const setCookie = (name, value) => {