FAQ Database Discussion Community


How to Access a List through a key?

python,string,list,dictionary,key
I have a program that has a save file full of lists. It Loads up the Items by making lists. It gets the Names from the file too. Since I couldn't "unstring" a string so I put the names as keys. My problem is re-saving the lists when you are...

Python: extracting text from strings using a key phrase

python,string,key
Struggling trying to find a way to do this, any help would be great. I have a long string – it’s the Title field of an eBay auction. Here are some samples. Cisco AIR-LAP1142N-A-K9 W/POWER CORD AIR-LAP1142N-A-K9 Used Cisco Aironet 802.11n Draft 2.0 Single Band Access Point AIR-LAP1142N-A-K9 Cisco Aironet...

Can I remap the “,” command in VIM before using it as the leader key?

vim,key,leader
I like the way of working with "," as a leader key, but don't want to lose the original "," functionality, because it is very powerful with the "f" and "t" command. Is there a way I can remap the original "," key, maybe invoking some internal low level VIM...

How to select values of keys that are provided as variables in jq?

json,variables,dictionary,key,jq
If this was the input, { "a_key": 2, "another_key": 100, "one_more_key": -4.2 } what would be the best way to select the value of any of these keys by providing the name of the key as a variable? Ideally, I was looking for something like: "a_key" as $key | .$key...

filtering the keys of a python dictionary for all the items of a list

python,dictionary,filter,key
I am trying to filter the keys of a python dictionary for specific strings. def filterDictionary(filterdata): dictionaryToFilter = {'car 1':100,'car 2': 200, 'car 3':300, 'bus 1':1000, 'bus 2':2000, 'bus 3':3000} filterInput =[] filterInput = filterdata.split() for a in filterInput: dictonaryFiltered = {k:v for (k,v) in dictionaryToFilter.items() if a in k}...

How to assign key to object literal when they keyname is represented by a variable?

javascript,jquery,variables,object,key
Perhaps someone can help me solve this. I'm pulling input elements' name and value out of a list like this simplified version: <ul id="options_set_1"> <li><input name="width" value="10" /></li> <li><input name="height" value="20" /></li> <li><input name="depth" value="5" /></li> </ul> The id of the ul and the names and values of the inputs...

PHP: Return Array of Values from Key in Associative Array [duplicate]

php,arrays,multidimensional-array,key,associative-array
This question already has an answer here: Is there a function to extract a 'column' from an array in PHP? 13 answers Let's say that I have an array like this: $people = array( array( 'name' => 'Bob', 'job' => 'Carpenter' ), array( 'name' => 'George', 'job' => 'Programmer'...

I want to sort a list in a method with respect to the method's argument

python,list,sorting,key
I have a method and as an argument I enter x and y coordinates of a point and then I calculate the power reached to that [x,y] coordinate from other points and sort them in order of highest power reached to lowest: def power_at_each_point(x_cord, y_cord): nodez_list = [nodes_in_room for nodes_in_room...

How to close an android application by pressing back key twice?

android,key,back,close
I saw many android applications that if you press the back key once a toast will pop out warning the user that if you press the back key one more time it will close the android application. How can I do that? EDIT: This is different from just closing the...

Symmetric and public key encryption

encryption,cryptography,key,encryption-symmetric,encryption-asymmetric
Suppose N people want to communicate with each of N- 1 other people using symmetric key encryption. All communication between any two people, i and j, is visible to all other people in this group of N, and no other person in this group should be able to decode their...

Perl Sorting Multiple Keys Hash

perl,sorting,hash,key
I have a hash %grades{$subject}{$student}=$score I am trying to extract top 30 scores for each subject with students from the hash which requires sorting, but I'm not sure how to sort the multiple key hash. So far I have this, but this gives me every single one of the scores...

setting SSH access to localhost

ssh,key,localhost
I am trying to setup ssh access to my own local machine. I have created the id_rsa key using ssh-keygen. I added id_rsa.pub to authroized_keys in .ssh/ I made sure the permission of authorized_keys is 640 I enabled public-key authentication in sshd_config & restarted ssh RSAAuthentication yes PubkeyAuthentication yes AuthorizedKeysFile...

C++ Continuous Player Movement

c++,windows,key
For my program I am making Pacman! I am able to allow the player to move with the key but how can I make it where the player automatically moves, then when you press another key it changes. In a brief sentence, if I press the right arrow key, the...

How to set up two SSH keys for two GitLab accounts and push/pull by using TortoiseGit?

git,ssh,key,gitlab,tortoisegit
Currently Im using GitLab as my remote GIT server. I have no problem using single Gitlab account with SSH key assigned to it. But now I applied another Gitlab account and I'm trying to use the same SSH key for it, but I cant add the key to this new...

how I should proceed to extract the value id for keys from the .json file in python using the keys

python,json,key
I am a beginner in python. Could you kindly advise me on how I should proceed to extract the value id for keys from the .json file in python. I am currently comparing the key using 'if' condition and then i am stuck as to how I should proceed to...

Java Append Key Input to String

java,string,input,keyboard,key
For my current project I need to create a custom text box that gets each key pressed and adds it to a string. I'm constantly updating the method that retrieves the key a user is pressing and then I add it like so: public void addCharacter(String c) { String before...

PHP get ranges of same values from array

php,arrays,key,range,value
Is there any way to get the key range of same values and make a new array? Let's say we have an Array Like this in php : $first_array = ['1'=>'a','2'=>'a','3'=>'a','4'=>'b','5'=>'b','6'=>'a','7'=>'a']; How can i get this array? Is there any function for this? $second_array = ['1-3'=>'a','4-5'=>'b','6-7'=>'a']; ...

In XSLT 1.0 how to create a lookup function on XML data embedded in the XSLT using key and document('')?

xslt,key,document,lookup,xpath-1.0
My specific need is to lookup line-heights given a particular font-size, but I am seeking to learn a general technique of creating lookups/a specific mapping. I think it is possible to embed XML in the XSLT document itself (so it can work standalone) and build a key on it using...

Sort multi-dimensional array - keep values of keys

php,arrays,sorting,date,key
I want to sort my array based on the key (which is a date) - preferrably both ASC and DESC. I have tried to use several of the methods on SO, but keep getting bad results - so I thought I would ask the question again. I have this array:...

Usage of Google Maps API Key v3

javascript,google-maps,google-maps-api-3,key,quota
I'm just starting with Google Maps API (GMA for short) and I came to understand it is good to have the GMA Key (GMAK for short) regardless of not being necessary IF you are not to set foot beyond the limit quota. It happens that I probably won't but that...

Create a unique key from XML

php,xml,key,unique
Starting point I have a small application which stores hardware data from all computers in my network. A powershell script fetches the data and generates an XML therefrom. This XML is then sent via HTTP request to my PHP script. On my PHP script I map the data into several...

How can I ask for a key of a subkey in a dictionary in Python?

python,dictionary,key
If I have a dictionary in a dictionary, how can I ask for a key in constant time? For example: def get_hobby(hobby): d = {'An' : {'Hobby': "Paintball", 'Age' : 22}, 'Jef' : {'Hobby' : "Football", 'Age': 24}, 'Jos' : {'Hobby': "Paintball", 'Age' : 46}} assert get_hobby("Paintball") == ['An', 'Jos']...

check existence of data in python dictionary

python,validation,dictionary,key
I have a program that maintains a flat file database of cd information. I am trying to write a function that updates the database. In this function I am checking to see if the artist exists and if so, appending the album name to this artist, but for some reason...

Python: how to get values from a dictionary from pandas series

python,dictionary,pandas,key,dataframes
I am very new to python and trying to get value from dictionary where keys are defined in a dataframe column (pandas). I searched quite a bit and the closest thing is a question in the link below, but it doesnt come with an answer. So, here I am trying...

Java HashMap, hashCode() equals() - how to be consistent with multiple keys? [duplicate]

java,hash,hashmap,key
This question already has an answer here: What issues should be considered when overriding equals and hashCode in Java? 12 answers I have an ID class. It refers to identification for a unique person. There are two forms of ID. Username and user number. If either username matches or...

PHP remove array keys

php,arrays,key
I have Array ( [0] => 2088 [1] => 2087 [2] => 2091 [3] => 2083 [4] => 2086 [5] => 2085 [6] => 2084 [7] => 2092 [8] => 2089 [10] => 2122 [11] => 2122 ) As you can see i don't have array key number 9 How...

Getting the name of an object in a for in loop to use as a key for another object

javascript,object,key,for-in-loop
So I have set up a system where my GUI Class, when initiated, sends a config object to the Focus class constructor. The GUI class creates an instance of the Focus class, and the class constructor has an argument. My Code: var GUI = function(){ this.isWorking = "GUI(LOCAL) IS WORKING";...

PHP / MySQL: How to store Select results in array

php,mysql,arrays,dictionary,key
I am new to PHP and MySQL and hope someone can help me with this. I have a MySql db with a table "TranslationsMain" and the following PHP query. This returns all the items from column "German" (incl. the corresponding ID) from the db table and works correctly so far....

C++ Custom std::map<> key class causing memory violation

c++,templates,dictionary,stl,key
For the first time I've written a class that is supposed to be usable as a key type for std::map<>. I've overloaded copy constructor, assignment, and operator < as suggested in other questions on SO. But for some reason it crashes when I'm trying to insert using operator []. This...

preventing adds of KVPs with duplicate key Values c#

c#,list,duplicates,key,keyvaluepair
I have a list of (int,int) KeyValuePairs and I want to prevent adds to this is if the key already exists. Is this function already present? or do I have to prevent the add in some other way? EDIT: Additionally I want to be able to sort the collection by...

extracting particular fields of each record from input file into key/value pairs in apache spark

apache,key,field,apache-spark,value
The following is the input file to Apache spark processing. each record contains four fields as shown. User ID Movie ID Rating Date 6 9217 2 2005-04-28 00:00:00.000 6 9254 4 2005-04-20 00:00:00.000 6 9330 4 2004-11-17 00:00:00.000 6 9330 5 2004-09-27 00:00:00.000 6 1615 4 2004-09-15 00:00:00.000 6 1659...

How to display every key and value in a dictionary apart from one in python [duplicate]

python,dictionary,key,value
This question already has an answer here: Iterating over dictionaries using for loops in Python 6 answers dict1 = {"Bear":3,"Wine":3,"Spirits":7,"No":0} Here I have a dictionary and I want to display every key and value from Bear, Wine and spirits so it would look something like this: Bear 3 Wine...

Surrogate Keys complicate insertion?

database-design,foreign-keys,key,relational-database,surrogate-key
I often see people using artifical / surrogate keys in relational databases. Thinking about it, it seems to me that while this simplifies join-Queries, it complicates the insertion of new tuples. Take the following example: R1(a, b, c) R2(c, d, e) c is a surrogate primary key of R2, referenced...

Excel - SUM of multiple VLOOKUP

excel,table,excel-formula,key,vlookup
It seems like a simple problem, but I do not manage to solve it. I have the following tables: Values | Key | Value | |-----|-------| | A | 1 | | B | 2 | | C | 3 | Results | Foo | Bar | |-----|-----| | A...

new dictionary from existing dictionary values

python,dictionary,key,append,value
I am trying to figure out how to perform the following: firstDictionary = {"firstKey" : "A", "secondKey" : "B"} secondDictionary = {"firstKey" : 3, "secondKey" : 47} emptyDictionary = {} for key, value in firstDictionary, secondDictionary: # emptyDictionary = some sort of append method... so that secondDictionary = {"A" :...

SSH asking for password at login and not passphrase

ssh,passwords,key,passphrase
I recently used this guide https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-14-04 When I created the public key I opted to use a passphrase. When I connect via ssh from my local machine it is only asking me for a "password" (as it normally would). I assumed that it would now ask for a "passphrase" and...

Word frequency and line number in Java

java,regex,key,frequency,word
Write a program using Java or C# that counts the frequencies of each word in a text, and output each word with its count and line numbers where it appears. We define a word as a contiguous sequence of non-white-space characters. (hint: split()) Note: different capitalizations of the same...

HTML page scrolls on keydown

javascript,html,key,arrow
*** Note that this question has an answer *** I have a game in which the player can move using the arrow keys, I when I hit the up or down arrows the screen also moves. Is there a way to disable this? I'm using the following: Local HTML page,...

Does MapQuest allow us to draw routes on the Map on the free version?

android,key,mapquest
I have an app that has an old MapQuest key and I wanted to show a route on the Map. However, it didn't work, and on my Callback I got this message: This key is not authorized for this service. If you do not have a key, you can obtain...

Why Can't I move an Element of a map?

c++,dictionary,key,const,move
I want to be able to change the key of an element of a map. I thought that a good way to handle that would be to move the element from the map, as follows: map<char, int> foo{{'a', 1}, {'b', 2}, {'c', 3}}; foo['z'] = move(*foo.find('c')).second; for(auto& i: foo){ cout...

how to sort a list of tuples with list[i][1] as key from biggest to smallest [duplicate]

python,sorting,key
This question already has an answer here: How to sort (list/tuple) of lists/tuples? 5 answers This is my list. [('a', 12), ('c', 4), ('b', 3), ('e', 6), ('d', 5), ('g', 50), ('f', 30),] The result for sorting this list would be. [('g', 50), ('f', 30), ('a', 12), ('e', 6),...

PHP Autoincrement Array

php,arrays,indexing,key,key-value
I am having trouble with expanding my PHP array. Here is a sample of my code : <select name="PaymentCounts"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> </select> <?php $arr = array ('Client' => "Alex", 'BillNumber' => "123", 'PaymentCounts' => "1", 'Amounts' => array ('PaymentNumber' => array( array('Amount1' => "100.00",...

Android Key Hash - Users appearing to have different keys

android,facebook,hash,key,match
We've had our app out on Android for well over a year with facebook integration. I set up the key hash on the Facebook app when the build was first made. We launched a new version of the game 2 days ago, and we have some users with the error:...

Find KeyAttribute of a class, defined using HasKey method

c#,entity-framework,attributes,key
I am using Entity Framework Power Tools to generate database Model classes. It uses HasKey() Method to define Key Attribute of a class. Is there any way to find my key attribute of a class while using it in my application code? Is there any way to check either a...

PHP: echo item from array by its value instead of by its array index

php,arrays,key,echo
I have an array with two values stored for each item, the first one called "ID" and the second one called "en". The ID values are unique integers and the en values are text. Now I would like to echo a specific item from the array referring to it by...

Reverse array with custom keys, keep keys intact?

php,key,reverse
First post here, and a new PHP developer. :x I'm looking for a way to iterate through the LAST four elements of an array, then break. The array keys are custom IDs for the products sold on a website, so I can have the flexibility of adding additional items and...

Increment shared preference key after adding value

android,key,sharedpreferences,value
In my app, the user can add a name and an age for multiple people. Most likely it will only be around 2 or 3. I want to store these in shared preferences. I set a counter to keep track of how many people have been stored as well as...

Scrapy: If key exists, why do I get a KeyError?

python,list,key,scrapy,scrapy-spider
With items.py defined: import scrapy class CraigslistSampleItem(scrapy.Item): title = scrapy.Field() link = scrapy.Field() and populating each item via the spider thus: item = CraigslistSampleItem() item["title"] = $someXpath.extract() item["link"] = $someOtherXpath.extract() When I append these to a list (returned by parse()) and store this as e.g. a csv, I get two...

Why doesnt mysql use the key for a simple select?

mysql,indexing,key
Here's what I did: MariaDB []> explain select * from blabla where name like '%poor%'; +------+-------------+--------------+------+---------------+------+---------+------+---------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +------+-------------+--------------+------+---------------+------+---------+------+---------+-------------+ | 1 | SIMPLE | blabla | ALL | NULL | NULL...

VBA dictionary data type

excel-vba,dictionary,key
Many sources, e.g. https://support.microsoft.com/en-us/kb/187234, claim the key of a dictionary can be of many data types beyond string. However, when I tried integers and dates as keys, it fails. Can someone explain? I tried the answer of @Tim Williams below, it works. What I had before was Private Sub trial()...

JQuery JSON push using object as key [duplicate]

javascript,jquery,json,object,key
This question already has an answer here: Using a variable for a key in a JavaScript object literal 3 answers I am trying to write a JSON file using JQuery. I am attempting to use a javascript object as a json key however it does not run. My code...

compojure destructuring making integers… not integers?

clojure,key,compojure,datomic
This Compojure GET route with hard-coded id... ;posts (GET "/post:id" [id :as request] ;(str "the post id is... " id) (def email (get-in request [:session :ze-auth-email])) (vb/post-page-draw email 17592186045616)) Works^ However, with symbolic id (on the last line)... ;posts (GET "/post:id" [id :as request] ;(str "the post id is... "...

How can i get output array having only different key?

php,arrays,key
I have following two array $array1 = array("product_a" => "Nokia1", "product_b" => "Nokia11", "product_c" => "Nokia111", "Nokia1111"); $array2 = array("product_a" => "Nokia1", "Samsung", "Nokia1111"); I want to compare these both array and want output as having different keys Like my output as below Array ( [product_b] => Nokia11 [product_c] =>...

How do i allow/deny a key based on how many times it appears on a listbox?

textbox,listbox,key,keypress,keydown
So i got a listbox where i'll have random vowels/cons and i wanna limit what the person can write on the textbox according to these keys i'll have on the listbox. So far i got to allowing only whats on the listbox but you can use it as many times...

Python Sets, Keys, and Dictionaries

python,function,dictionary,set,key
What I'm trying to do is ask the user for a name and then find out in how many clubs a person is, using sets and keys. I'm still new to dictionaries and sets, so I'm a bit confused with how to go about this. So far, I have this...

How to get array which have some particular key

php,arrays,key,value
my array is [newconfig_name] => 'abc', [name] => 'xyz', [newconfig_qty] => '200', [qty] => '100' i need data which have key same as newconfig how to convert array like [newconfig_name] => 'abc', [newconfig_qty] => '200', without any loop...

Python List To Dictionary - Without Value Overwrite

python,dictionary,key,append,value
Keys = [1,2,3] Values = [["a",1],["b",2],["c",3],["d",1]] Dictionary = dict.fromkeys(Keys) for d in Dictionary: for value in Values: if value[1] == d: # Add to dictionary Dictionary.update({d:value}) # else # Do Nothing print(Dictionary) When I run this piece of code, it works fine until I look closer at the its output....

What means /V key when Windows Installer service starts?

windows,service,key,msiexec
Windows Installer service starts as C:\Windows\system32\msiexec.exe /V I read standard help to msiexec but not found this key description. What it means?...

Why does enclosing a field in quotes take longer than without it?

mysql,sql,indexing,key
For example, I have this query: SELECT * FROM a WHERE field IN (-1, "1") The above query takes 20 times longer than this one to execute. Why? SELECT * FROM a WHERE field IN (-1, 1) Also, in the first case the index is not used, even with USE...

Print out key values of array from form

php,html,arrays,forms,key
Currently I am running a php file in a form of my own html file. I want the print out at the end the key values in my arrays. The arrays are to hold the values of the drop down boxes and radio boxes. I want to know how to...

gnuplot: add extra keys

key,gnuplot,histogram,legend
I have a simple gnuplot script to plot a histogram with differently colored bars, with each color representing a group. How can I show 3 different keys (1 red, 1 green and 1 blue)? This is my script: unset title set key left set yrange [0:10] set ylabel 'Score' set...

Connecting two models belongs_to/has_many and selecting via dropdown in form

ruby-on-rails,key,models,rails-models
I am rails beginner and I am facing a basic problem. I have found a couple of solutions but none of them fully describe my problem. I have two models: Contact and Group Group has_many :contacts Contact belongs_to :group (Through devise there is a third user model) When creating a...

Moving Keys in dictionary

python,dictionary,key
This is my first question, I've read the good posting guide but if I make any mistakes please let me know. So anyway, I have a dictionary in python that is has keys numbered 1,2,3,4,5, etc and my question is if I delete, say 3, so I have 1,2,4,5 can...

PYthon - Building 3rd layer of list within a hashmap

python,function,dictionary,key
I am currently on ex 39 of Learn Python the Hard way: http://learnpythonthehardway.org/book/ex39.html I am really stuck at the moment with this code, I am trying to add a 'third layer' of 'buckets' to the code so every individual key has its own dictionary, so that keys can hold multiple...

An error when cast stdClass to array

php,arrays,casting,key
When I cast stdClass to array like this: $a = (array)json_decode('{"0":{}}'); print_r($a); print_r($a[0]); // This causes error The output is: Array ( [0] => stdClass Object ( ) ) Notice: Undefined index: 0 in [...][...] on line 3 How can I solve this problem?...

constructing key by bit shifting 3 integers in C

c,key,bit-shift
I want to construct a key composed of 3 values by using bit shifting operations: According to my understanding, the C statement code I am starting from creates a hash table by constructing its keys from certain data variables: uint64_t key = (uint64_t)c->pos<<32 | c->isize; My interpretation is that key...

Android Signature key differences between Old and New PC

android,key,signature
An existing package by the same name with a conflicting signature is already installed I had developed an inhouse app years back on an old PC and had deployed it. Now I got a new PC, that I used to work on some upgrades, but when I tried to upgrade...

Searching Python dictionary for matching key

python,dictionary,key
I want to search a python dictionary for a key that matches an initial sequence of letters. However, it's a bit more complicated and I lost myself midway in confusion. Example: I have a string "ABSTTHGIHG" and i want to search a dictionary for a key that matches exactly the...

Converting byte array to publickey ECDSA

java,key,signature,public-key,ecdsa
I need to use ECDSA algorithm to sign a message and send to receiver in java. Then, receiver should verify sender's signature. So, for this, receiver has sender's public key but in byte array format after converting java.security.PublicKey to byte array by the command bellow: byte[] byteArrayPublicKey = publickey.getEncoded(); The...

Covering index and getting rid of Key Lookup

sql-server,indexing,key
I have a SQL statement that is giving me a Key Lookup sucking the processing of this query below. Since its part of a 3 part union, getting rid of the key lookup is preferable. My query is below. SELECT c.customerName, c.customerNumber, totals.TotalLoanAmount, totals.TotalCommitmentAmount, l.loanNumber, l.commitmentAmount, ed.amountThreshold, ex.exceptionId, IsNull(ex.reminderDateGracePeriod, ed.defaultReminderDateGracePeriod)...

JQuery function not firing on enter keypress

javascript,jquery,function,key,keypress
I have the following jQuery/js controlling a trello style input field. So when you click on the span element, it switches to an input field. Then after you finish editing the element and take focus away from it(blur), it switches back to the span element with the new text. I...

How to add key pairs to object literals using loop--WITHOUT overriding existing entries?

javascript,jquery,object,key,literals
I'm reading input field 'name' and 'value' attributes from ul lists. No two lists have the same amount of inputs and the 'name' and 'value' attributes are unknown till read. <ul id="options_set1"> <li><input name="width" value="10" /></li> <li><input name="height" value="20" /></li> <li><input name="depth" value="5" /></li> </ul> <ul id="options_set2"> <li><input name="finish" value="printed"...

Reference as key in swift dictionary

swift,dictionary,key,hashtable,memory-address
Dictionary key requires Hashable conformance: class Test {} var dictionary = [Test: String]() // Type 'Test' dies not conform to protocol 'Hashable' class Test: NSObject {} var dictionary = [Test: String]() // Works How to get address of pure Swift class instance to use as hashValue?...

Get KEY from JSON

javascript,json,key,key-value
Following JSON : https://api.myjson.com/bins/3yz34 I was thinking I might use an internal ID for a key (which simplifies looping through several entities and setting up data gathering) and use a value for display. However, I cannot get the value of the key. $.each(tabledata.Companies, function (){ company = this; alert(company); var...

python dictionries when keys are numbers [duplicate]

python-3.x,dictionary,numbers,key
This question already has an answer here: Why is the order in Python dictionaries and sets arbitrary? 5 answers I have a question about dictionary properties in python when the keys are number. in my case when I print a dictionary with number keys the result of print will...

Recreating Google Maps API for Android

android,api,google-maps,key
I have an android application that is on Google Play right now. It uses Google Maps v2 to display maps so it has an API Key. But another developer who has worked before me, used his own gmail account to create the API Project. So I created a new API...

How to retrieve a value from an object by passing a variable as a key

arrays,json,object,coffeescript,key
I have the following array of objects position = [ {exchange: 'KRAKEN', USD: 1800, EUR: 800, GBP: 800, BTC: 800}, {exchange: 'BTCE', USD: 800, EUR: 800, GBP: 800, BTC: 800}, {exchange: 'BITSTAMP', USD: 600, EUR: 800, GBP: 800, BTC: 800}, {exchange: 'MYWALLET', USD: 1300, EUR: 800, GBP: 800, BTC: 800}...

How to get 2nd deep array key from multi-dimentional array

php,arrays,multidimensional-array,key
i have an array like this Array ( [files] => Array ( [����r�2���VA .]�^�] => Array ( [complete] => 89 [downloaded] => 314 [incomplete] => 40 [isDct] => 1 ) [isDct] => 1 ) [isDct] => 1 ) Array ( [files] => Array ( [����r�2���VA .]�^�] => Array ( [complete]...

Converting key,value object to key,value array in Javascript

javascript,arrays,object,key,value
Please refer to fiddle js file object obj1. (I'm starting out with an object this format because it represents what I get back from Ajax when PHP echos back an ordered key,value PHP array). var obj1 = { "key1": "val1", "key2": "val2", "key3": "val3" }; box1.innerText = "Object: " +...

add a new named key into matches of the preg_match_all

php,key,preg-match-all
My original code is: $sc = 'hello 8491241 some text 6254841 some text 568241'; preg_match_all('/[0-9]{5,10}/', $sc, $matches1); $all_matches = $matches1[0]; foreach ($all_matches as $match) { $sid = '9'; $rov['batch'] = $match; $rov['scid'] = $sid; $res[] = $rov; } print_r($res); How can i add a new named key ['type'] into $matches1...

Python Dictionaries, Keys, and Strings

python,function,dictionary,key
I'm trying to write a program that takes a variable, containing a dictionary, where keys are one word strings and values are lists of strings. Each string is a definition for the word/key. What I want to do is ask the user for a word; if it's not in the...

Adding new key to dictionary overwrites all previously stored keys with new keys values

python,dictionary,key,key-value
I'm trying to use a for loop to generate random values for item prices, by changing the value of the item prices in a pre-defined dictionary. The new values of this pre-defined dictionary are then added to the end of another pre-defined dictionary so a history of prices can be...

Simple Way of Looking for Key Phrases in Jquery?

jquery,key,match,phrases
I have set up a method of retrieving messages from a real time chat client. I want to take these messages (a lot of text) and find out if any of these messages contain key phrases. If they contain a key phrase I will simply add 1 to a count...

How can I read a CSV file to only get the most recent three values into a dictionary?

python,dictionary,key
This code reads every row from a CSV file. The first column is made to a value in the dictionary. I want to limit the value of the keys to three (with the most recent three values.) for row in reader: key = row[0] if key in result: # if...

fetch json value with no key using jquery

javascript,jquery,json,key,value
i am having trouble fetch JSON using jQuery, if possible someone tell me what mistake i made because my code is not working data.json file contain { "value1", "value2", "value3", "value4" } and here is my jquery code $.getJSON( "data.json", function( data ) { $.each( data, function( val ) {...

Setting array key value pair JavaScript

javascript,arrays,key,value,pair
So, I am having an issue and for the life of me I cannot seem to resolve it. It seems very basic, but I just cannot understand for the life of me why this code is not working. My issue is, I am assigning a key value pair to an...

In Grails g:select, using an enum, display the enum keys, but use the values as the options' values

grails,drop-down-menu,enums,key
I wanted to use a g:select tag to produce a select box where the keys of the enum are displayed to the user, while the values of the enum are passed when the form is submitted, using the following enum: public enum LetterRange { ABCD("a-d"), EFGH("e-h"), IJKLM("i-m"), final String value...

Python key error - for key in dictionary: dictionary[key]

python,dictionary,key,keyerror
I am programming a Graph class to handle pathing in a game. Graphs have one field, mapping, which is a dictionary that maps nodes to edges. In one of my functions, I have the following bit of code: for key in self.mapping: connected_edges = self.mapping[key] At one point in my...

Cannot push to remote repository (git)

git,key,push,master
I don't know if it's just me, but I find the process of interacting with remote repositories of Git via command line utterly frustrating. I have generated my own SSH key, added it to my GitLab account. And I have the same key saved, just checked to be sure. And...

How can I convert string virtual key code to virtual key code?

key
I have created xml file in which I have added all keys as nodes and its respective virtual key codes as a value. I am fetching those values and storing it in string format. I need output as: When I press key 0 its corresponding value is 0x30 But my...

Java Hashmap: Get key from a given ARRAY of values

java,arrays,hashmap,key
I have a hashMap called prizeWinners. The key for each pair in the hashMap is the year a nobel prize was won. The value is the name(s) of the winners. The value is an array of Strings, because in any given prize year, there can be up to 3 winners....

Python: How to store multiple values for one dictionary key

python,list,dictionary,key,key-value
I want to store a list of ingredients in a dictionary, using the ingredient name as the key and storing both the ingredient quantity and measurement as values. For example, I would like to be able to do something like this: ingredientList = {'flour' 500 grams, 'tomato' 10, 'mozzarella' 250...

PHP Some help understanding this !isset

php,arrays,key,isset
I am trying to understand this simple code, if someone could explain this one section of code to a beginner. Please bear with me on the simple code and trying to understand this. I understand what the loops are doing, it's just the !isset($value[$values]) part that's tripping me up. Can...

Detect wrong decryption key while working with mcrypt functions in PHP

php,encryption,key,mcrypt
I've wrote the codes below to make an encryption and decryption mechanism. Everything works fine, but I would like to prevent showing unreadable characters if somebody enter a wrong key while decryption. Instead, I would like to show him a certain error message. How can I do it? My PHP...

How to Dynamically name a Hash key in Ruby

ruby,dynamic,hash,key,erb
I'm trying to make a 'render' call in an erb file where the key of the hash is dynamically named. For example... <% object_type_abbr = ["pos", "job_description", "policy", "procedure", "step", "task", "product"] %> <%= render path.to_s, model_id: @model.id, object_type_abbr[i]: orphan, row_no: row_no, is_orphan: true %> The problem is this syntax...

SSH Key: “Permissions 0644 for 'id_rsa.pub' are too open.” on mac

ssh,permissions,key
I generate a ssh key pair on my mac and add the public key to my ubuntu server(in fact, it is a virtual machine on my mac),but when I try to login the ubuntu server,it says: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: UNPROTECTED PRIVATE KEY FILE! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Permissions 0644 for '/Users/tudouya/.ssh/vm/vm_id_rsa.pub' are...

Swap key and value in a map in fsharp

dictionary,f#,key,swap,value
How to create a new map that is similar to the original one, but with swapped keys and values in Fsharp? For example, I have this let map1 = [("A", "1"); ("B", "2"); ("C", "3");] |> Map.ofList and want to get this: let map2 = [("1", "A"); ("2", "B"); ("3",...

Merge JSON Object with same “key” and add their “value” using JavaScript

javascript,json,merge,key,value
My JSON looks like this {"rows":[ {"key":["zeit.de"],"value":98}, {"key":["google.com"],"value":49}, {"key":["spiegel.de"],"value":20}, {"key":["spiegel.de"],"value":12}, {"key":["spiegel.de"],"value":20}, {"key":["spiegel.de"],"value":12}, {"key":["netmng.com"],"value":49}, {"key":["zeit.de"],"value":300} ]} and I am looking for a solution to merge all the same keys and add the values of the merged keys together to get something looking like this. {"rows":[ {"key":["zeit.de"],"value":398}, {"key":["google.com"],"value":49},...

Check if value exists in php multi-dimensional array before adding

php,arrays,multidimensional-array,key,multiple-value
I have a separate set of functions that grabs a "Date" and a "Time" from my application and puts the date into as a key, and the time as a multi-dimensional value. For example purposes: $alldatetimes = array( 'date1' => array('13:00','14:30','14:30','14:30','15:00'), 'date2' => array('09:00','10:00','10:30','10:30','12:00') ); foreach ($alldatetimes as $date =>...

AES Key generation (C#)

c#,encryption,key,aes
i'm working on this project that uses AES encryption. The encryption / decryption part is all done, but I can't get the random AES key generator to work.. I tried multiple things, but I can't get them to work.. Help would be appreciated Regards, CmplDev...