hash

Mysql Partition : how to deal with month and hash

Hi all, I have a specific question on mysql sub-partitioning using hash on a date/datetime column. I have partitioned by site_id, and I want now to subpartitioned by month (1 to 12), so the partitions number is fixed in time (sp_dec, sp_jan, ...) Current cut (columns and other partitions) table structure : CREATE TABLE IF NOT EXISTS `...

Is there a gentle hash function tutorial?

Embarrassingly, picking a hash function (say, for hashing strings, or sets of integers, etc.) is still magic to me: take some prime numbers here, magic constants there, do some bit shifting, modulo something, and done. Is there a nice, gentle and approachable tutorial about creating hash functions? ...

How can I reset a hash completely without using a for loop?

I would like to completely reset my %hash so that it does not contain keys or values at all. I prefer to use a one-liner than have to use a loop. So far I have tried: %hash = 0; %hash = undef; But these both throw errors in strict mode with warnings enabled, so I wrote a simple for loop to achieve the same thing: for (keys %hash) { ...

generating MD5 hash of a text with C#

I understand that System.Security.Cryptography has a MD5 hashing method in MD5.ComputeHash. However, the method takes and returns bytes. I don't understand how to work with this method using String key and hashes. I try to work around by doing this, var hash = MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(@"text".ToCharArray())); for...

How to access AJAX hash values in ASP.NET MVC?

I'm considering using the hash method to create static urls to content that is managed by ajax calls in a Asp.Net MVC. The proof of concept i'm working on is a profile page /user/profile where one can browse and edit different sections. You could always ask for the following url /user/profile#password to access directly to you profile pa...

Accessing an array within a hash - Ruby

Hello, I'm writing an application that pulls values out of an excel spreadsheet and then stores those values in a hash using the version number as a key. Everything seems to be working correctly until I try and retrieve the information from the hash. Here is the code that builds the hash. @version_numbers.each do |version| user_var...

Generating SHA-256 hash in Python 2.4 using M2Crypto

Is it possible to generate a SHA-256 hash using M2Crypto? Python 2.4's SHA module doesn't support 256, so I started using PyCrypto, only to find out that PyCrypto doesn't support PKCS#5 (needed elsewhere in my project.) I switched to M2Crypto as a result and now I would like to replace my PyCrypto SHA-256 call with an M2Crypto equivale...

hash table for finding sum

Given an array of integers and another integer X - create an algorithm to determine if the sum of any two integers in the array would result in x. I was asked to use hash tables for this. The solution is create a hash table with the array of integers and set the data to one. Access the hash table with keyvalue x-arr[i] and check if data...

Marshal ruby hash with default proc - remove the default proc?

I've got a Hash with a default proc that I'd like to to Marshal to a file, but the default proc prevents me from doing that. Rather than writing my own _dump and _load methods, is it possible instead to remove the default_proc instead? At the point where I'm Marshalling I'm never going to need the default_proc again. ...

Is there a function that takes two values, lets f(x,y) == f(y,x), and the output is otherwise unique?

Hi, I am wondering if there is a way to generate a key based on the relationship between two entities in a way that the key for relationship a->b is the same as the key for relationship b->a. Desirably this would be a hash function which takes either relationship member but generates the same output regardless of the order the members ...

Am I using PHP's crypt() function correctly?

I've been using PHP's crypt() as a way to store and verify passwords in my database. I use hashing for other things, but crypt() for passwords. The documentation isn't that good and there seems to be a lot of debate. I'm using blowfish and two salts to crypt a password and store it in the database. Before I would store the salt and the e...

How to stop browser window from jumping on a #ID hash link - simplest javascript required

Hi guys, Got a client who is strictly no javascript, but in this particular circumstance, I don't think I can avoid it. I've got a "next / previous" featured area situation going on using CSS (overflow: hidden and position: absolute) - where the click next or previous (a href="#section...") then brings the relevant div ID into view -but...

Storing a hash as byte array with JPA

My User entity class contains password hash field, which is a byte array with a fixed length (32 since it's an SHA-256 hash). @Entity public class User { @Column(nullable=false) private byte[] passwordHash; ... } As you can see, I haven't annotated it with anything special, just a NOT NULL. This works, but will it perform...

Iterate hash for specific range ..

How to pass range in hash to iterate from index 1 to last? h = {} h[1..-1].each_pair do |key,value| puts "#{key} = #{value} end This code returning error. how may i pass range in hash ?? EDIT: I want to print first key and value without any calculations. From second key and value i want to do some calculation on my hash. For th...

Is it safe to use the "hash" method to track NSURLConnections in memory?

My question is related to this discussion: http://www.cocoabuilder.com/archive/cocoa/202211-how-to-get-nsurl-form-nsurlconnection.html I am sending several NSURLConnections to transmit data and need to be able to tell which specific connection failed or succeeded. There are NSURLDelegate methods (didFailWithError, etc) which return the ...

ruby Hash include another hash, deep check

Hi guyes, what is the best way to make such deep check: {:a => 1, :b => {:c => 2, :f => 3, :d => 4}}.include?({:b => {:c => 2, :f => 3}}) #=> true thanks ...

How would I break up and extract an array from an array-of-hashes in Ruby on Rails?

for example: [ (id=>1, email=>'[email protected]', name=>'tim'), (id=>2, email=>'[email protected]', name=>'joe'), (id=>3, email=>'[email protected]', name=>'dan') ] How can I extract the email column and put it in its own array? ...

How do people do this: http://mysite.com/#/page-name

I want to use deep linking on my site using this url method, but I'm not sure how it works. When I set my links to work like this: <a href="/#/page">stuff</a> the browser doesn't put it in the window location bar. Ideas? ...

Should I choose a hash, an object or an array to represent a data instance in Perl?

I was always wondering about this, but never really looked thoroughly into it. The situation is like this: I have a relatively large set of data instances. Each instance has the same set or properties, e.g: # a child instance name age height weight hair_color favorite_color list_of_hobbies Usually I would represent a child as a hash ...

[iPhone] hash a password string using SHA512 like C#

Dear All, I am developing logon function for my iPhone Application, so I want to hash the password using the SHA512 hashing algorithm then get the result as NSString (the result should be the same with SHA512 in C#). After spending a lot of time in the internet, I still not find out the solution yet! :( Is there anyone has the solution...