Skip to content

Instantly share code, notes, and snippets.

View antirez's full-sized avatar

Salvatore Sanfilippo antirez

View GitHub Profile
./redis-cli latency graph aof-write
aof-write - high 16 ms, low 1 ms (all time high 16 ms)
--------------------------------------------------------------------------------
_
_####### _#### #_ #o_# |
o__________o_ _oo|||||||| _o____o_ ___ooo__ _______o__|||||#||#|||| | ___ _ ___
|||||||||||||#|||||||||||_#||||||||#||||||||#|||||||||||||||||||||||_|o|||#|#|||
44444444444444444444444442222222222222222221111111111111111111111111111111111111
mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
$LOAD_PATH.unshift("./lib")
require './lib/redis.rb'
Sentinels = [{:host => "127.0.0.1", :port => 26380},
{:host => "127.0.0.1", :port => 26381}]
r = Redis.new(:url => "sentinel://mymaster", :sentinels => Sentinels, :role => :master)
r.ping
(0..1000000).each{|i|
begin
@antirez
antirez / gist:11365598
Created April 28, 2014 08:36
Heimdall S4 baseband upgrade to install 4.4.2
WARNING: You can brick your phone, follow this steps at your risk.
With older basebands 4.4.2 has issues with the network, so a baseband update is required.
If you don't want to touch Windows / Odin for this, this has worked for me, since the vanilly "run" failed to upgrade the baseband file. Basically the trick is, for some obscure reason, to upgrade the baseband two times in a row.
1) Use Heimdall v1.4.0
2) Flast first time with: heimdall flash --MDM modem.bin (Obtained from baseband file modem_XXUFNB8.tar)
3) When the device reboots, press volume down AGAIN to enter Download/Odin mode again.
4) Flash again with: heimdall flash --MDM modem.bin --no-reboot
@antirez
antirez / gist:11255064
Created April 24, 2014 13:42
lock_test.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/file.h>
#include <errno.h>
void lockFile(char *filename) {
int fd;
/* To lock it, we need to open the file in a way it is created if
<?
require("redis.php");
require("json.php");
$term = $_GET['term'];
$r = new Redis("127.0.0.1","6379");
$r->connect();
$items = $r->zrangebylex("kernel","[$term","[$term\xff",Array("LIMIT","0","10"));
127.0.0.1:6379> pfadd hll 1 2 3 4 5 6
(integer) 1
127.0.0.1:6379> pfdebug decode hll
"Z:495 v:2,1 Z:2084 v:1,1 Z:4946 v:1,1 Z:3445 v:1,1 Z:4397 v:4,1 Z:208 v:2,1 Z:803"
cardinality 1 uses 5 bytes (0.00244140625 bits per register})
cardinality 10 uses 31 bytes (0.01513671875 bits per register})
cardinality 100 uses 271 bytes (0.13232421875 bits per register})
cardinality 1000 uses 1906 bytes (0.9306640625 bits per register})
cardinality 2000 uses 3517 bytes (1.71728515625 bits per register})
cardinality 3000 uses 4918 bytes (2.4013671875 bits per register})
cardinality 4000 uses 6129 bytes (2.99267578125 bits per register})
cardinality 5000 uses 7206 bytes (3.5185546875 bits per register})
cardinality 6000 uses 8099 bytes (3.95458984375 bits per register})
cardinality 7000 uses 8868 bytes (4.330078125 bits per register})
127.0.0.1:6379> zrangebylex words [anter + LIMIT 0 10
1) "anterior"
2) "anteriorly"
3) "anteroom"
4) "anterooms"
5) "antes"
6) "anthem"
7) "anthemed"
8) "anthems"
9) "anther"
require 'rubygems'
require 'redis'
r = Redis.new
r.config("SET","maxmemory","2000000")
r.config("SET","maxmemory-policy","allkeys-lru")
r.config("SET","maxmemory-samples",1000)
r.config("RESETSTAT")
r.flushall
redis-cli -c -p 7000 :3.0:
redis 192.168.1.10:7000> set foo bar
-> Redirected to slot [12182] located at 192.168.1.11:7001
OK
redis 192.168.1.11:7001>