w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Is it possible to pair with device constant pair key using core bluetooth
they said they are not having provision to provide what is the key to enter I'm not sure I completely understand this sentence but if the user is given a device that has a specific pin/key, then that has to be documented somewhere for them. This is the same situation as it is with a SIM card's PIN. That code is set by the manufacturer and the user gets to know it when she buys the card. If the code is the same for all devices, then you can add it to your application and show it to the user in some way. The iPhone application cannot dismiss or enter any value in the pairing dialog, this is sure.

Categories : Iphone

iOS Core Bluetooth Not asking for Pair
If I understand you right you can write a value successfully to a characteristic but you don't get a pairing request. The pairing is triggered by the peripheral. Meaning the peripheral has to refuse the write or read request of your central to a characteristic. Your central gets the refusal "unauthorized authentication" and then tries to pair with the peripheral and showing the pairing alert pop up you are waiting for. This is all done by core bluetooth automatically. The only thing you need to do is change the characteristics options and permissions in your peripheral. This is the apple sample code to trigger a pairing: emailCharacteristic = [[CBMutableCharacteristic alloc] initWithType:emailCharacteristicUUID properties:CBCharacteristicPropertyRead | CBCharacteristicProper

Categories : Iphone

iOS: can I pair more than one bluetooth audio device at once?
The bluetooth specification allows up to seven devices to connect, but it's not straightforward, as it is dependent on the type of device and the service profile it provides. For example, you can have a bluetooth keyboard, mouse, and headset connected at the same time, and an A2DP (Advanced Audio Distribution Profile) device to stream music, but you can't have two devices that performing the same service profile connected at the same time. check the link below for more info. http://en.wikipedia.org/wiki/Bluetooth

Categories : IOS

How to pair Bluetooth device programmatically Android
How can I avoid or dismiss Android's Bluetooth pairing notification when I am doing programmatic pairing? This seems to give you the answer, with the pin entering and all. It involves sending .setPin() whenever you get the message.

Categories : Android

Query unique pair of nodes when pair orders is not important in cypher
OK, I see that you use (*) as a start point, which mean to loop through the whole graph and make each node as a start point.. So the output is different, not duplicate as you say.. +-----------------------------------------------+ | n.name | other.name | common | freq | +-----------------------------------------------+ | "u2" | "u1" | ["f1","f2","f3"] | 3 | not equal to: +-----------------------------------------------+ | n.name | other.name | common | freq | +-----------------------------------------------+ | "u1" | "u2" | ["f1","f2","f3"] | 3 | So, I see that if you try using an index and set a start point, there won't be any duplicates. start n=node:someIndex(name='C') match p=n-[:LIKES]->item<-[:LIKES]-other where n <> othe

Categories : Neo4j

How many devices we can pair via Bluetooth to iPhone?
As it stands in iOS 6.1.4, the current limit for Bluetooth Low Energy devices is 10 simultaneous CONNECTIONS (at least on the NRF8002 chipset). Although the BLE spec says it can in theory have an infinite number of connections, the connection will time out when you try to add an 11th device. As for the pairing table, I've previously had two additional a2dp devices in my pairing table(not connected) and 10 current BLE connections as the maximum. So that is a total of 12 devices in the pairing table on an iPhone 5 running iOS 6.1.4. You could probably have more devices listed in the pairing table, but the one definite is 10 connections is the current max.

Categories : Iphone

pair(const std::pair<_T1, _T2>&) is implicitly deleted because the default definition would be ill-formed Error: when assigning map of unique_ptr
std::unique_ptr is non-copyable, therefore you can't copy a std::map that holds unique_ptrs. You can move it though: void setx(map<int, unique_ptr<B>> x) { this->x = std::move(x); } Note that in order to move the map, you need it not to be a const reference, otherwise you can't move it. Taking it by value allows the caller to use either temporaries or moved lvalues. So now, you'd use your code like this: std::map<int, std::unique_ptr<B>> some_map = ...; some_a.setx(std::move(some_map)); Or like this, using temporaries: some_a.setx({ {1, make_unique<B>(...)}, {2, make_unique<B>(...)} }); As pointed out by 0x499602D2, you can do this in your constructor directly: A::A(map<int, unique_ptr<B>> x) : x(std::move(x)) { }

Categories : C++

Present pair of users at random, and not show that same pair again
I would create a class that consisted of the id's for two users. @interface userPair: NSObject @property (nonatomic, assign) NSInteger user1id; @property (nonatomic, assign) NSInteger user2id; @end I would just create a NSMutableArray of all possible pairs then run this awesome shuffle method: (taken from this answer) - (void)shuffle { NSUInteger count = [self count]; for (NSUInteger i = 0; i < count; ++i) { // Select a random element between i and end of array to swap with. NSInteger nElements = count - i; NSInteger n = (arc4random() % nElements) + i; [self exchangeObjectAtIndex:i withObjectAtIndex:n]; } }

Categories : IOS

Haskell: Overlapping instances of pair with same pair specialization
You can use OverlappingInstances pragma in this case as Box (a,a) is more specific than Box (a,b) so compiler will choose the right instance for you. Informally, you say a is more specific than b if you can instantiate b to a. Another definition can be, if you unify a and b you get a. For example, in (a,b) you can put b=a, so (a,a) is more specific than (a,b). If compiler can not find the most specific instance it will throw error even with OverlappingInstances.

Categories : Haskell

Generate adjacent pair permutations where each side of the pair can only be used once
Here's a quick program I threw together to solve this. It's probably not the most efficient way to go about this, but it gets the job done. l = [(1,2),(2,3),(3,4),(4,5)] # replace with whatever your full list is import itertools for perm in itertools.permutations(l,len(l) / 2): pair_list = [] for pair in perm: if pair[0] in itertools.chain(*(i for i in pair_list)) or pair[1] in itertools.chain(*(i for i in pair_list)): break pair_list.append(pair) if len(pair_list) == len(l) / 2: unused = [] for n in itertools.chain(*(i for i in l)): if n not in itertools.chain(*(i for i in pair_list)) and n not in unused: unused.append(n) print pair_list,'unused:',unused Also, are you sure you want to

Categories : Python

add a new key value pair to existing key value pair object in python
somedict = {"foo" : {"bar" : "bars value"} } somedict['foo']['baz'] = 'baz value' When Python encounters somedict['foo']['baz'] it first looks-up the value of the bare name somedict. It finds it is a dict. Then it evaluates somedict['foo'] and finds it is another dict. Then it assigns to this dict a new key 'baz' with value `baz value'.

Categories : Python

Can CoreBluetooth framework pair and talk to a slave bluetooth 2.0 serial module?
No, CoreBluetooth is for Bluetooth Low Energy. The External Accessory Framework can be used for Classic Bluetooth connection. But to be able to open on a serial link from the iPhone, you need a peripheral that complies with the Made For iPhone (MFi) program, and you need to be an MFi member to be able to buy one. Look at this question for more info: What's needed to use the Apple Accessory Protocol?

Categories : IOS

How to discover another device without using Gamekit, EAaccessory and core Bluetooth framework in iOS?
You will need to be in control of your device, otherwise there is no way. If you're controlling your other device, you can setup Bonjour on it. Beware this is not an easy walk - neither on the device's side nor on the iOS side. The Apple docs (https://developer.apple.com/bonjour) don't help too much, but https://github.com/tolo/HHServices might help you get started with the iOS side. (It's designed for iOS to iOS over Bluetooth, but the code should also work with WiFi with minor modifications. It will not work with Non-MFI Bluetooth devices.) For the device side, you might want to have a look at http://jmdns.sourceforge.net.

Categories : Iphone

Isolating obd scan tool from other bluetooth devices during bluetooth device search
Try what @Erik Smekens suggested. You can connect to OBD-2 without pairing via insecure RFCOMM.

Categories : Java

Will this pair be moved?
Initializer lists are not expressions, so they do not have a type and they do not yield a value. This means that the following: {std::move(key),std::move(value)} Does not in itself create a pair. Initializer lists are just a syntactic construct used for initialization, and in this case the function parameter will be constructed by directly invoking the constructor of pairtype with std::move(key) and std::move(value) as arguments. There is no creation of temporaries involved - the only thing to be aware of is that explicit constructors will not be considered when performing list-initialization (for instance, this would not work with an instance of std::tuple<>). Which means that the invocation of foo we just discussed, i.e.: foo({std::move(key),std::move(value)} Is technicall

Categories : C++

Key Value Pair List
Using one of the subsets method in this question var list = new List<KeyValuePair<string, int>>() { new KeyValuePair<string, int>("A", 1), new KeyValuePair<string, int>("B", 0), new KeyValuePair<string, int>("C", 0), new KeyValuePair<string, int>("D", 2), new KeyValuePair<string, int>("E", 8), }; int input = 11; var items = SubSets(list).FirstOrDefault(x => x.Sum(y => y.Value)==input); EDIT a full console application: using System; using System.Collections.Generic; using System.Linq; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { var list = new List<KeyValuePair<string, int>>() { new KeyValuePair<string, int>

Categories : C#

How to add a key,value pair to a list?
You want to append a dict - note the {}, eg: .append( {abilities_m_l[job_row]['Element Name']:list()} ) And it's more Pythonic and efficient to use [] for an empty list...

Categories : Python

XSL Name Value Pair transformation
This should do it: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/*"> <Attributes> <xsl:apply-templates select="Attributes" /> </Attributes> </xsl:template> <xsl:template match="Attributes"> <xsl:element name="{AttributeName}"> <xsl:value-of select="AttributeValue" /> </xsl:element> </xsl:template> </xsl:stylesheet> When run on your sample data, the result is: <Attributes> <AAA>Value1</AAA> <BBB>Value2</BBB> </Attributes>

Categories : Xml

Subclassing std::pair and std::map in C++
You use auto which finds out that the type (returned by begin) is a map. And map has no inc. Maybe implement std::begin( MyMap ) to retrive the right iterator. But You should probably not derivate, and more wrap a pair.

Categories : C++

Spinner with Key-Value Pair
Hope this can help you Add Data in in Spinner private void setDataInSpinner(Spinner id, int dataArray) { ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource( this, dataArray, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_item); id.setAdapter(adapter); } To get the selected value of Spinner use this Spinner mySpinner = (Spinner)findViewById(R.id.spinner); String Text = mySpinner.getSelectedItem().toString(); Or You can use setOnItemSelectedListener to get the selected values String value = GetClassCode.getCode(Text);//here u have to pass the value that is selected on the spinner Create a Class public class GetClassCode { static HashMap<String, St

Categories : Android

Parsing "Key" = "Value" pair
I'm not familiar with that dialect, but since you've tagged regex, here's one that should do it in principle: ^"([^"]*)" = "([^"]*)";$ You're not being exact about the format so you may need to add some conditional white-space here and there depending on your input format. Another thing that might come into play is the need to escape the parentheses. For example with sed, you'd have to write: echo '"Key" = "Value";' | sed -e 's#^"([^"]*)" = "([^"]*)";$#key is 1 and value is 2#'

Categories : Objective C

EC2 Key Pair Change
You can create an AMI of your current instance and spin up a new instance with a different key pair using that AMI. You can then associate your elastic IP with the new instance. Is that what you're looking to do?

Categories : Amazon

AWS ssh key pair with passphrase
Directly through the console or the api you can't. It is possible to create a keypair using external tools and import it. You can try to create the keypair with password and then import it using the console or the api. For more information take a look at http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html

Categories : Amazon

The possible value of the key-value pair is unhashable?
The problem is the other half of the line, the entrez_eq.get(v). There, you're using a list v as the key to what's presumably a dict or other mapping. (You can tell v is a list because it's a value from dbrefs, and you print dbrefs, so it's either ['MGI:1920949'] or ['73699'].) Whenever you run into a problem like this, where you can't figure out where an error is coming from, try breaking it into pieces. Instead of this: sp_eq[row.get('name')] = entrez_eq.get(v) Do this: key = row.get('name') value = entrez_eq.get(v) sp_eq[key] = value Then you can find out which of the three subparts of the expression is raising—and, if you still don't know why, you have access to the intermediate values and types, so you can log them.

Categories : Python

SQL Compare on 1st or 2nd value pair
May as well call it an answer. You can use and / or clauses in you where statement. where (psi_a = ? and gpm_a = ? ) or (psi_b = ? and gpm_b = ? ) You can also put a case clause in the select statement that will show you which where clause found the match if it's needed.

Categories : SQL

Undefined reference std::pair
The linker fails to find definition of Q::X. This is probably because std::pair<> constructor takes arguments as references to const, and Q::X is an l-value, hence it requires an external definition of Q::X to be able to refer to that. A portable fix: int const Q::X;

Categories : C++

Construct a std::map from a std::vector >
Every standard library container can be constructed from an iterator range. In your case: std::map<std::string, Foo> mymap(myvector.begin(), myvector.end()); If you want to add the lower-case versions of the strings, you need to pass the values through a transforming iterator. Unfortunately that’s not included in standard C++ but it’s rather straightforward to implement. Boost also includes a version: // Make the pair's key lower-case std::pair<std::string, Foo> make_lower(std::pair<std::string, Foo> x) { std::transform(x.first.begin(), x.first.end(), x.first.begin(), ::tolower); return x; } std::map<std::string, int> mymap( boost::make_transform_iterator(myvector.begin(), make_lower), boost::make_transform_iterator(myvector.end(), make_lowe

Categories : C++

C++ map from std::pair to some internal class
Just don't reuse standard library names such as map for variable names. Call it something meaningful, and it will also remove the conflict between type and variable. Also, you forgot to #include <utility> to bring in std::pair.

Categories : C++

std::set containing pair with custom comparator
Since a record cannot be less than itself, or its equivalent self, ensure that your comp function returns false if two records have the same ID, regardless of weight. // Assuming that your previous comp_f was correct, here is the new one: struct comp__f { bool operator() (const pair<double, int>& lhs, const pair<double, int>& rhs) const{ if(lhs.second == rhs.second) return false; // ADD THIS LINE if(lhs.first < rhs.first) return true; if(lhs.first > rhs.first) return false; return lhs.second > rhs.second; } };

Categories : C++

Extracting key/value pair from dictionary
Try this, using the dictionary comprehensions available in Python 2.7 or newer: { k:v for k,v in my_dict.items() if 'Peter' in k } Alternatively, if we're certain that the name will always be in the first position, we can do this, which is a bit faster: { k:v for k,v in my_dict.items() if k[0] == 'Peter' } If you're using an older version of Python, we can get an equivalent result using generator expressions and the right parameters for the dict() constructor: dict((k,v) for k,v in my_dict.items() if k[0] == 'Peter') Anyway, the result is as expected: => {('Peter', 'Cell1', 8): 8, ('Peter', 'Cell1', 6): 0}

Categories : Python

Returning key/value pair in javascript
Your goal is to enrich the obj map with new properties in order to get {2:4, 10:20,30:60,50:100, 100:200}. But instead of doing that you're replacing the value of the obj variable with an object having only one property. Change obj = {original_value : doubled_value}; to obj[original_value] = doubled_value; And then, at the end of the loop, just log console.log(obj); Here's the complete loop code : for(var i=0; i< Num.length; i++) { var original_value = my_arr(Num[i]); var doubled_value = doubling(original_value); obj[original_value] = doubled_value; } console.log(obj);

Categories : Javascript

Query for key value pair structure
Whether this is a good design or not, you can accomplish what you want with the data as presented in the OP. The key is to note that the difference between the ids identifies the rows. I must emphasize that an explicit "record" reference should be included in the design, so I would call this message a hack. select (id - FieldId), max(case when FieldName = 'DueDate' then value end) as DueDate, max(case when FieldName = 'TargetDate' then value end) as TargetDate, max(case when FieldName = 'Status' then value end) as Status from t group by (id - FieldId) By the way, the fact that you have to store dates as strings is further indication of a problem with the data structure. Even in an EAV structure, you can have "ValueStr", "ValueDate", "ValueInt" as separate columns

Categories : SQL

Accessing a pair after moving it into a map
Yes, you can use the pair. Insert will return a reference to the pair that already exists in the map. Documentation is here: http://www.cplusplus.com/reference/map/map/insert/

Categories : C++

Search for key-value pair in string
You can use a Regex to get them (Pattern class, with the MULTILINE flag flor simplicity): import java.util.regex.*; public class RegexStrings { public static void main(String[] args) { String input = "Response: Success "+ "Message: Extension Status "+ "Exten: 1234 "+ "Context: from-sip "+ "Hint: DS/5678 "+ "Status: 9"; String exten = null; String status = null; Matcher m = Pattern.compile("^Exten: (.+?)$", Pattern.MULTILINE).matcher(input); if (m.find()) { exten = m.group(1); } Matcher m2 = Pattern.compile("^Status: (.+?)$", Pattern.MULTILINE).matcher(input); if (m2.find()) { sta

Categories : Java

How to find pair with kth largest sum?
I start with a simple but not quite linear-time algorithm. We choose some value between array1[0]+array2[0] and array1[N-1]+array2[N-1]. Then we determine how many pair sums are greater than this value and how many of them are less. This may be done by iterating the arrays with two pointers: pointer to the first array incremented when sum is too large and pointer to the second array decremented when sum is too small. Repeating this procedure for different values and using binary search (or one-sided binary search) we could find Kth largest sum in O(N log R) time, where N is size of the largest array and R is number of possible values between array1[N-1]+array2[N-1] and array1[0]+array2[0]. This algorithm has linear time complexity only when the array elements are integers bounded by small

Categories : Performance

How to return the content of std::pair?
Just return the pair of int & std::string itself as the multimap contains that as its element std::pair<int,std::string> client(){ //... }

Categories : C++

Pair SQL records without Cursor
You can use ROW_NUMBER() and some simple maths to generate PairIDs: declare @Tab table (UID int not null,Date date not null,time time not null) insert into @Tab (UID,Date,Time) values (1,'20130607','08:00'), (2,'20130607','10:00'), (3,'20130607','13:00'), (4,'20130607','17:00'), (5,'20130608','07:00'), (6,'20130608','11:00'), (7,'20130608','14:00'), (8,'20130608','18:00') ;With PairedRows as ( select UID,Date,Time, (ROW_NUMBER() OVER (ORDER BY Date,Time) + 1) / 2 as PairID from @Tab ) select p1.UID,p1.Date,p1.Time,p2.UID from PairedRows p1 inner join PairedRows p2 on p1.PairID = p2.PairID and p1.UID != p2.UID (I've done this as a SELECT, but it's easy enough to switch it to an UPDATE if this is meant to be a permanent pairi

Categories : Sql Server

How to insert a new key value pair in array in php?
If you are creating new array then try this : $arr = array("key" => "value"); And if array is already created then try this : $arr["key"] = "value";

Categories : PHP

create key-value pair Borland C++
C++Builder can only consume instances of Delphi-based Generics types, like TDictionary, that originate from Delphi code. Unfortunately, it cannot instantiate Delphi-based Generics types. If you are not trying to interact with Delphi code, then you should use the STL's std::map class instead: #include <map> std::map<AnsiString, AnsiString> d;

Categories : C++

std::pair alignment control
A std::pair basically reduces down to: class xxx { T1 _t1; T2 _t2; }; The alignment of the two members is defined by the alignment in force when the template itself is defined, not just when it's used to instantiate an instance. The Microsoft implementation of the STL uses the symbol _CRT_PACKING to define the packing used for all STL components. By default the packing is set to 8. If you define this symbol yourself before including the header that defines std::pair (<utility>) you can theoretically override the packing and set your own. Be aware of potential problems you may encounter calling libraries or other code that assumes the standard packing.

Categories : C++



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.