This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
chunked_server_test.py | |
Copyright August 3, 2012 | |
Released into the public domain | |
This implements a chunked server using Python threads and the built-in | |
BaseHTTPServer module. Enable gzip compression at your own peril - web | |
browsers seem to have issues, though wget, curl, Python's urllib2, my own | |
async_http library, and other command-line tools have no problems. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
This is an implementation of the Recursive Division algorithm for maze | |
generation, primarily derived from the algorithm presented here: | |
http://weblog.jamisbuck.org/2011/1/12/maze-generation-recursive-division-algorithm | |
The input grid can be generated via: | |
grid = [width*[0] for i in xrange(height)] | |
The initial call should be of the form: | |
divide(grid, 0, 0, width, height) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
one_bit_difference.py | |
Written September / October 2023 by Josiah Carlson - josiah.carlson@gmail.com | |
Released into the public domain. Please include this authorship note / reference | |
to this GIST if you use / derive this software. Thank you. | |
Been thinking about this algorithm for about 17 years, haven't seen it around. | |
I might not know the proper literature search to find relevant references, or if | |
this was already done. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- keys: key dest | |
-- argv: score member [score member ...] | |
-- e.g. keys: "data:test:1:2" "data-sum:test:1:2" | |
-- argv: 10 a 15 b | |
local key = KEYS[1] | |
local dest = KEYS[2] | |
local sum = tonumber(redis.call('get', dest)) or 0 | |
for i=1, #ARGV, 2 do |
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 1 column, instead of 4. in line 1.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ time docker-compose run redis-server numactl -N 1 -l /usr/src/redis/src/redis-benchmark --crc 512000000 --csv --combine | |
algorithm,buffer,performance,crc64_matches | |
crc_1byte,512000000,400,1 | |
crcspeed,512000000,1354,1 | |
crcdual,512000000,2129,1 | |
crctri,512000000,2243,1 | |
crc_1byte,312000000,401,1 | |
crcspeed,312000000,1352,1 | |
crcdual,312000000,2090,1 | |
crctri,312000000,2213,1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
redis_search.py | |
Written by Josiah Carlson July 3, 2010 | |
Released into the public domain. | |
This module implements a simple TF/IDF indexing and search algorithm using | |
Redis as a datastore server. The particular algorithm implemented uses the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
This code is derived from: http://code.activestate.com/recipes/576944/ | |
It was released under the MIT license. | |
I (Josiah Carlson) have modified it to be correct in more cases, and to report | |
errors in some error cases. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'''pass_socket.py | |
Written September 14, 2012 | |
Released into the public domain. | |
Works on Python 2.6, 2.7, and may need minor changes for 3+. | |
''' | |
import multiprocessing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
sort_zset_cols.py | |
Copyright 2013 Josiah Carlson | |
Released into the public domain. | |
''' | |
''' | |
Let's imagine that there are 3 restaurants with price, score, distance info | |
being: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
rate_limit2.py | |
Copyright 2014, Josiah Carlson - josiah.carlson@gmail.com | |
Released under the MIT license | |
This module intends to show how to perform standard and sliding-window rate | |
limits as a companion to the two articles posted on Binpress entitled | |
"Introduction to rate limiting with Redis", parts 1 and 2: |
NewerOlder