Skip to content

Instantly share code, notes, and snippets.

View gmalysa's full-sized avatar

Greg Malysa gmalysa

View GitHub Profile
diff --git a/test/dm/blk.c b/test/dm/blk.c
index aa5cbc63777..704c8e52973 100644
--- a/test/dm/blk.c
+++ b/test/dm/blk.c
@@ -275,6 +275,10 @@ static int dm_test_blk_flags(struct unit_test_state *uts)
ut_asserteq(-ENODEV, blk_next_device_err(BLKF_FIXED, &dev));
/* Look only for removable devices */
+ ut_assertok(blk_find_first(BLKF_REMOVABLE, &dev));
+ ut_assertnonnull(dev);
@gmalysa
gmalysa / arcospheres.c
Last active May 3, 2024 08:55
Calculate Residuals and extra info for Arcosphere Balancing
#include <stdbool.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#define DIM 8
struct vec {
int32_t x[DIM];
};
@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) {