My goal is to create an efficient structure to store the most relevant entries of a matrix that would (in a world without memory limitations) be approximately 10^5 x 10^5 and filled with doubles. The matrix is symmetric, so it actually would contain only (10^10)/2 values.
I need to access entries many, many times in my simulation, so fa...
Hi.
I'm trying to set key name in a hash to a string containig "/" symbols, for instance
$myshash{"/dev/shm"} = "shared memory";
But what I get is something like '28/64' and so on when viewing with Data::Dumper.
How can I use these special chars in hash key names?
...
Why does this work the way it does? I thought it had something to do with pass-by-reference/value, but that's not the case. Does it have something to do with the new block scopes?
def strip_ids(array)
array.each{ |row| row.reject! {|k, v| k =~ /_id/ } }
end
class Foo
attr_accessor :array
def initialize
@array = []
@array...
Hey.
I have some xml on server (http://server.com/my.xml). Here is the example:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE current PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<current>
<song>Bruce - Inside The Machine</song>
<song>02 Duel of the Fates 1</song>
</current>
...
Suppose you had this:
def wipeProduct(hash, nameToDelete)
hash.each do |i|
key = i[0]
productName = i[1].first
hash.delete(key) if productName==nameToDelete
end
end
I'm not sure it's safe to delete things from a hash whilst you're iterating over the key-value pairs of the hash. I checked the RI documentation but I ha...
I'm trying to compare two UIImages from the file system to see if they are the same. Obviously, I can't use NSObject's hash method, since this returns a hash of the object, and not the actual image data.
I found code generate an MD5 hash from a string, but I haven't discovered how to implement it for a UIImage.
How should I go about ha...
I need to find a way to find a way to find the hash for the base64 encoded data in the XML node //note/resource/data, or somehow otherwise match it to the hash value in the node //note/content/en-note//en-media@hash
See below for the full XML file
Please suggest a way to {obtain|match} using XSLT
4aaafc3e14314027bb1d89cf7d59a06c
{f...
Is there a hash function where small changes in the input result in small changes in the output? For example, something like:
hash("Foo") => 9e107d9d372bb6826bd81d3542a419d6
hash("Foo!") => 9e107d9d372bb6826bd81d3542a419d7 <- note small difference
...
For the sake of convenience I am trying to assign multiple values to a hash key in Ruby. Here's the code so far
myhash = { :name => ["Tom" , "Dick" , "Harry"] }
Looping through the hash gives a concatenated string of the 3 values
**Output**
name : TomDickHarry
**Required Output**
:name => "Tom" , :name => "Dick" , :name => "Harry"
...
Hello
UltraEdit saves temporary, ie. unsaved/untitled, files as (regex) "Edit.\d+".
When UltraEdit is killed (I do this when some software nags me to reboot), I noticed that it doesn't always save files in the same directory, so I end up with a bunch of "Edit.\d+" files scattered in my two hard-disks, with a lot of identical contents.
...
We are told that we should implement hashCode() for our classes but most people like me have no real idea of how to do this or what happens if we get it "wrong". For example I have a need for a hash function for indexing nodes in a tree (http://stackoverflow.com/questions/1685239/finding-the-most-frequent-subtrees-in-a-collection-of-pars...
In some Python code I've read I keep noticing this code:
return dict(somekey=somevalue)
Does that have any benefit over:
return {somekey:somevalue}
I tend to say no, since both objects will belong to the same dict type, but I may be wrong.
...
Hello,
I have blocks of data associated with latitude/longitude values. I'd like to create a lookup key/hash value from the latitude/longitude value so it can be used as a lookup into a map or something similar.
I'm using negative values for West and South... therefore 5W, 10S is represented as -5, -10 in the program.
I'd like to...
Hi,
I am newbie in Ruby.. seeking some help..
I have a code
DB = { 'key1' => "value1",
'key2' => "value2"}
key = gets
DB["#{key}"]
when i enter key1 from console i get nil
how to resolve this?
I tried few different alternative but could not solve it. hope to get help here.
Thanks
...
I'm looking for some C library that includes STM-style (Software Transactional Memory) hash maps, but I had no luck so far. It would be great if it was based on glib / gobject, but it's not that crucial. It also doesn't need proper transactions over many objects - single immutable hash support is all I really need.
Must haves: immutable...
I'm building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished?
hash.to_xml
...
I have to search a given file name (let say Keyword) in a directory containing files. If there were only few keywords to be searched, I could have used regular search (like creating an array of file names residing in the specified directory and then search each file name with the given keyword). Since I need to search very large number...
Say I'm using a hash to identify files, so I don't need it to be secure, I just need to minimize collisions. I was thinking that I could speed the hash up by running four hashes in parallel using SIMD and then hashing the final result. If the hash is designed to take a 512-bit block, I just step through the file taking 4x512 bit blocks a...
Hi
I want perform sha1sum file1 and sha1sum file2 and perform bitwise OR operation with them using bash. Output should be printable i.e 53a23bc2e24d039 ... (160 bit)
How can I do this?
I know
echo $(( 0xa | 0xb )) but how to extend to 40 hexadecimal digits?
Thanks
...
I've tried and tried, but I can't make this less ugly/more ruby-like. It seems like there just must be a better way. Help me learn.
class Df
attr_accessor :thresh
attr_reader :dfo
def initialize
@dfo = []
@df = '/opt/TWWfsw/bin/gdf'
case RUBY_PLATFORM
when /hpux/i
@fstyp = 'vxfs'
wh...