Skip to content

Instantly share code, notes, and snippets.

View jzawodn's full-sized avatar

Jeremy Zawodny jzawodn

View GitHub Profile
@jzawodn
jzawodn / lmdb.tcl
Created May 18, 2023 17:11 — forked from antirez/lmdb.tcl
LMDB -- First version of Redis written in Tcl
# LVDB - LLOOGG Memory DB
# Copyriht (C) 2009 Salvatore Sanfilippo <[email protected]>
# All Rights Reserved
# TODO
# - cron with cleanup of timedout clients, automatic dump
# - the dump should use array startsearch to write it line by line
# and may just use gets to read element by element and load the whole state.
# - 'help','stopserver','saveandstopserver','save','load','reset','keys' commands.
# - ttl with milliseconds resolution 'ttl a 1000'. Check ttl in dump!
#define _GNU_SOURCE
#include <errno.h>
#include <sched.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/types.h>
@jzawodn
jzawodn / Turn CAPSLOCK to Ctrl.reg
Created July 1, 2018 16:50 — forked from krists/Turn CAPSLOCK to Ctrl.reg
Remap Caps-Lock key to Ctrl in Windows 7/8
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00
@jzawodn
jzawodn / gist:8cc6365e8bcecba9b0bb
Created November 7, 2014 17:58
override Mojo's JSON::XS::encode_json with JSON::XS
sub xs_encode_json {
JSON::XS::encode_json $_[1];
}
{
no warnings;
*Mojo::JSON::encode = \&xs_encode_json;
}
@jzawodn
jzawodn / rt_mem_limit_show_index_status.diff
Created April 4, 2014 18:55
A simple patch to add rt_mem_limit to SHOW INDEX xxx STATUS in sphinx searchd
macbook :: ~/code/sphinxsearch-read-only » svn diff
Index: src/searchd.cpp
===================================================================
--- src/searchd.cpp (revision 4648)
+++ src/searchd.cpp (working copy)
@@ -17303,6 +17303,7 @@
{
tOut.DataTuplet ( "ram_chunk", tStatus.m_iRamChunkSize );
tOut.DataTuplet ( "disk_chunks", tStatus.m_iNumChunks );
+ tOut.DataTuplet ( "mem_limit", tStatus.m_iMemLimit );
@jzawodn
jzawodn / pmp_sphinx.sh
Created July 16, 2013 23:47
pmp for sphinx/searchd
#!/bin/bash
nsamples=1
sleeptime=0
pid=$(pidof -s searchd)
for x in $(seq 1 $nsamples)
do
gdb -ex "set pagination 0" -ex "thread apply all bt" -batch -p $pid
sleep $sleeptime
done | \
@jzawodn
jzawodn / bdb_mysq_leak.pl
Created June 14, 2013 18:33
Demonstrate the leak in DBD::mysql that I noticed. If you fail to connect (down host), the program will leak memory. If you're connecting to a server that's up, there is no leak.
#!/usr/bin/perl -w
use strict;
use warnings;
use feature qw(say);
use DBD::mysql;
my $host = 'dev4h';
my $port = 9307;
my $dsn = "DBI:mysql:host=$host;port=$port";
my $user = 'foo';
@jzawodn
jzawodn / pic-conv.pl
Created November 21, 2012 22:14
Picture Orientation
#!/usr/bin/perl -w
#
# rotate a bunch of images to upright
use strict;
use File::Copy;
use Image::EXIF;
use Data::Dumper;
$|++;
@jzawodn
jzawodn / bench_parens.pl
Created September 25, 2012 03:57
silly benchmark of matching parens
#!/usr/bin/perl
use strict;
use warnings;
use Benchmark qw(:all);
my $string = "foo (bar) and (baz) stuff)";
my $left = 0;
my $right = 0;