Skip to content

Instantly share code, notes, and snippets.

View binki's full-sized avatar

Nathan Phillip Brink binki

View GitHub Profile
@binki
binki / MANIFESTO.md
Last active April 16, 2017 03:25
#retrobox remote includes magical linking manifesto

Goals

Clients trust server certificates.

No more self-sighed certs. Use something like LetsEncrypt.

Use “mesh” topology

We currently have “star” topology. That means that when my server goes down everyone suffers. If when my server goes down, other servers

@binki
binki / gist:1b974422b9487c37d33bd63159c8d03c
Last active April 23, 2017 22:22
can you break this code
> function decrypt(s) { return Buffer.from([].slice.call(s).reverse().join('').split(' ').map(s => Number.parseInt(s, 2))).toString(); }
undefined
> decrypt('10100110 10110110 11110110 11001110 10100110 11101110 10000110 00000100 10100110 01001110 10000110 00000100 10101110 11110110 10011010')
'You are awesome'
@binki
binki / ThrottleDemo.cs
Last active May 11, 2017 15:32 — forked from AArnott/ThrottleDemo.cs
Demonstrates scheduling unbounded work and applying a throttle to keep the threadpool responsive.
using System;
using System.Diagnostics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
class Program
{
static void Main(string[] args)
{
@binki
binki / Program.cs
Last active May 24, 2017 16:24
SqlCommand does read OUTPUT from stored procedure even when RAISERROR
using System;
using System.Data;
using System.Data.SqlClient;
class Program
{
static void Main(string[] args)
{
using (SqlConnection connection = new SqlConnection(new SqlConnectionStringBuilder
{
SCGI: A Simple Common Gateway Interface alternative
Neil Schemenauer <[email protected]>
2008-06-23
1. Introduction
The SCGI protocol is a replacement for the Common Gateway Interface
(CGI) protocol. It is a standard for applications to interface with
HTTP servers. It is similar to FastCGI but is designed to be easier
to implement.
@binki
binki / httpd-scgi-autolaunch.md
Created May 27, 2017 16:45
Convention for launching SCGI applications and managing lifetimes

Status

Incomplete. I just posted to save my progress, probably completely wrong still…

Introduction

CGI (Common Gateway Interface) has been around for a long time and is considered a standard for server-side dynamic content generation. CGI provides a mapping from URI to a script stored on a filesystem and a protocol for activating the script, sending the client’s request, and returning the script’s response to the client. CGI communicates headers and request information to the script by setting well known environment variables and executes it to activate it. This results in different types of overhead: concurrent requests require multiple processes and each request requires a fork(), exec(), and quite likely a script interpreter which may need to consume many resources before being able to respond to the request.

@binki
binki / index.js
Last active July 12, 2017 18:10
Subtle behavior change in primitive-enum with Enum.defaultArrayTransform
#!/usr/bin/env node
if (process.env.different === '1') {
require('./mod2');
}
const mod1 = require('./mod1');
const mod2 = require('./mod2');
console.log(mod1.enum1+'');
console.log(mod2.enum2+'');
@binki
binki / gist:78301b60663b0aba627cde22e67a477b
Last active July 19, 2017 21:18
Demonstration of &#xd;
Mono C# Shell, type "help;" for help
Enter statements below.
csharp> LoadAssembly("System.Xml.Linq");
csharp> using System.Xml.Linq;
csharp> (int)XElement.Parse("<x xml:space=\"preserve\">&#xd;</x>").Value[0]
13
csharp> (int)XElement.Parse("<x xml:space=\"preserve\">&#13;</x>").Value[0]
13
@binki
binki / shell-transcript.txt
Created July 24, 2017 14:28
“a” is an invalid decimal value
ohnobinki@gibby ~ $ echo '<x>&#a;</x>' | xmllint -
-:1: parser error : CharRef: invalid decimal value
<x>&#a;</x>
^
-:1: parser error : xmlParseCharRef: invalid xmlChar value 0
<x>&#a;</x>
^
const fs = require('fs');
module.exports = function writeFileSafely(tempPath, destPath, contents, callback) {
fs.open(tempPath, 'w', function (err, fd) {
if (err) {
callback(err);
} else {
fs.createWriteStream(null, {
fd: fd,
autoClose: false,
}).on('error', function (err) {