hashes

C# hashes

I'm new to C# How do i hash files with C# What is available ? (md5, crc, sha1, etc) Is there an interface i should inherit? Basically i want to checksum multiple files and store it in a db along with using two of my own checksums/hashes. ...

How can I sort a hash of hashes by key in Perl?

I want to sort a hash which actually has a hash as a value. For instance: my %hash1=( field1=>"", field2=>"", count=>0, ); my %hash2; $hash2{"asd"}={%hash1}; and I inserted lots of hashes to %hash2 with different count values of %hash2. How can I sort the %hash1 according to a count value of hash1? Is there a way of doing ...

How can SHA encryption be possible?

Duplicate: Confused about hashes How can SHA encryption create unique 40 character hash for any string, when there are n infinite number of possible input strings but only a finite number of 40 character hashes? ...

Ruby/Rails 1&2: collection problem

Hey, I just began to learn ruby/rails. At the moment, I try to do an example of a german book "Praxiswissen Ruby on Rails", which is pretty old and written for Ruby on Rails 1. Anyway, I tried to do the examples with Rails 2. Now I have had problem for over a week. According to the book (Rails 1) I have to write in my controller: pa...

How to get to my anonymous arrays?

The following code generates a list of average number of clients connected by subnet. Currently I have to pipe it through sort|uniq|grep -v HASH. Trying to keep it all in perl this doesn't work: foreach $subnet (keys %{keys %{keys %days}}) { print "$subnet\n"; } Source is this: foreach $file (@ARGV) { open(FH, $file) ...

how can I simply merge a hash into a new one?

I have a simple hash like so { "1234" => "5", "2345" => "6" } How can I create a new hash with both the keys and values in side it? Like so: { key_id = "1234", value_id = "5" }, { key_id = "2345", value_id = "6" } ...

How can I reference a hash with a variable name?

I have three hashes named %hash1, %hash2, %hash3. I need to reference each hash by variable and am not sure how to do it. #!/usr/bin/perl # Hashes %hash1, %hash2, %hash3 are populated with data. @hashes = qw(hash1 hash2 hash3); foreach $hash(@hashes){ foreach $key(keys $$hash){ .. Do something with the hash key and value...

Good numeric hashes

Hi, I'm looking to hash a string but I need the output to be an integer so I can't do md5. Do people here have any favorite numeric hashes that they might want to enlighten me with. I'm using PHP. Thanks! ...

Java (6) Hash & Array alternatives that behave more like their Ruby counterparts

Having been spoiled by ruby for so long, I now find myself having to do some Java development (Eclipse RCP). I'm wondering if anyone knows of alternatives to HashMap & ArrayList that have some of the sugar of ruby. The verbosity of dealing with an ArrayList of HashMaps drives me bonkers. I'm also interested in finding other Ruby langua...

Populating an array of hashes with arrays of hashes

I am currently developing a piece of monitoring software that takes an input file of server names and ip addresses and creates a rudimentary database of information. I want to default some values as it processes the config file and it works fine for the first time round the loop but any subsequent entries get created with weird (well wei...

Merging contents of array / hash (keys and contents) in Ruby

Arg! Someone replied with an answer, just as I edited the below! So I've put it back to what I had before. ** Original array setup ** myArray = [{"papers"=>[[1,2,3],[1,3,2]], "value"=>"1"}, {"papers"=>[[2,1,3],[2,3,1]], "value"=>"1"}, {"papers"=>[[1,2,3],[1,3,2]], "value"=>"0.5"}] I need to merge the contents ...

What is the proper syntax for storing an array into a Perl hash?

I'm creating a new object like this: TestObject->new(@array1, @array2) My new method looks like this: sub new { my $class = shift; my $self = {}; my $self->{Array1} = shift; my $self->{Array2} = shift; bless($self, $class); return $self; } As a simple test to access the data, I'm trying this, and then once I get it w...

Ruby Array group and average by hour

We get our data from a sensor which records and stores data like hashes. At any time it measures a few stuff like that: {:temperature => 30, :pression => 100, :recorded_at => 14:34:23} {:temperature => 30, :pression => 101, :recorded_at => 14:34:53} {:temperature => 31, :pression => 102, :recorded_at => 14:34:24} {:temperature => 30, :p...

How can I make a Perl hash from an array with the keys and another array with the values?

In Perl, how do I make hash from arrays @A and @B having equal number of elements? The goal is to have each value of @A as key to value in @B. The resulting hash %C would,then make it possible to uniquely identify an element from @B supplying key from @A. ...

How do I print a hash structure in Perl?

Examples: %hash = (2010 => 21, 2009=> 9); $hash = { a => { 0 => {test => 1}, 1 => {test => 2}, 2 => {test => 3}, 3 => {test => 4}, }, }; How do I print the hash? ...

MySQL Unique hash insertion

So, imagine a mysql table with a few simple columns, an auto increment, and a hash (varchar, UNIQUE). Is it possible to give mysql a query that will add a column, and generate a unique hash without multiple queries? Currently, the only way I can think of to achieve this is with a while, which I worry would become more and more processo...

Remove/squash entries in a vertical hash

I have a grid that represents an X, Y matrix, stored as a hash here. Some points on the X Y matrix may have values (as type string), and some may not. A typical grid could look like this: {[9, 5]=>"Alaina", [10, 3]=>"Courtney", [11, 1]=>"Gladys", [8, 7]=>"Alford", [14, 11]=>"Lesley", [17, 2]=>"Lawson", [0, 5]=>"Katrine", [2, 1]=>"Tyra...

How can I maintain a sorted hash in Perl?

@aoh =( { 3 => 15, 4 => 8, 5 => 9, }, { 3 => 11, 4 => 25, 5 => 6, }, { 3 => 5, 4 => 18, 5 => 5, }, { 0 => 16, 1 => 11, 2 => 7, }, { 0 => 21, 1 => 13, 2 => 31, }, { ...

Convert byte array to understandable String

I have a program that handles byte arrays in Java, and now I would like to write this into a XML file. However, I am unsure as to how I can convert the following byte array into a sensible String to write to a file. Assuming that it was Unicode characters I attempted the following code: String temp = new String(encodedBytes, "UTF-8"); ...

javascript apply #hash to all links

How can I append #somehash to all links on a page without depending on a JS framework? Or is it possible to catch when someone clicks on a link and attach #somehash? ...