Skip to content

Instantly share code, notes, and snippets.

🐢
Moving slowly and fixing things

Matt Stancliff mattsta

🐢
Moving slowly and fixing things
Block or report user

Report or block mattsta

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mattsta
mattsta / hundreds.erl
Last active Aug 29, 2015
This is an erlang version of https://gist.github.com/gigamonkey/6249d85021bc8bf54eb4 (with a minor change to 'combos'/'combineAdjacent' for easier reading)
View hundreds.erl
#!/usr/bin/env escript
% Problem statement:
% Write a program that outputs all possibilities to put + or - or nothing between the
% numbers 1, 2, ..., 9 (in this order) such that the result is always 100.
% For example: 1 + 2 + 34 – 5 + 67 – 8 + 9 = 100.
% Generate all combos of digits 1-9 with +, -, or nothing in between.
combos([N]) -> [[N]];
combos([N|Ns]) -> [[N, X] ++ Rest || X <- [plus, minus, empty], Rest <- combos(Ns)].
@mattsta
mattsta / reformatted.hs
Created Feb 23, 2015
commandstats reformatted
View reformatted.hs
{'ver': {'status': 'UNKNOWN', 'version': ''}}
{'cmds': {'sorted by calls': [{'get': '158,696,585 times'},
{'set': '71,614,064 times'},
{'ping': '23,045,904 times'},
{'exists': '1,425,952 times'},
{'info': '1,403,483 times'},
{'replconf': '1,370,802 times'},
{'mget': '700,439 times'},
{'del': '163,092 times'},
{'setex': '139 times'},
@mattsta
mattsta / mem_size_bench.c
Created Dec 20, 2014
benchmark memory operations from small 32 bytes to 4+ MB. results reported as factional nanoseconds.
View mem_size_bench.c
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <string.h>
static long long ustime(void) {
struct timeval tv;
long long ust;
gettimeofday(&tv, NULL);
View gist:8810a0cdf18f45875ebf
* THIS CONVERSATION IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS CONVERSATION, EVEN IF ADVISED OF THE
@mattsta
mattsta / thing.hs
Created Dec 3, 2014
Script/Non-Script Speeds
View thing.hs
127.0.0.1:6379> script load "return redis.call('georadius', '{global}:z:locations:'..ARGV[1], ARGV[2], ARGV[3], 10, 'km', 'withdistance', 'ascending')"
"1c4c03da2a57cf99d50d57aba9a1d431526b2b9e"
127.0.0.1:6379> script load "return redis.call('get', 'abc')"
"b86fdf4c29439ed5d9a52c206d90e2b2d8cfc42c"
Geo tests (key doesn't exist, so just testing getting an empty reply):
matt@ununoctium:~/repos/redis/src% redis-benchmark -n 10000 georadius {global}:z:locations:u1 51.0500000 3.7166700 10 km withdistance ascending
====== georadius {global}:z:locations:u1 51.0500000 3.7166700 10 km withdistance ascending ======
10000 requests completed in 0.08 seconds
@mattsta
mattsta / soooooon.t
Created Nov 16, 2014
DEBUG JEMALLOC INFO
View soooooon.t
matt@ununoctium:~/repos/redis/src% ./redis-cli -p 6379 debug jemalloc info
___ Begin jemalloc statistics ___
Version: 3.6.0-0-g46c0af68bd248b04df75e4f92d5fb804c3d75340
Assertions disabled
Run-time option settings:
opt.abort: false
opt.lg_chunk: 22
opt.dss: "secondary"
opt.narenas: 32
opt.lg_dirty_mult: 3
@mattsta
mattsta / timcook
Last active Aug 29, 2015
word frequency analysis of https://news.ycombinator.com/item?id=8532261 (when it had 641 comments (see history for earlier versions))
View timcook
% ./text.py timcook-hn-at-641-comments
===============================================================================
Count of sentence ending words:
55: it.
29: gay.
27: people.
23: that.
@mattsta
mattsta / mergables
Created Oct 29, 2014
things in my hidden merge branch
View mergables
Author: Matt Stancliff <matt@genges.com>
Date: Mon Oct 20 13:07:06 2014 -0500
Add dynamic proctitle support
Uses new anet IP formatting to show proper IPv4 vs IPv6 results too.
Closes #2081
Author: Matt Stancliff <matt@genges.com>
Date: Mon Oct 20 10:39:11 2014 -0400
@mattsta
mattsta / redis-demo.service
Created Oct 21, 2014
redis systemd voodoo
View redis-demo.service
[Unit]
Description=Redis Demo
After=network.target
[Service]
# Port 0 stops Redis from listening to ports by itself
ExecStart=/home/matt/repos/redis/src/redis-server --dir /tmp --port 0
PrivateTmp=yes
# Redis requires non-blocking sockets or else _nothing_ works
@mattsta
mattsta / nginx.config.nice
Last active Aug 29, 2015
hack at me, bro
View nginx.config.nice
/usr/local/src/web/nginx-1.7.6% cat config.nice
./configure --prefix=/sw --with-http_perl_module --with-ipv6 --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_geoip_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-pcre=../../libs/pcre-7.9/ --add-module=../nginx-upload-module/ --with-http_spdy_module --with-openssl=/usr/local/src/sys/openssl-1.0.1j
You can’t perform that action at this time.