hash

PHP Form Key Niggle ?

Hello again, Can someone look at my two functions below and suggest what i can do?, i have created two functions that basically creates a unique key and this is echoed in a hidden field in a form and then straight after i check if the form has been submitted the second function checks to see if the key in the hidden field matches the ke...

Update URL parameter with javascript, without ruining the history?

I'm looking for a way to update the url in the status bar.. I have a gallery, and when you click your way through the gallery I want the image ID to show up in the URL, so that the user can link directly to the image.. I've read about using hash and so. but as far as I've tried it, that "ruins" the history. If I click the back-button in...

Why the hash part of the URL is not in the server side?

For example if I type in the URL: http://www.foo.com/page.php?parameter=kickme#MOREURL In the server isn't the part: #MOREURL Is possible to send or get these part to the server without jQuery AJAX?. Thanks ...

PHP: fastest hash for non-cryptographic uses?

I'm essentially preparing phrases to be put into the database, they may be malformed so I want to store a short hash of them instead (I will be simply comparing if they exist or not, so hash is ideal). I assume MD5 is fairly slow on 100,000+ requests so I wanted to know what would be the best method to hash the phrases, maybe rolling ou...

[RUBY] DRY way to assign hash values to an object

Hi, I'm looking for a elegant way to assign the value stored inside an Hash into a pre-existed object. Just to be clear, if I have an object, say obj with two attributes, say name and age, I want to assign this values coming from an hash without do something like: obj.name = hash[:name] obj.age = hash[:age] Thanks for your attention...

Create hash using block (Ruby)

Can I create a Ruby Hash from a block? Something like this (although this specifically isn't working): foo = Hash.new do |f| f[:apple] = "red" f[:orange] = "orange" f[:grape] = "purple" end ...

ajax prototype to load page then update hash

hi all, first im sorry about my poor english.. ok, i have 3 page with different concept/layout/animation im use prototype & scriptaculous i have this in my navigation: <ul> <li><a href="#page1" id="page1" onClick="showPage(page1);">PAGE1</a></li> <li><a href="#page2" id="page2" onClick="showPage('page2');">PAGE2</a></li> </ul> and ...

"Array to Hash" transform in Ruby

Hello. I need to transform ["a", "b", "c", "d"] to {:a => {:b => {:c => "d" }}} ? Any ideas ? Thanks ...

How do I make a Perl "array of arrays of hashes"?

I think what I need is an Array of Array of Hash, but I have no idea how to make that. Can Perl do that? And if so, how would the code look like? ...

How do I map unique values from a multi-level array to a hash of value=>array?

I have an array that looks something like this: [[100, "one"], [101, "one"], [102, "one"], [103, "two"], [104, "three"], [105, "three"]] What I would like to do is create an array of hashes that looks like this [{"one" => [100,101,102]}, {"two" => [103]}, {"three" => [104,105]}] The number portion will always be unique, the ...

What's the best way to check for the presence of a hash?

Right now I'm using if(window.location.hash != '') Is this foolproof? Or, is there a way to return a Boolean value instead? ...

How to get the URL's hash/anchor part on server?

My website uses asual address plugin for implementing hash based URLs. I want to implement follwoing feature which facebook and twitter have successfully implemented. Say I am not logged into twitter and click on the below link http://twitter.com/#favorites It will take me to login page(note the /favorites in querystring) http://twitt...

Find number of bytes a particular Hash is using in Ruby

All I want to know is how many bytes Ruby is using for a particular Hash object. How do I do that? ...

Salted hash to be passed through URL for persistent login without cookies

I am producing a script that others will put in their websites. It is designed for people with limited knowledge of PHP so that all they have to do is include() the script and set a few configuration variables. This means headers will probably have been sent already and so using sessions may not work. I recommend they call session_start ...

How can I represent sets in Perl?

I would like to represent a set in Perl. What I usually do is using a hash with some dummy value, e.g.: my %hash=(); $hash{"element1"}=1; $hash{"element5"}=1; Then use if (defined %hash{$element_name)) to decide whether an element is in the set. Is this a common practice? Any suggestions on improving this? Also, should I use defined...

How can I check if a key exists in a deep Perl hash?

If I understand correctly, calling if (exists $ref->{A}->{B}->{$key}) { ... } will spring into existence $ref->{A} and $ref->{A}->{B} even if they did not exist prior to the if! This seems highly unwanted. So how should I check if a "deep" hash key exists? ...

How do I maintain the order of values in an XML file with I read it with XML::Simple?

I am using XML::Simple for parsing a XML file. Code is given below with XML file, use Tie::IxHash; tie %$data, "Tie::IxHash"; use XML::Simple; use Data::Dumper; $xml = new XML::Simple; $data = $xml->XMLin("ship_order.xml"); print Dumper($data); XML file, (ship_order.xml) <?xml version="1.0" encoding="UTF-8" ?> <shipment> <sh...

Python: `key not in my_dict` but `key in my_dict.keys()`

I have a weird situation. I have a dict, self.containing_dict. Using the debug probe, I see that dict's contents and I can see that self is a key of it. But look at this: >>> self in self.containing_dict False >>> self in self.containing_dict.keys() True >>> self.containing_dict.has_key(self) False What's going on? (I will note that ...

What is the purpose of padding an md5 message if it is already the right length?

I know the process for padding in md5, but what is the purpose of adding a 1 and several 0's to a message that is already the correct length? Is this for security or just a marker? ...

Perl: Threading with shared multi-dimensional hash

I am trying to share a multi-dimensional hash over multiple threads. This hash holds 2 connected key-pairs, I need to know if they are already connected, if they are not, I need to connect them, if not, there is no need to go to the database. use threads; use threads::shared; my %FLUobject2param : shared = (); #Start a new thread f...