key

need help with sort function in python

Hi, The contents of my dictionary is like so:- >>> dict {'6279': '45', '15752': '47', '5231': '30', '475': '40'} I tried using the sort function on the keys. I noticed that the sort function doesn't work for the key -- 15752. Please find below:- >>> [k for k in sorted(dict.keys())] ['15752', '475', '5231', '6279'] Could someone po...

How can I parse a CSV into array with first value as key?

So I have a CSV file that looks like this: 12345, Here is some text 20394, Here is some more text How can I insert this into an array that looks like so $text = "12345" => "Here is some text", "20394" => "Here is some more text"; This is what I currently had to get a single numerical based value on a one tier CSV if ...

How can I access user-installed keys and certificates from my Android app?

I've been struggling to consume user installed identity CA certs from a p12 file on an SD card. The certs and keys are installed using the Secure Credential Storage (Location & Security > Install from SD card). I haven't found any documentation stating the location if the keys and certificates once imported. I tried to create an inst...

How do I prevent MySQL from auto-incrementing the Primary Key while using ON DUPLICATE KEY UPDATE when the duplicate is a different unique column?

Consider the following table: +-------------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+------------------+------+-----+---------+----------------+ | vendor_id | int(10) unsigned | NO | PRI | NULL | auto_increment | | vendor...

Handle brightness key press event in a native Windows Mobile application

I need to intercept brightness key press in a device with a hardware keyboard, where that key has the double function of changing brightness and the "0" number: if I can handle it, I can avoid to the user of the application to switch to the numeric keypad in some textboxes that accept only numeric input. I tried to handle that key even ...

Java AES and using my own Key

I want to encrypt a string using AES with my own key. But I'm having trouble with the bit length of the key. Can you review my code and see what I need to fix/change. public static void main(String[] args) throws Exception { String username = "[email protected]"; String password = "Password1"; String secretID = "BlahBlahBlah"; ...

Key Management - Classic ASP - encrypt/decrypt

Here is my scenario: I have file called gen.asp, when ever someone requests this file It needs to generate a encrypted-random-key and pass it back. (Gen.asp can not store the key it generated, anywhere no session, no database) I have a different file called GenValid.asp, in this file I need to verify weather the encrypted-random-key is...

How can I design a dict like sqlite class in python which can using different field as "key"?

Hi All, I have a such a data structure, "ID NAME BIRTH AGE SEX" ================================= 1 Joe 01011980 30 M 2 Rose 12111986 24 F 3 Tom 31121965 35 M 4 Joe 15091990 20 M I want to use python + sqlite to store and query data in a easy way. I am in trying to design a dict like...

Android - Key Dispatching Timed Out

In my Android application I am getting a very strange crash, when I press a button (Image) on my UI the entire application freezes and after a couple of seconds I getthe dreaded force close dialog appearing. Here is what gets printed in the log: WARN/WindowManager(88): Key dispatching timed out sending to package name/Activity WARN/W...

HIbernate Query returning incorrect records when used with Composite Keys

class Mstatkey // This defines the coomposite key over the columns deviceid, groupaddr, srcaddr @Embeddable public final class MstatKey implements Serializable { private Integer associatedNetDeviceId; private Long groupAddr; private Long sourceAddr; .... // Here we use the composite key class Mstat @NamedQuery( ...

Using non-copyable object as key for NSMutableDictionary?

I tried to figure out this code referencing: http://stackoverflow.com/questions/1187112/cocoa-dictionary-with-enum-keys + (NSValue*)valueWithReference:(id)target { return [NSValue valueWithBytes:&target objCType:@encode(id*)]; } And, [table setObject:anObject forKey:[NSValue valueWithReference:keyObject]]; But it feels somethin...

How to query java appengine datastore VIEWER for entity using a Long id

Hi all, I'm trying to do something relatively straightforward and something I think I used to be able to do. I'm trying to use the admin interface to query my datastore using a long id. The entity in question is defined as: @PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true") public class Notification { ...

MapActivity: set APIKey programmatically.

Hello all, I currently use a MapActivity in my application. I use it with 2 API Keys. One for debugging, and one for "production" I am fed up with changing these values in the xml layout: <view class="com.google.android.maps.MapView" android:id="@+id/myGmap" android:layout_width="fill_parent" android:layout...

Proper way to catch KeyError in Django?

I am creating an API where a URL is sent to the server. I want to get the username, etc from the URL. I use the following code to do that: try: username = request.REQUEST['username'] message = request.REQUEST['message'] time = request.REQUEST['time'] except KeyError: ... However, there are times when the URL does...

Fastest type for std::map key?

I would like to use the partitions of a graph as the key to a std::map I could represent this as a std vector of nodes. Or I could convert it into a more compact 'custom' binary format (bitset?), or a string representation. For simplicitiy's sake, we can say there is no inherent order to partitions of a graph. Which will be fastest i...

Session Key & Access Token in Facebook-API

Can someone please explain to me once and for good what are Session Key & Access Token? How do I catch those two? Why and when do I need them? When is it one-time and when is it not? Also, what are the differences between them either the application already installed or not. Please do it in Java. I'm a new-to-facebook-api Java developer...

Reversible shuffle algorithm using a key

How would I code a reversible shuffle algorithm in C# which uses a key to shuffle and can be reversed to the original state? For instance, I have a string: "Hello world", how can I shuffle it so that later I could be able to reverse the shuffled string back to "Hello world". ...

Python, get dictionary key as variable directly (not by searching from value)

Sorry for this basic question but my searches on this are not turning up anything other than how to get a dictionary's key based on its value which I would prefer not to use as I simply want the text/name of the key and am worried that searching by value may end up returning 2 or more keys if the dictionary has a lot of entries... what I...

SCP with Ruby and a private key

Hi all I have a small problem here: I try to upload a file using SCP and Ruby to a server using a private key. The code looks like: def transfer_file(source_file, destination_file) $log.info("ScpDP: Key=#{@key}") Net::SCP.start(@host, @userName, :keys => @key ) do |scp| scp.upload!(source_file,@folder + destination_f...

Java - Can we detect if a key is pressed without using a Listener?

Hi There, I need to be able to detect if a certain key (e.g. CTRL) is pressed during a specific operation of mine. I don't have access to a key listener, nor to a mouse event. What I'm hoping is that there will be some class that has a method like "boolean isKeyPressed(keycode)". Is anyone aware of a method like this in java? For ...