Redis 3.2 feature the geohash type.
GEOADD is used to add keys:
> GEOADD restaurants 32.0 34.0 Falafel
(integer) 1
> GEOADD restaurants 32.1 34.1 Pizza
(integer) 1
GEORADIUS is used to make a geo query:
> GEORADIUS restaurants 32.05 34.05 100 km WITHDIST
1) 1) "Falafel"
2) "7.2230"
2) 1) "Pizza"
2) "7.2213"
However, HDEL does not seem to work:
> HDEL restaurants Falafel
(error) WRONGTYPE Operation against a key holding the wrong kind of value
How do I delete, or set a TTL, to a key within a geo hash?
Geohashes are sorted sets, so the right command is ZREM:
> ZREM restaurants Falafel
(integer) 1
> GEORADIUS restaurants 32.05 34.05 100 km WITHDIST
1) 1) "Pizza"
2) "7.2213"
Related
I am running a diskspace used query in Prometheus and would like to return only the top 5 or 10 entries from the search result. Is there anyway I can achieve that?
Currently, the query I am trying is returning me 58 entries
(100 - 100 * (node_filesystem_avail{device!~"by-uuid",device!~"tmpfs",mountpoint="/"} / node_filesystem_size{device!~"by-uuid",device!~"tmpfs",mountpoint="/"})) > 70
Just add topk(5, ...) in your query:
topk(5, (100 - 100 * (node_filesystem_avail{device!~"by-uuid",device!~"tmpfs",mountpoint="/"} / node_filesystem_size{device!~"by-uuid",device!~"tmpfs",mountpoint="/"})) > 70)
I have a twist on the usual thread. I am working on a labor market where the firm will pick the worker asking for the lower firm out of all close workers until its capital is exhausted or there are no more unemployed workers available.
The problem is, NetLogo min command does not like it when there is only one worker left to choose from. This causes the error message:
MIN expected input to be a list but got the number 98.22043664491966 instead.
the code is as follows:
while [ (capital > min-wage) and (local-number > 2) ] [
let min-worker min-one-of local-unenmp [ salary ]
let wage [salary] of min-worker
ask min-worker [
set unemployed? false
set aggregate-employed (aggregate-employed + 1)
set wealth (wealth + wage)
set labor-check1 (labor-check1 + 1)
set local-unenmp local-unenmp with [self != myself]
set local-number count local-unenmp
]
set working (working + 1)
set capital (capital - wage)
if capital <= min-wage [stop]
if local-number < 3 [stop]
]
set labor working
set labor-check2 (labor-check2 + 1)
]
I have a model where I want to measure the time a turtle takes to travel from from one patch to another given the scale of the map, 'speed' or distance traveled (map scale is 1000m x 1000m per patch for reference), and a desired time that elapses in one tick (in seconds).
I am trying to count the total time it takes using a turtles-own variable called totaltime.
Total time is determined by taking the total number of ticks minus extra ticks and then multiplying it by the time-interval (last line of code).
Extra ticks are counted because the loop has to operate when the ship is moving directly to the center of the patch in the list. this is necessary so the patch can be removed from the list allowing the turtle to search for the next patch in the list and so on (in the ifelse statement).
The use of extra-ticks may be redundant and jumping to exact patch locations may certainly not be the best way to have turtles traverse through a list of patches. Unfortunately I am new to netlogo and don't have a great grasp on the concept of ticks and correct context (turtle, observer, etc). If anyone could help me it would GREATLY appreciated as I have been stuck trying to figure this out for way too long.
> to move
> set speed 40
> set time-interval 1
> set ship-distance (time-interval / 3600) * speed
> set extra-ticks 0
> tick
> ask ships with [length current-path != 0]
> [
> go-to-next-patch-in-current-path
> ]
> end
>
> to go-to-next-patch-in-current-path
> face first current-path
> set total-ticks total-ticks + 1
> ifelse distance first current-path <= ship-distance
> [
> set extra-ticks (1 - (distance first current-path / ship-distance)) + extra-ticks
> print (distance first current-path / ship-distance)
> move-to first current-path
> set current-path remove-item 0 current-path
> ]
> [
> set normal-ticks normal-ticks + 1
> fd ship-distance
> ]
>
> set totaltime (ticks - extra-ticks) * time-interval / 60
> end
I want to compare some strings like this
Previous -> Present
Something like
path 1 : 100 -> 112 --> 333 --> 500
path 2 : 100 -> 333 --> 500
path 3 : 100 -> 333 --> 500 --> 500
path 4 : 100 -> 112 --> 500
I need to compare path 1 with path 2, get the number that was in path 1 which doesn't exist in path 2 and store it in a database
Then compare path 2 with path 3 and do same thing. If it already exists then increment it. Otherwise insert the new number.
I know how to insert into a database and increment if the entry exists. What I don't know is how to loop through all those paths getting those values then deciding whether to insert into the database.
I have done some research, and I have heard of Levenshtein Edit Distance but I can't figure out how I should do it.
Your question appears to be:
Given two lists of numbers, how can I tell which ones in list A aren't in list B?
Hashes are useful for doing set arithmetic.
my #a = ( 100, 112, 333, 500 );
my #b = ( 100, 333, 500 );
my %b = map { $_ => 1 } #b;
my #missing = grep { !$b{$_} } #a;
I'm not sure if this is the right web page to ask...
I have a xyz file I have generated:
C 0 0 0
O 0 0 0.1
O 0 0 0.2
C 0 0 0.6
O 0 0 0.5
O 0 0 0.4
.
.
.
How can I select a specific atom in command line or measure the distance between two atoms (pymol)?
pymol select command is described in detail here:
http://www.pymolwiki.org/index.php/Property_Selectors
In your case, to select certain atom(s), you can use:
select C_atoms, name C # select all C atoms and name the selection C_atoms
select atom_4, id 4 # select the 4th atom in the file and name it atom_4
select idx_4, index 4 #
select rank_4, rank 4 #
as for the difference between rank, ID, index for atoms, see
http://www.mail-archive.com/pymol-users#lists.sourceforge.net/msg08503.html
I have sent an email to the pymol email-list. I need to find the ID of the atom/molecule I want (I'm sure there is a better way but I have used the gui interface) and then:
select id <num>
or
distance id<num>, id<num>
to measure distance