Posts

php - How to quickly find elements in a sorted array -

i new here have checked previous posts , although similiar, not quite enough i'm trying do. have csv file 40k+ records , retrieve ldap records of 70k+ records; both stored in multidimensional array variable. objective display records not match. current solution taking on 20 minutes process inefficient. created outer loop each record checks match in ldap recordset (inner loop), if found skip next record , unset ldap array index shrink array next loop. have sorted both arrays in ascending order speed process. ideas, tweaks, speed process? foreach($csvarray $csvindex=>$csvalue) { echo "<br />csvarray record: <strong> ".$counter."</strong><br />\n"; if($counter <= 1) { ($i = 0, $max=$rs["count"]-1; $i < $max ;$i++) { //loop through ldap array if($csvalue[0] == $rs[$i]['uid'][0]) { // csv netid & ldap netid echo "csv netid: ".$csvalue[0]; e...

c# - How do I nest async statements were the execution of the nested statement is dependant on the result of the first? -

i'm trying build asynchronous method read record or create if no matches found. i using async api provided sqlite.net. this far have got think i'm struggling concepts, existingopponent null insert executed. public async task<testentity> createorget(string name, cancellationtoken cancellationtoken = default(cancellationtoken)) { var existingentity = await database.getconnection(cancellationtoken) .table<testentity>() .where(o => o.name == name) .firstordefaultasync(); if (existingentity == null) { var newentity = new testentity() { name = name }; var rowcount = await database.getconnection(cancellationtoken) .insertasync(newentity); return newentity; } return existingentity; } is able point me in right direction? was query problem rather async problem.

different RA/Decs returned by pyEphem -

i using pyephem calculate ra/decs of satellites , i'm confused different values computed , described on http://rhodesmill.org/pyephem/radec.html this bit of code sat=ephem.readtle("satname ", \ "1 38356u 12030a 14148.90924578 .00000000 00000-0 10000-3 0 5678",\ "2 38356 0.0481 47.9760 0002933 358.9451 332.7970 1.00270012 3866") gatech = ephem.observer() gatech.lon, gatech.lat = '-155.47322222', '19.82561111' gatech.elevation = 4194 gatech.date = '2014/01/02 07:05:52' sat.compute(gatech) print 'a_ra=',sat.a_ra,'a_dec=',sat.a_dec,'g_ra=',sat.g_ra,'g_dec=',sat.g_dec,'ra=',sat.ra,'dec=',sat.dec gives a_ra= 0:52:40.75 a_dec= -3:15:23.7 g_ra= 1:14:10.55 g_dec= 0:06:09.8 ra= 0:53:23.57 dec= -3:10:50.5 if change observers location gatech.lon, gatech.lat = '-5.47322222', '19.82561111' i get a_ra= 1:15:36.95 a_dec= -2...

Java String Translation -

is possible translate string other language in java? example, if have code: class example { public static void main(string[] args) { string s = "text"; system.out.println(s); } } can translate s other language in code (for example someclass.translatetosomelanguage(s) )? the place supported in jdk simpledateformat formatting dates providing locale . you'll need external library else.

c - Binary Search Tree Madness -

i have write implementation of binary search tree can handle library's stock. reads text file books , add books tree in alphabetic order. have been fighting insertar() function code days , can't make work properly, receives pointer root of tree along data related book. if root null, inits node values entered in function , asings memory direction null node. problem is, doing locally , in end doesnt assigns it. can me correct specific function please? functions , structs: nodoarbol: node arbolbin: binary tree, has pointer root node , int number of elements initnodo: inits node, returns pointer node raiz: returns pointer root of binary tree clear,clear_aux: clears tree ingresar: insert() function , source of problem imprimir: rints elements of node. #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct nodoarbol { char nombre[51],autor[51]; int valor,stock,anno; struct nodoarbol *der; struct nodoarbol *izq; } tnodoa...

php - How to query and select * where a value is a INT? -

this sql far , nothing working. $st = db::getinstance()->query("select * users group = 1 order joined asc"); all want select * table users group = 1 (order by...) problem group column int. cannn't retrieve data it. if try group = '1' is there function/way through issue? thanks! group reserved word in many sql implementation. try using users.group = 1 . oracle sql reserved words : https://docs.oracle.com/database/121/sqlrf/ap_keywd001.htm#sqlrf55621 mysql reserved words : http://dev.mysql.com/doc/refman/5.6/en/reserved-words.html mssql reserved words : http://msdn.microsoft.com/en-us/library/ms189822.aspx

class - How does return by reference work in C++ classes? -

in c++ , if type: int x=5; int &y=x; then y act alias memory location original x stored , can proven/tested printing memory location of both, x , y the output of similar program below: x @ location: 0x23fe14 y @ location: 0x23fe14 but classes ? when member function declared return type reference , function uses this pointer, function returning? for example: #include <iostream> class simple { int data; public: // ctor simple(): data(0) {} // getter function int& getter_data() { return this->data; } // modifier functions simple& add(int x=5) { this->data += x; return *this; } simple& sub(int x=5) { this->data -= x; return *this; } }; int main() { simple obj; obj.add().sub(4); ////////// how & why working? ///////// std::cout<<obj.getter_data(); getchar(); } why possible execute command in highlighted line? wha...