Skip to content

Instantly share code, notes, and snippets.

View Jimbly's full-sized avatar

Jimb Esser Jimbly

View GitHub Profile
@Jimbly
Jimbly / asyncThreadPoolTest.cpp
Last active January 22, 2025 09:25
condition_variable deadlock
#define dbgprint(...) async_mem_log.print(__VA_ARGS__)
#include "utilUtils.h"
#include "utilRand.h"
#include "utilTime.h"
void asyncThreadPoolTest()
{
static auto one_ms = std::chrono::milliseconds(1);
int threads = 6;
std::vector< std::thread > workers;
int queued_tasks = 0;
@Jimbly
Jimbly / Solution.js
Last active April 7, 2018 23:35
Simplified GoogleCodeJam Javascript stdio tokenizer
'use strict';
// Does not work on Google's servers, try stdio-async instead
const fs = require('fs');
let tok = (function () {
let buffer = Buffer.alloc(1);
function getc() {
while (true) {
try {
let bytes_read = fs.readSync(process.stdin.fd, buffer, 0, 1);
@Jimbly
Jimbly / index.js
Last active July 1, 2024 17:00
Steam CD Key Batch query
/* jshint esversion: 6*/
const assert = require('assert');
const async = require('async');
const fs = require('fs');
let request = require('request');
const FileCookieStore = require('tough-cookie-filestore');
if (!fs.existsSync('cookies.json')) { fs.writeFileSync('cookies.json', '{}'); }
let j = request.jar(new FileCookieStore('cookies.json'));
request = request.defaults({ jar : j });
FROM buildpack-deps:jessie-curl
RUN set -ex; \
apt-get update && apt-get install --force-yes -y --no-install-recommends \
git-core \
build-essential \
libxml2-dev uuid-dev \
libssl-dev bash patch make tar xz-utils bzip2 gzip sed cpio python \
&& rm -rf /var/lib/apt/lists/* && \
# Install version matching latest 32-bit CMake
wget -q --no-check-certificate https://cmake.org/files/v3.6/cmake-3.6.3-Linux-x86_64.tar.gz && \
let pos = [
[0, 0],
[-35, -12],
[-50, -50],
[-80, -40],
[-50, 50],
[0, -66],
[35, -35],
[68, -50],
[70, -4],
@Jimbly
Jimbly / codejam.js
Last active January 8, 2017 19:07
Generic parallel CodeJam Problem Runner
/*
* This file contains the generic file loading, test parsing, dispatching code
* used in all of my solutions, other than the last lines specifying which problem module
* and possibly different delimiters being used, this file remains unchanged.
*/
'use strict';
var assert = require('assert');
var child_process = require('child_process');
var fs = require('fs');
GOOD
Client :: ready
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to localhost [127.0.0.1] port 22.
debug1: Connection established.
debug1: identity file /home/mscdex/.ssh/id_rsa type -1
debug1: identity file /home/mscdex/.ssh/id_rsa-cert type -1
GOOD
DEBUG: Local ident: 'SSH-2.0-ssh2js0.0.18'
DEBUG: Client: Trying staging.dashingstrike.com on port 22 ...
DEBUG: Client: Connected
DEBUG: Parser: IN_INIT
DEBUG: Parser: IN_GREETING
DEBUG: Parser: IN_HEADER
DEBUG: Remote ident: 'SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.3'
DEBUG: Outgoing: Writing KEXINIT
DEBUG: Parser: IN_PACKETBEFORE (expecting 8)
@Jimbly
Jimbly / gist:ec6126da15bf0e6f9a63
Created February 12, 2015 19:13
PROXY protocol preparse event
function requestPreParse(preparse_params) {
// Requires https://github.com/Jimbly/node/commit/e8952eb
// and https://github.com/Jimbly/node/commit/13cfb39
var data = preparse_params.preparse_data;
if (!data.did_haproxy || (data.is_haproxy && !data.did_haproxy_data)) {
var len = preparse_params.end - preparse_params.start;
if (len >= 6) {
data.did_haproxy = true;
if (preparse_params.d.toString('utf8', preparse_params.start, preparse_params.start + 6) === 'PROXY ') {
data.is_haproxy = true;
@Jimbly
Jimbly / webroot.js
Last active March 13, 2019 17:38
Node.js app combining virtual hosts, proxies, mapped subdirectores, and static sites, with WebSockets support.
// Companion Blog Post about architecture:
// http://jimbesser.wordpress.com/2014/10/20/its-node-js-all-the-way-down/
// Companion Blog Post about dealing with legacy requests:
// http://jimbesser.wordpress.com/2014/11/29/the-horrible-things-peoples-routers-do-to-my-packets/
//
// Routing handled by this app:
// [www.]bigscreensmallgames.com -> static site: /var/data/smb_web/bigscreensmallgames.com/
// fanime.info -> node app running entire site on port 4001
// [default site]/app1: replace URL and redirect to single page app on 192.168.0.127:21022
// [default site] -> static site: /var/data/smb_web/dashingstrike.com/