Programming :: Store Executable Code In The Value Part Of A Hash?
May 28, 2010
I was reading about Ruby code blocks, but it's all a bit hazy.My questions:1. Can you store executable code in the value part of a hash (err...associative array)2. If you did, how would you call the code?3. If you executed this stored code, would it be possible when doing soto pass in an object to the code that it could use?
I am in need of some syntax help. I'm trying to figure out how to store and retrieve an array out of a hash of hashes. For this example, I'm trying to access the city list for a particular state for a particular country. I understand I could do a join and split on the hash key to combine Country and State, but trying to keep things separated.The code I have gets in all the information for the Countries, and states, and gets the list of cities together, no problem. I store all the city names in an array, then make an anonymous pointer to the array for the hash, like this - $MY_CITIES{$COUNTRY}{$STATE} = [@CITIES]I believe that syntax is correct, or is it? What I'd like to do is I need to cycle through every hash to find if a city exists or not. If it exists in 3 states, then it should print 3 times. Here is the code block to search -
Code: for $COUNTRY (@LIST_OF_COUNTRIES) { for $STATE ( keys %MY_CITIES{$COUNTRY){$STATE} ) {
Morning all , not sure how to put this. I have a .sh executable script I use for video encoding. I want the system to be able to see it no matter where in which folder I am. I want to be able to execute that script in terminal in any folder. How can I make it part of the system path. ? Don't know if my wording is right but I think you guys know what I mean.
I am in the process of re-DL-ing the ISO as the checksums didn't match.
Mind you, that was with a shell extension in Win-Lose. Who knows.
Anyway:
I have the ISO (that I had previously) on a USB courtesy of UNetBootIn. All appears well until, quite quickly, I receive an error after the loading process which goes something like:
Code: Error: cannot find disk at [hash-code - looks like 0ace5f etc etc, is about 12 char's in length.]Something very similar (but not same error I think) happened when I tried to do the same with my OpenSolaris or Fedora install. I.e., gets as far as the very beginning of the loader and then: bork.
At least one of them said "will reboot in 120 secs". Saves me the trouble!
I thought this question's best category would be in the newbie sectionBasically I have a C code, (for simplicity is only prints a few lines), called printx.c that I would like to convert into a binary file so whenever I have to type "printx" in the command line it would execute the programofcourse gcc will give me a binary file if I do a "gcc printx.c", but even the output file (e.g. print.outwould have to be executed following manner./print.outI only ask, because I notice programs like mailx (which is written in C) is a binary file that could be run in this manner (at least that's what I notice on my ubuntu distro)
I am trying to make a hash of objects in perl (long story.) I have a package containing the main hash and all the subroutines necessary to work with it. My "new" subroutine used to add an object to the hash goes like this:
I'm writing an interpreter and it used simple association lists for mapping varaible names to their values. Here's the code:
Code:
#include "assoc_array.hpp" #include <string.h> using namespace LANG_NAMESPACE;
[code]....
I thought that I would replace it with a hash table to increase performance. Note that I decided to store linked lists in the buckets instead of the actual values, in case the hash function outputs the same index for multiple variable names:
It runs in about 0.333 seconds on my machine. Since I'm using git version control, I decided to bring back the old version that used association lists. To my amazement, it ran 3 times faster, completing in 0.116 seconds! Is my hash table implementaion really that bad, or is this a really poor benchmark (and real-world code actually will be faster using the hash table)?
I have two students whose windows laptops are riddled with malware and not working properly. They want me to help them install Linux (which we use in school), but they are concerned about their iTunes.
Having avoided iPods as "defective by design", I know nothing about iTunes whatsoever. However I remember reading about DRM locking and such problems that have me concerned that I won't be able to do it.
Where does iTunes store its stuff?
Can I copy its data store to an external drive, and then into a linux home?
Then will it work on wine, or can another manager (rhythmbox etc) access the itunes data?
Alternatively, if I partition the drive and install linux, can rythmbox/wine/something access itunes data on the win partition?
Supposing they are buying music through iTunes, what will happen to that account?
Finally, one of them has an iphone. Does that work with linux?
Ironic that an apple application is blocking migration away from windows.
i have a loop which produces new value everytime it runs. i want to store the results in an array. how can i do dat??
loop is like: a=0 declare v while ((....)) do v[$a]="$r" let a=a+1 done
while doing this it is not treating v as array but as variable and it is overriding the value and old value is lost..i am using bash shell version 3.00.15
i m trying to store h.264 in avi container using ffmpeg....is it possible using ffmpeg.i m using v4l to capture a image and compressed in to h.264, how i can store it in avi container,any programming example,header format for avi container,and what other information required to store in a container.
website.com/john/doe/index.htmlI need to cut that to say:website.com/john/doe/I am getting really close using sed, but I just can't get the syntax quite right.
I am trying to store the data in my program in a map of priority_queues an I am having a bit of trouble doing it. basically I am storing activities (ie watching tv, eating dinner, playing ping-pong, etc) and I want these event grouped by the day that they happened on. my first thought was to use a multimap where the key is the date, and the value is the activity, however I would like to keep the activities in a specific order. I have tried to find the proper syntax for this but have frustratingly come up empty. Even google provided little assistance.
I am working in DM355 board. CPU is armv5t. I am asked to record the video thats coming from camera using rtsp. I can record the video file in avi format on /opt directory on dm355 target board. Now I have to store this avi file in nas server. My nas server ip is 192.168.1.250. Linux pc,DM355 target board and NAS server on same network. How to write the program to store avi files from DM355 to NAS server.
I am working on an structure program and i have to represent a 2,4 tree in a class in Java using single int array and make the insert and delete functions .
I have a requirment where I have to store some data before the system goes to hibernate. How the kernel intimates to the application when it goes to hibernate. Is there any event or a signal that kernel posts to all applications?
I have to pull certificate from multiple computers which are on network and store it in a single fie or each file belong to a particular computer.I am using certutil -store to import the certificate.
I have a very bad attempt at hashing the components of an tcp session to assign/locate the session in a hash table bucket. I am pretty sure that it has a very high collision rate and when there are a very large number of tcp sessions my application is having to search a long linked list to find the session within the bucket.
All the hashing functions I have found take a single string input where I need to input several integers and hash them into a single result. My guess is that any real hashing function is going to produce better results than what I am currently doing.