Skip to content

Instantly share code, notes, and snippets.

@robrich
robrich / gist:74bff4b51358a3470160
Created May 1, 2014 17:35
Experiments on request timeouts when a server isn't listening in different platforms
/*jshint node:true */
'use strict';
/*
What happens if there's no server listening when we do the request?
- win32: socket.on('timeout' fires and req.abort() fires req.on('error', e) with e.code === 'ECONNRESET'
- else: req.on('error', e) fires imediately with e.code === 'ECONNREFUSED'
*/
var http = require('http');
@robrich
robrich / phxjs-gulpfile.js
Created June 19, 2014 03:57
sample gulpfile.js created at @phxjs
//jshint node:true
'use strict';
var gulp = require('gulp');
var less = require('gulp-less');
var uglify = require('gulp-uglify');
var gulpIf = require('gulp-if');
var express = require('express');
@robrich
robrich / hammerhead-from-lrx21o-to-lrx22c.md
Last active August 29, 2015 14:12 — forked from eyecatchup/hammerhead-from-lrx21o-to-lrx22c.md
@jonmcoe is right: it's trivial to get into recovery mode from the stock recovery
  UPDATE `NEXUS 5` 
     SET `VERSION`='5.0.1', `BUILD`='LRX22C', `RECOVERY`='CUSTOM', `ROOTED`=1 
   WHERE `VERSION`='5.0' && `BUILD`='LRX21O' && `RECOVERY`='CUSTOM' && `ROOTED`=1 
         && `WANNA_KEEP_USERDATA`=1;

A manual OTA for rooted hammerheads, quasi.

@robrich
robrich / hammerhead-from-lrx21o-to-lrx22c.md
Last active August 29, 2015 14:12 — forked from eyecatchup/hammerhead-from-lrx21o-to-lrx22c.md
@jonmcoe is right, it's trivial to get into stock recovery's options
  UPDATE `NEXUS 5` 
     SET `VERSION`='5.0.1', `BUILD`='LRX22C', `RECOVERY`='CUSTOM', `ROOTED`=1 
   WHERE `VERSION`='5.0' && `BUILD`='LRX21O' && `RECOVERY`='CUSTOM' && `ROOTED`=1 
         && `WANNA_KEEP_USERDATA`=1;

A manual OTA for rooted hammerheads, quasi.

@robrich
robrich / AuthorApi.js
Last active October 15, 2018 22:21
Move from promises to async/await
import delay from './delay';
import { authors } from './authorData'
//This would be performed on the server in a real app. Just stubbing in.
let maxid = authors.reduce(((currentMax, {id}) => currentMax>id ? currentMax : id), 0 );
const generateId = (author) => {
return ++maxid;
};
@robrich
robrich / gist:3b5ee06a1bc179f3c5cfce0055def5d4
Last active August 10, 2021 08:23
MemSQL load-balanced failover queries.sql
-- MemSQL load-balanced failover
-- =============================
-- Queries demoing load-balanced failover in MemSQL: https://youtu.be/J86fLCMr5dc
create database x_db partitions 8;
select host, port, node_id, availability_group as AG from leaves order by AG;
SELECT master_host as m_host, master_port as m_port, host as repl_host, port as repl_port, GROUP_CONCAT(database_name ORDER BY database_name) AS list_partitions FROM information_schema.mv_cluster_status WHERE metadata_role='slave' GROUP BY master_host, master_port, repl_host, repl_port ORDER BY master_host, master_port, repl_host, repl_port;
@robrich
robrich / singlestore-to-gcs.sql
Created March 25, 2021 02:05
SingleStore to Google Cloud Storage
CREATE DATABASE IF NOT EXISTS acme;
USE acme;
CREATE TABLE IF NOT EXISTS messages (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
content varchar(300) NOT NULL,
createdate TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP
);
@robrich
robrich / singlestore-to-s3.sql
Created March 23, 2021 04:45
SingleStore to AWS S3
CREATE DATABASE IF NOT EXISTS acme;
USE acme;
CREATE TABLE IF NOT EXISTS messages (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
content varchar(300) NOT NULL,
createdate TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP
);
@robrich
robrich / sproc-delimiter.sql
Created February 17, 2021 21:19
SingleStore Stored Procedures
CREATE DATABASE IF NOT EXISTS acme;
USE acme;
CREATE TABLE IF NOT EXISTS messages (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
content varchar(300) NOT NULL,
createdate TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP
);
@robrich
robrich / select-into-var.sql
Created February 16, 2021 00:13
SQL Programmability with variables in SingleStore
CREATE DATABASE IF NOT EXISTS acme;
USE acme;
CREATE TABLE IF NOT EXISTS messages (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
content varchar(300) NOT NULL,
createdate TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP
);