Skip to content

Instantly share code, notes, and snippets.

View gmalysa's full-sized avatar

Greg Malysa gmalysa

View GitHub Profile
@gmalysa
gmalysa / fhdl_season1_analysis.c
Created May 26, 2021 20:48
FHDL Player and Captain Analysis
#include <string.h>
#include <stdio.h>
#include <stdint.h>
struct team {
const char *captain;
int32_t cap_mmr;
int32_t cash;
};
#include <zmq.h>
int main(void) {
void *context = zmq_ctx_new();
void *sock = zmq_socket(context, ZMQ_REQ);
zmq_connect(sock, "tcp://localhost:5999");
@gmalysa
gmalysa / steam-client.js
Created April 3, 2019 19:59
With node-dota2/node-steam, you need an updated list of steam login servers, because the server list that ships with node-steam is like 9 months out of date. Periodically should also rebuild this list.
const steam = require('steam');
const steamClient = new steam.SteamClient();
const steamUser = new steam.SteamUser(steamClient);
const dota2 = require('dota2');
const dotaClient = new dota2.Dota2Client(steamClient, true);
if (fs.existsSync('steam-servers.json')) {
steam.servers = JSON.parse(fs.readFileSync('steam-servers.json'));
}
<?php
/**
* Convert a series of TIFF files given on the command line to pages in
* a single PDF
*/
if ($argc < 3) {
echo ('Convert a series of TIFF images as individual pages in a PDF');
echo ("\n".'Usage: php -f pdf_convert.php <output name> <input 1> <input 2> ...');
exit(0);
(defvar friends (evar friends '()))
(defvar enemies (evar enemies '()))
(defun start
(say "Halt, who goes there?")
(add-response "A friend." add-friend)
(add-response "An enemy." add-enemy))
(defun add-friend
(set-var! friends (cons (get-name character) friends))
command! -complete=shellcmd -nargs=+ Shell call s:RunShellCommand(<q-args>)
function! s:RunShellCommand(cmdline)
echo a:cmdline
let expanded_cmdline = a:cmdline
for part in split(a:cmdline, ' ')
if part[0] =~ '\v[%#<]'
let expanded_part = fnameescape(expand(part))
let expanded_cmdline = substitute(expanded_cmdline, part, expanded_part, '')
endif
endfor
WELL = require('well-rng');
_ = require('underscore');
loop_count = 1000;
burn_count = 0;
s = [];
for (i = 0; i < 32; ++i) {
s[i] = 0;
}
@gmalysa
gmalysa / opt_test.js
Last active December 20, 2015 00:59
Test of some simple function optimizations for javascript/nodejs.
// Test 1: Do simple functions get inlined?
var iter = 10000;
var start, stop;
function inc(a) { return a+1; }
// Wrap test in a function to allow warmup of optimizer
function test1_fn(iter) {
var x;
for (var i = 0; i < iter; ++i) {
@gmalysa
gmalysa / gist:5581882
Last active December 17, 2015 08:39
Quick benchmark test for comparing flux-link to some standard async packages that are commonly used
Results:
Promise overhead (calling one after another) x1000:
1: 65ms Base (plain Node.js lstat call)
2: 75ms When: Dedicated wrapper
3: 86ms flux-link
4: 97ms Deferred: Dedicated wrapper
5: 102ms Deferred: Promisify (generic wrapper)
6: 135ms jQuery.Deferred: Dedicated wrapper
7: 1055ms Q: Dedicated wrapper