Posts

Showing posts from May, 2014

symfony - KnpMenuBundle: why using 'route' instead of 'uri' transforms the <a> element to <span>? -

i'm creating bundle knpmenubundle on symfony 2.3.x , doesn't mark current element, so, thought problem has using 'uri' instead of 'route' since i'm on symfony , all, thing is, when use route, element changes from <li><a href="engineerings">engineerings</a></li> to: <li><span>engineerings</span></li> the <a> element public function mainmenu(factoryinterface $factory, array $options) { $factory = new menufactory(); $menu = $factory->createitem('root'); $menu->setchildrenattributes(array('id' => 'tabs', 'class' => 'fl')); $menu->addchild('cooperators', array('uri' => 'companies')); $menu->addchild('customers', array('uri' => 'clients')); $menu->addchild('engineerings', array('uri' => 'engi

objective c - Is it possible to use Background Fetch (or any other iOS mechanism) to download some files at specified interval? -

i have basic knowledge of ios programming, though, understand concepts , limits (and i'am experienced programmer on other platforms). i asked prepare project, require ios app download basic office files (whenever available) , keep them in local ipad storage, accessible offline. sake of simplicity let's say, published on kind of web servers. , should work on 3g. now, understand, first way keep data (files) date synchronize them whenever user opens app , has access network (internet). it becomes more complicated when need in addition try keep them synced while app not running / ipad/iphone lays on table. is possible use f.e. "background fetch" (or other mechanism) download files in background? know 30 second window (this should enough, or - if must enough, can adapt synchronized files sizes make possible). don't need have strict intervals, nice, though. i understand, when files stored locally, it's not rocket science open them in installed apps (li

cmd - "Invalid namespace" by retrieving ProcessorId through wmic -

i not understand why cmd command wmic cpu processorid works on 2 of 3 computers on third returning "invalid namespace" what wrong? you might want try running "wmic cpu list /format:list". guess different version of wmic , name of variable different. command should give list of able wmic cpu call.

c# - Upload a .net application online? -

i'm project on financial data visualization. nothing advanced really, user input manipulated , visualized output charts , numbers. thing though, though plan have .net desktop application begin idea later transform web based application. , since i've got no experience whatsoever question simply: can 1 write desktop application in c# .net , later "upload" or "convert" web based interface without work? i've heard of asp.net seems pretty used framework web applications, cannot find converting desktop application asp.net application. thanks in advance! if divide application parts should - e.g. business logic, data access layer etc (into different dlls preferably), need create new ui, isn't bad creating app scratch... there confusion in definitions. (and seems of guys posted answers here) have misunderstood technology. you can't compare asp.net c#, because 1 web framework, other programming language. asp.net can , use c# (or vb

knitr doesn't convert xtable output on R 3.0.2 -

i create tex table using xtable() . here's minimal example worked when used same r version on win 7. \documentclass[a4paper,12pt,twoside]{article} \begin{document} <<load-packages,include=true,echo=true>>= library(xtable) @ <<testing-xtable,echo=true,cache=false,include=true>>= tab <- matrix(1:50,nrow=10) rownames(tab) <- letters[1:10] print( xtable( x=tab, caption="a table", label="tab", align=rep("c",times=6), digits=3, display=rep("f",times=6) ), sanitize.colnames.function=identity, include.rownames=false, table.placement="h" ) @ \end{document} instead of nice table verbatim code output of xlatex() in pdf document. here's output of knitr: > grdevices::pdf.options(usedingbats = false); require(knitr); opts_knit$set(concordance = true); knit('xtable.rnw', encoding='utf-8') loading required package: knitr processing fil

php - Query does not work when i fetch data and insert it into a table -

i trying insert table results of select statement table. select statement works insert statement not work. please me. $query="select * subject sub_code = '$enrol' "; $result = mysql_query($query); while($row = mysql_fetch_array($result)) { $csubject=$row['sub_name']; $cday=$row['sub_day']; $ctime=$row['sub_time']; echo "<strong>". $csubject . "</strong>"; } $query = mysql_query("insert client (client_csub_code,client_csub_name,client_csub_day,client_csub_time) values ('$enrol','$csubject','$cday','$ctime')"); header("location:homeclient.php"); ?> you asked how these 2 1 query. this how: $query = mysql_query("insert `client` ( `client_csub_code`, `client_csub_name`, `client_csub_day`, `client_csub_time` ) select `sub_code`, `sub_name`, `sub_day`, `sub_time` `subject` `code` = '$enrol'"); // add error checking

javascript - add OR operator on mql over freebase -

i want create query show artists thay in reggae , rock music try not work.. [{ "id": null, "name": "rock music", "or:name": "reggae", "type": "/music/genre", "/music/genre/artists": [] }] since you're after artists, i'd recommend turning query inside out , asking artists, not genres. return artists names, ids, , genres artists include genre of rock music or reggae: [{ "id": null, "name": null, "type": "/music/artist", "genre": [{ "name|=": [ "rock music", "reggae" ] }], "g:genre": [] }] it's more robust use ids genres rather names in case decides genre should called "rock" instead of "rock music."

php - Function has no effect for the first item in the array -

i have function change quantity of product , store in session. public static function updateproduct($product_code, $newqty) { foreach ($_session["products"] $cart_itm) //loop through session array { if($cart_itm["code"] == $product_code) //the item exist in array { $product[] = array('name'=>$cart_itm["name"], 'code'=>$cart_itm["code"], 'qty'=>$newqty); } else { //item doesn't exist in list, retrieve old info , prepare array session var $product[] = array('name'=>$cart_itm["name"], 'code'=>$cart_itm["code"], 'qty'=>$cart_itm["qty"]); } } //found user item in array list, , increased quantity $_session["products"] = $product; return; } but if there 2 or more products in array, function works last added product. have idea? ps:

css3 - resize portionally image and center in container -

i want display image in full-width gallery. container static: #container{ width:100%; height:400px; } <div id="container"> <img src="myimage.jpg"> </div> i have images of different dimensions, want display image in full width without deformate in height, centering image (in height way) diplay in center. if want keep same aspect ratio images different dimensions best solution patsy issa saying. use css #myimage{ background: url("myimage.jpg") no-repeat center center; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; width:100%; height:400px; } and html <div id="container"> <div id="myimage"></div> </div> jsfiddle: http://jsfiddle.net/qbpy6/

Search for values in table1 that match values in table2 without joins (Sql Server 2008) -

i ran situation have 2 tables store employee information, table1 employees , table2 3rd party temps. these tables use different convention ids (not have control over). the problem oftentimes these 3rd party temps become employed , there no link between these tables. when happens, need make sure don't exists in table2 before create them. right want identify matches on dob & last 4, although i'm going add @ least first name criteria right i'd start somewhere. the columns although name differently same (dob = birth date, code = last 4) create table table1 ([emp_id] int, [dob] date, [code] varchar(10)) ; insert table1 ([emp_id], [dob], [code]) values (55556, '1966-01-15', '5454'), (55557, '1980-03-21', '6868'), (55558, '1985-04-26', '7979'), (55559, '1990-10-17', '1212'), (55560, '1992-12-30', '6767') ; create table table2 ([user_id] int, [birth_date] date, [last4] varchar(

templates - Writing a very simple event class in C++ -

i'm trying write simple event or message class in c++. want event hold time of occurrence , data specific event type. have @ moment following class eventdata{ public: virtual ~eventdata(void) = 0; }; struct event{ event(eventtype type, time time, eventdata *data = nullptr): type_(type), time_(time), data_(data) {} ~event(void){ if(data_) delete data_; } //disable copying, event memory managed eventmanager event(const event& other) = delete; const eventtype type_; const time time_; const eventdata *data_; }; in main loop, have this, bool running = true; while(running){ const event* nextevent = evtmanager.getnextevent(); switch(nextevent.type_){ case evt_a: const eventadata* data = static_cast&lteventadata*&gt(nextevent.data_); //do stuff break; } ... case evt_end: running = false; break; } } the question if there more effi

javascript - JS/jQuery passing array/variable/data to PHP in same page? -

im hoping can point me in right direction. i have php page, includes html markup , js/jquery routines build array of 'user choices' based on 'user input' (checkboxes..etc). my question is, how can pass off (multidimensional) array php, in same page? (ultimately want save data/array php session) while looking around, read using (external) .php script do,, not im after, i'm hoping same page i'm in... without refresh. will $.post() me? without page refresh (if suppress event or whatever)... , -not- using external .php script? i understand php runs/executes first... else.. i'm not trying php data being sent js/ajax.. outside of save session array.. ajax seems needed? to summarize: 1.) php , js in/on same page (file) 2.) no page refresh 3.) no external php script 'anything'. 4.) trying (multidimensional) array php session in same page. 5.) trying 'update' php session array each time user 'clicks' on checkbox.

javascript - Code works in console/scratchpad but not in a Greasemonkey script? -

i'm trying write script make map larger on google flights . i've got jquery working in firefox scratchpad. script trying accomplish: $('div').filter(function(){ return $(this).css('width') == '648px' }).css({"width":"900px","height":"550px"}); but when paste greasemonkey script, doesn't work. if add console.logs debug, can verify script running , filter working correctly, it's not modifying css. ideas? sometime need make sure script executed after page loaded $(function(){ // code here }); you can try settimeout , put 2sec (2000) var myfunc = function(){ // code here }; settimeout(myfunc, 2000);

c++ - Passing an object to a function, scope, and destructors -

recently i've been getting programming in c++ , have come across interesting while programming else. in code below defined class pointer member gets deleted in class' destructor. i have defined function takes test_object object argument calls 1 of get_val() method nothing more report value held in memory address pointer pointing to. now when call function twice correctly prints value in held internal pointer correctly once, core dumps after second. correct me if i'm wrong, believe reason happens because after first time function called object's destructor called because object has gone out of scope , destroyed. the way think of preventing passing object reference. there other way prevent happening? seems bit dangerous pass object reference since object can modified in function call lead headaches later on. i've tried making argument const, error stating ‘const test_object’ ‘this’ argument of ‘void test_object::get_val()’ discards qualifiers argument.

c# - How to view Horizontal scroll in the toolstripmenuitem -

Image
i have created toolstipmenuitem in added lot of toolstripmenuitems sub menus. , restricted maximum size of toolstripmenuitem results in: vertical scrolling automatically becomes enabled shown in image. but need horizontal scrolling. there way achieve this?

c# - Can I speed up code by moving typeof out of loops? -

this question has answer here: efficiency of c#'s typeof operator (or whatever representation in msil) 3 answers i have code executes typeof many times inside loops. i'm wondering if should call typeof outside loops , use variable? my code this. for(int i=0; < 1000; i++) { type t = foo(i); if(t == typeof(string)) { //.... } } is following code faster, slower or no difference? type s = typeof(string) for(int i=0; < 1000; i++) { type t = foo(i); if(t == s) { //.... } } instead of running few c# tests see runs faster. i'm looking answer can explain happens when typeof used. does produce compile time constant? no (as in extremely negligible), typeof() done @ compile-time--the work type comparison. should asking why you're checking types when using polymorphism.

MATLAB eps output different from on screen version using painters renderer -

i have issue when outputting eps version of image matlab. eps looks different on screen version , png output of same image. the code below, run on matlab r2012b, produces eps file different png. notably grid offset on right hand panel same (random) data flipped axis. clear close a=rand(40,20); figure subplot(1,2,1); imagesc(0.5:19.5,-85.5:2.5:14.0,a); ylim([-6.2 11.1]); set(gca,'fontsize',13); subplot(1,2,2); imagesc(0.5:19.5,-85.5:2.5:14.0,a); set(gca,'ydir','normal'); ylim([-6.2 11.1]); set(gca,'fontsize',13); colormap(pink(10)); print('-depsc2','a.eps'); print('-dpng','a.png'); any ideas why? error doesn't seem occur if using non-'painters' renderer. , grids fine when axis uses standard direction imagesc, not when flipped. thanks!

javascript - jQuery, resize then fadeIn -

i search around don't know how one... receive through $.ajax() data render through jquery template. want: create template object (this 1 done) set hide() (this 1 done) insert page height 1 or 0 then make effect re-size (by height) inserted div make fadein on template so base thing need re-size (slowly) page, add there hidden div (rendered template) , make fadein function on it. same thing on fadeout. you'll need use callback functions - $( "#something" ).animate({ height: "100", width : "100" }, 5000, function() { $('#someotherthing').fadein(); });

c# - Network Command Processing with TPL Dataflow -

i'm working on system involves accepting commands on tcp network connection, sending responses upon execution of commands. basic stuff, i'm looking support few requirements: multiple clients can connect @ same time , establish separate sessions. sessions can last long or short desired, same client ip able establish multiple parallel sessions, if desired. each session can process multiple commands @ same time, of requested operations can performed in parallel. i'd implement cleanly using async/await and, based on i've read, tpl dataflow sounds way cleanly break processing nice chunks can run on thread pool instead of tying threads different sessions/commands, blocking on wait handles. this i'm starting (some parts stripped out simplify, such details of exception handling; i've omitted wrapper provides efficient awaitable network i/o): private readonly task _servicetask; private readonly task _commandstask; private readonly cancellatio

php - opencart - get parent category name/id on a sub-category page? New -

okay, i've been asked repost moderator deemed 'new' question thread: opencart - parent category name/id on sub-category page i believe valid question related title have posted here in compliance. appreciated: being newbie concept i'm struggling interpret logic within original thread [above] when applying particular scenario; i'm trying display displayed category's parent category name. in category.php i've included line $categories = explode('_', $this->request->get['path']); having difficulty in displaying parent category name. i'm unclear correct variable name use in category.tpl display this. please advise? thanks. find (catalog/controller/product/category.php) around line 95 if ($category_info) { add inside if($category_info['parent_id'] != 0){ $this->data['parent_cat_info'] = $this->model_catalog_category->getcategory($category_info['parent_id']); } now in template fi

asp.net - Similarity of Connection pooling in ADO.NET and Throttling in WCF -

can explain me connection pooling in ado.net , throttling in wcf same. they seem similar. sql connection pooling reusing. connecting database server typically consists of several time-consuming steps. physical channel such socket or named pipe must established, initial handshake server must occur, connection string information must parsed, connection must authenticated server, checks must run enlisting in current transaction, , on. in practice, applications use 1 or few different configurations connections. means during application execution, many identical connections repeatedly opened , closed. to minimize cost of opening connections, ado.net uses optimization technique called connection pooling. connection pooling reduces number of times new connections must opened. pooler maintains ownership of physical connection. manages connections keeping alive set of active connections each given connection configuration. whenever user

java - android threading and handler - Changing UI objects from a background thread -

i've written small android application send , receive udp messages on local network. i have udp receiver thread runs listen udp packets, want happen button become enabled on ui when packet received contains string of data. know has done handler, problem being have small amount of knowledge threads , little knowledge handlers. able shed light on how handler put code? thanks code: public void startudplistener() { // creates listener thread listen = true; thread listenthread = new thread(new runnable() { @override public void run() { try { log.i(log, "listener started!"); datagramsocket socket = new datagramsocket(broadcastport); socket.setsotimeout(1500); byte[] buffer = new byte[buffersize]; datagrampacket packet = new datagrampacket(buffer, buffersize); while(listen) { try { log.

c++ - How to get row POST request data from fastcgi++ -

how can row post request data client using fastcgi++ library , show on web page. i tried example below out << "<h1>post data</h1>"; if(environment().posts.size()) { for(http::environment<wchar_t>::posts::const_iterator it=environment().posts.begin(); it!=environment().posts.end(); ++it) { out << "<h2>" << encoding(html) << it->first << encoding(none) << "</h2>"; if(it->second.type==http::post<wchar_t>::form) { out << "<p><b>type:</b> form data<br />"; out << "<b>value:</b> " << encoding(html) << it->second.value << encoding(none) << "</p>"; } else { out << "<p><b>type:</b> file<b

php - How to add attribute for outermost decorator? -

hope can shed light on this: i have decorator wraps tr / td tags on various elements. far, good. however, have 'break' element, puts in blank area on form grouping. this has following php: public $elementbreakdecorator = array( 'viewhelper', 'errors', array(array('data' => 'htmltag'), array('tag' => 'td', 'class' => 'form_break')), array('label', array('tag' => 'td', 'colspan'=> '4')), array(array('row' => 'htmltag'), array('tag' => 'tr')) ); used follows: $this->addelement('hidden', 'break', array( 'decorators' => $this->elementbreakdecorator, 'label' => 'optional text break element') ); and generated following markup: <tr> <td id="break-label"> <label for="break" col

objective c - iOS: Nonexistent Pointer is Crashing App -

Image
when open specific storyboard scene, app crashes error: "incorrect checksum freed object - object modified after being freed". i've got "exc_bad_access" crashes going on, it's 1 or other. couldn't find troubled pointer, tested out nszombieenabled . lead me message on crash: *** -[nscontentsizelayoutconstraint seconditem]: message sent deallocated instance 0x1e0a5220 now, searched project [nscontentsizelayoutconstraint seconditem] , , nscontentsizelayoutconstraint , seconditem individually. exists in project. i'm still new objective-c, , have no idea next. also, run fine 1 out of 5 times on device , simulator. happened with: -[nsattributedictionary release]: , no in project either. also, *** -[pitchdetector addsamples:innumberframes:]: . keep changing, , can't find these anywhere in project. , runs fine sometimes, on simulator, makes frustrating since error keeps changing on device when crashes. to switch views in storyboard, i'm u

entity framework - Solution for "Validation failed for one or more entities. See 'EntityValidationErrors' property for more details." -

i encountered error, did not provide detail root cause figured out problem is. wanted share others encounter might have success in solving problem. i had following class: public class bankuser : identityuser, iuserprofile { #region iuserprofile members [display(name = "first name")] public string firstname { get; set; } [display(name = "last name")] public string lastname { get; set; } [required] [display(name = "email address")] [emailaddress(errormessage="invalid email address")] public string email { get; set; } [display(name = "time zone")] public int timezone { get; set; } public dictionary<string, string> timezoneoptions { { dictionary<string, string> d = new dictionary<string, string>(); d.add("(gmt -10:00) hawaii", "-10"); d.add("(gmt -9:00) alaska", "-9"

java - What is Apache Camel's File "camelLock"? -

whenever start camel route file uri, see camel obtains "lock" on file. instance, if file named myinput.xml , camel creates "lock file" on it, in same directory, called myinput.xml.camellock . what , why camel use it? when camel "release" lock file (delete it)? most importantly , there way configure file uri not lock @ (and if so, how )? hope helps friend readlocks used consumers, poll files if has exclusive read-lock on file (i.e. file not in-progress or being written). camel wait until file lock granted after camel creates marker file , holds lock on camel maintain lock jdk io api cannot determine whether file being used process. option readlockcheckinterval can used set check frequency. option avail ftp component camel 2.8 onwards. notice camel 2.10.1 onwards ftp option fastexistscheck can enabled speedup readlock strategy. notice camel 2.10 onwards read locks changed, filelock , rename use markerfile well, ensure not picking file

HTML: Box above picture -

i want have black box goes side side of page above body background photo. started html think might bit of basic question, want know code task. thanks. i think want buddy: http://jsfiddle.net/7uj69/ html <div class="header"><h1>linton hopkins</h1></div> <div class="wrapper"> <div class="nav"> <div class="item"><a href="#">about</a></div> <div class="item"><a href="#">other</a></div> </div> </div> css body{margin:0; padding:0; background:url(http://www.lintonhopkins.netau.net/1400877.jpg)top left no-repeat;} div{display:block; position:relative;} .header{width:100%; text-align:center; background:#000; padding:10px 0;} h1{color:#fff; margin:0; padding:0;} a{color:#fff;} .wrapper{width:100%;} .nav{width:600px; margin-right: auto; margin-left:auto;} .item{display:inline; padding:5px; float:left;}

c++ - Expected constant in 2d array -

double rainpermonth(const int years) { int monthyear[months][years]; // ... } visual studio shows squiggly line underneath array declaration, saying years must constant when i'm creating array. ide issue because variable has yet initialized, or writing incorrectly? months declared globally. an array size must constant expression - is, value known @ compile time. (some compilers offer c-style variable-length arrays non-standard extension, don't think visual c++ does. if does, it's better not rely on such extensions.) a function argument isn't known @ compile time, can't used array size. best option here probably std::vector<std::array<int, months>> monthyear(years);

coldfusion - null null error in SERVER structure -

i have server variable, structure of structures, highly accessed users (concurrency). values added , deleted very frequently. here small example of server variable. real 1 has more data. <cfset server.structure = structnew()> <cfset s = structnew()> <cfset structinsert(s, 'test11', 'value11', true)> <cfset structinsert(s, 'test12', 'value12', true)> <cfset structinsert(server.structure, 'test1', s, true)> <cfset s = structnew()> <cfset structinsert(s, 'test21', 'value21', true)> <cfset structinsert(s, 'test22', 'value22', true)> <cfset structinsert(server.structure, 'test2', s, true)> every couple of hours, loop structure clean expired data. however, getting error "null null" while looping variable this: <cfloop collection="#server.structure#" item="key"> <cfif structkeyexists(server.structure, key)&

ssh - return code 22, fatal: git-http-push-failed -

i made own git repo on server using git init --bare . added files there , cloned repo myserver git clone http://www.example.com/mygit/repo , cloned perfectly. want push directory git push origin master returning code 22. added ssh public key of pc http://www.example.com/mygit/repo/.ssh/authorized_keys still can't push repo. try add config file in bare repository: [http] receivepack = true

java - To print the sum of the numbers(not digits) in a string -

i asked write function in java sum numbers(not digits) in string. e.g. if string abc35zz400tt15, output should 450. this wrote : public static void getsum(string a){ string[] arr=a.split("(?<=\\d)(?=\\d)|(?<=\\d)(?=\\d)"); int sum=0; for(int i=0;i<arr.length;i++){ if(pattern.matches("[0-9]+", arr[i])) sum+=integer.parseint(arr[i]); } system.out.println(sum); } is there more efficient way didn't satisfied above code. if forward efficiency regex matching , object allocations overkill task. can scan string backwards , accumulate number: int currentpower = 1; int length = string.length(); int value = 0; (int = string.length()-1; >= 0; --i) { char curchar = string.charat(i); if (curchar >= '0' && curchar <= '9') { value += (curchar - '0') * currentpower; currentpower *= 10; } else currentpower = 1; }

object - Angularjs; use $http in service returns reference instead of actual data -

i'm using services directive in angularjs not factory , need populate json file local variable; /* contains projects on town */ lemaireservicess.service('cityservice', function($http) { // json regions , cities loader this.cities = []; // initcities this.initcities = function() { this.cities = $http.get('data/census/cities.js').success(function(data) { return data; }); return this.cities; }; // city info this.getcity = function() { return this.cities; }; }); and in controller have // saved game controller lemairecontrollers.controller('gamecorectrl', function($scope, cityservice) { /* control town project slides */ cityservice.initcities(); $scope.city = cityservice.getcity(); console.log($scope.city); }); but instead of returning actual data, returns; object {then: function, catch: function, finally: function, success: function, error: function}

Is it possible to modify cookie from chrome extension content script? -

if have chrome extension content script, possible modify cookie content script? seems chrome.cookie api can't used content scripts , setting document.cookie don't change it. following code intended delete cookies, document.cookie same after completes: _.each(document.cookie.split(';'), function(s_cookie) { var sname = s_cookie.replace(/=.+/, ''); var = sname + "=;expires=thu, 01 jan 1970 00:00:00 gmt"; console.log(a); document.cookie = a; }); console.log(document.cookie); // nothing changed. if case, want inject script actual page's javascript context, i.e. chrome.tabs.executescript(tabid, {code:yourfunction.tostring()}, callback)

How to know zoom level to display a marker inside google marker cluster -

well, in title : i have thousands of markers google marker cluster (not google marker cluster plus : let me know if help) everything works perfectly but when fire event relative particular marker, i'd display marker alone (not within cluster anymore). since spacial repartition of markers not homogeneous : @ place zoom level of 9 display alone @ place, i'll have set zoom level 15. so the ultimate question : giving particular maker, how "query" marker cluster know : perhaps distance closest maker (giving should able calculate corresponding zoom level) any other helpful information should still miss @ time ... some code ;) /** * computes scale in meters per pixel given zoom , latitute. * * @param {object} opt optional parameters * - zoom * - lat * - precision * * @returns {number} scale in meters per pixel */ google.maps.map.prototype.getmapscale = function (opt){ var circumference = 40075040, zoom,

opencv - Triangulation to find distance to the object- Image to world coordinates -

localization of object specified in image. i working on project of computer vision find distance of object using stereo images.i followed following steps using opencv achieve objective 1. calibration of camera 2. surf matching find fundamental matrix 3. rotation , translation vector using svd method described in zisserman , hartley book. 4. stereorectify projection matrix p1, p2 , rotation matrices r1, r2. rotation matrices can find using homography r=cameramatrix.inv() h camera matrix. problems: triangulated point using least square triangulation method find real distance object. returns value in form of [ 0.79856 , .354541 .258] . how map real world coordinates find distance object. http://www.morethantechnical.com/2012/01/04/simple-triangulation-with-opencv-from-harley-zisserman-w-code/ alternative approach: find disparity between object in 2 images , find depth using given formula depth= ( focal length * baseline ) / disparity for disparity have per

cordova - How to Use Plugins with PhoneGap Build 3.x? -

i writing phonegap build 3.x program, , cannot figure out how configure config.xml , index.html files access of plugins. here config.xml file: <?xml version="1.0" encoding="utf-8"?> <widget xmlns = "http://www.w3.org/ns/widgets" xmlns:gap = "http://phonegap.com/ns/1.0" id = "org.kirsches.pgb" version = "1.0.0"> <name>phonegap build test</name> <description>phonegap build test</description> <author href="http://www.kirsches.org" email="mitch@kirsches.org"> mitch kirsch </author> <preference name="phonegap-version" value="3.1.0" /> <preference name="orientation" value="default" /> <preference name="target-device" value="universal" /> <preference name="fullscreen" value=&quo

Why would this work: Array of pointers to C strings? -

why such checking *(string + i) don't pass after strings printed? output of printf("%p", string + + 1); shows string + + 1 isn't null. i've tried code several times several quantity of strings. maybe of c guru can give answer this? in advance. :-) the code: #include <stdio.h> int main(void) { size_t i; char *string[] = { "hey, baby!", "how ya?", "what heck going on in here?" }; (i = 0; *(string + i); ++i) { printf("%s\t%p\n", *(string + i), string + i); } printf("%p", string + + 1); return 0; } the output: [aenry@mintk50id 2]$ ./test hey, baby! 0x7fff691978e0 how ya? 0x7fff691978e8 heck going on in here? 0x7fff691978f0 0x7fff69197900% [aenry@mintk50id 2]$ gcc -v ... gcc version 4.8.1 (ubuntu/linaro 4.8.1-10ubuntu9) --------edit: turned out, junk code

Notify Facebook users from iOS app -

my ios app gives user option login using facebook account. able see list friends , invite ones selected use app. problem using app request window, friends notification displayed somewhere in app center, rather in notifications panel. unfortunately, sort of notification subtle , might not seen after long time. from obvious reasons, cannot fetch emails of friends great alternative. do know if there way send facebook message or other sort of notification more 'visible' receiver? thanks! i'm not sure if understand problem. if it's problem think you're having, sounds need fill out more information on facebook app's configuration page. from remember when had same issue, need have canvas url set in facebook app's configuration page. if app not going use canvas, need have part filled out in order friends receive app's notification jewel on facebook.

Grails: Domain model relationships based on legacy database -

i'm creating grails application takes data existing legacy database (that's can't modified) , i'm trying wrap head around how represent table relationships in domain model classes. here's sample data: table 1 columns: pid, firstname, lastname, middlename table 1 id composite made of pid , lastname table 2 columns: pid, emailaddress, phonenumber, faxnumber table 1 id composite made of pid, emailaddress, phonenumber table 3 columns: pid, occupation table 3 id pid how represent these 3 tables , relationships (via pid column) domain model classes? class table3{ string id, occupation } class user implements serializable{ table3 pid string firstname, lastname, middlename static mapping = { // need name maping: id composite: ['pid', 'lastname'] } //!!!add equals , hashcode } class profile implements serializable{ table3 pid string emailaddress, phonenumber, faxnumber static mapping = { //

ReadTextAsync in Windows Store app with multibyte file and JavaScript -

i read csv file in javascript written windows store app. if use readtextasync error when using german umlauts. no mapping unicode character exists in target multi-byte code page. i found solution in c# here readtext file in ansii encoding have no idea how solve in javascript? is there someting encoding class in javascript? if convert file utf8 works fine, customer use file saved excel. excel not use utf8 default. the simplest convert file utf-8 that's accessed winjs. there isn't equivalent code in winjs library found c# (for reason, it's not exposed). there simple encodings available utf-8/16(l/h). so, if don't want convert file , you're using javascript, i'd create simple windows runtime component ( walkthrough ) contains behavior want. it's quite simple if follow walkthrough. basically, write code in c#, , when done per rules, becomes available in winjs component. code you'd need write relatively straightforward well: public s

css - Making the text vertical-aligned inside a Gridster's box doesn't work -

i'd have text inside gridster grid , make text-align: center , vertical-align: middle . <li><span>text</span></li> i tried this: .gridster .gs_w > span { text-align: center; vertical-align: middle; } only text-align works. can't use line-height because every grid's height different based on user choose. i assume because not have height , width directly, that's why margin: auto 0px; doesn't work either. got height , width via data attributes. does know gridster's css behavior? how vertically center elements (image or text) inside grid? this how add elements via ajax $.getjson( "data/tiles.json", function( json ) { for(i=0; i<json.length; i++) { gridster.add_widget( '<li class="gs_w" id="'+count+'" style="background-color: '+json[i].rgb+'"><span>teszt</span></li>', json[i].size_x

Unable to serve image (png) with node.js and express -

i've studied similar questions on haven't found solution problem... i've set express route serve images can't return image it's stored. notice i've included statement allow requests origin. happens when make request http://localhost:8080/images/x10.png response empty image element src="http://localhost:8080/images/x10.png instead of http://ubuntubox.dev/images/x10.png , image located , path i'm passing request method. missing? thanks. app.get('/images/*', function(req, res, path){ var imagepath = req.url, url = 'http://ubuntubox.dev' + imagepath; request(url, function(error, response, img) { if(!error && response.statuscode === 200) { res.header('access-control-allow-origin', '*'); res.writehead(200, {'content-type': 'image/png' }); res.end(img, 'binary'); } else if(response.statuscode === 404) { res.status(404); res.type('txt

windows - Joining a PNRP cloud on my local subnet -

i'm experimenting pnrp, using netsh execute basic commands register peers on machine. able add multiple peers on machine opening multiple instances of command prompt, , entering following commands netsh p2p pnrp peer add registration 0.mike after switch cloud context , enter show names , see bunch of info, , names of 2 peers registered through cmd . however, when ask developer (who has machine on same ipv4 subnet) run same commands not appear. expect third peer show on cloud, since we're using same name 0.mike what not understand going on here, , should doing behavior i'd expect? show names designed show names registered on local machines, not names computer aware of. due way name storage works (a 1 way hash algorithm) nodes of network aren't aware of names storing, hashed values. the command want run resolve 0.mike perform lookup name , return ip addresses. can restrict cloud if need to.

java - Short|quick int values comparison -

i learned terminary expression, want little different. i have following: int mode = getmyintvalue(); i comparison following: if(mode == 1 || mode == 2 || mode == 3) //do i know if there short way of doing this, tried didn't work: if(mode == 1 || 2 || 3) //do there short|quick way of doing it? quick "ifs" because makes code more clear, example, more clear this: system.out.println(mode == 1 ? text1 : text2): than this: if(mode == 1) system.out.println(text1): else system.out.println(text1): thanks in advance! well, if don't mind boxing hit, use set prepared earlier: // use more appropriate name if necessary private static final set<integer> valid_modes = new hashset<>(arrays.aslist(1, 2, 3)); ... if (valid_modes.contains(mode)) { } you use int[] , custom "does array contain value" method if wanted... o(n) or o(log n) binary search, suspect we're talking small sets anyway.

Crystal Reports Group Header edit -

Image
i'm trying figure out how change or edit group header titles in crystal reports. group header title pulled sql , have 2 group headers , it's second 1 need edit. reads sep pulled data table, reporting purpose i'd read separate accounts. group headers not text objects, don't know how edit. thanks. click on group tab properties can change name

javascript - Why is Jquery UI Datepicker not making dates unavailable? -

i'm developing datepicker allow administrator choose dates holiday makers staying @ property, , store data in database. want update datepicker potential customers see unavailable dates greyed out. i've managed retrieve data database , pass via json js variable i'm having no luck greying out beforeshowday method. console.log on datestoblock var showed following info: object {fromdate: "2014-02-28", todate: "2014-02-23"} and code far. var datestoblock = <?php echo json_encode($unavailabledates); ?>; $(function() { var unavailabledates = ["false","","not available"]; $( "#fromdatepicker" ).datepicker({ dateformat: "yy-mm-dd", beforeshowday: function(datestoblock) { return unavailabledates; } }); });

c# - Detect Printable Area Width in OpenXml.Wordprocessing -

i'm adding image word document using openxml. i able tell size of image being added, , can resize if want to. want resize if it's wider current column. (in case, there 1 column perhaps change.) is there way know how wide current column and, therefore, able ensure image fits within column? is, large images extending off page. i've updated answer, because answer case when table columns involved, word column in question mean column or text rather column in table. in document, should able following values: // ... var sectionproperties = body.getfirstchild<sectionproperties>(); // pagesize contains width , height properties var pagesize = sectionproperties.getfirstchild<pagesize>(); // contains information surrounding margins var pagemargin = sectionproperties.getfirstchild<pagemargin>(); // contains information spacing between neighbouring columns of text // can useful if use page layout multiple text columns var columns = sectionproper

c# - How to convert a string to a char (to a string) -

i hope title didn't confuse much. i'm trying : static dictionary<string, char> charmap = new dictionary<string, char>() { {"alpha ", 'a'},{"beta ",'y'},{"gamma ", 'g'},{"delta", '='} }; static string charmap(string value) { var strings = value .select(c => { string letter; if (!charmap.trygetvalue(the, out letter)) letter = c.tostring(); return letter; }); return string.join("", strings); } i want to : input - alpha beta gamma delta output - ayg= how can code work? try this var stringtosearch = value.split(new[] { ' ' }, stringsplitoptions.removeemptyentries).tolist(); var result = string.concat( charmap.where(o => stringtosearch.contains(o.key)).tolist(

shell - Counting the Number of Characters in a File Using Bash and Assigning to Variable -

i need loop through text file provided , count number of characters in file. file contain 1 word supposed analyze. basically, need know length of word. want assign length variable have defined in bash file. here's have(ignore other if statement @ end, know working properly. need while loop): #!/bin/bash file=$1 count=0 numchars=0 while ifs= read -rn1 char; if [[ "$char" == $'[a-za-z0-9#$+%@]' ]]; let numchars=numchars+1 fi done < "$file" if [ -r "${file}" ]; if /bin/egrep -q [09] $file ; let count=count+5 fi fi echo $count echo $numchars the file contain 1 word in case can do: # read whole file in variable w="$(<"$file")" # length echo "length is: ${#w}" option 2: using wc len=$(( $(wc -c < "$file") - 1 ))

Opening same file in two windows in Emacs -

say have opened file abc.cpp in 1 emacs window, want open in window. if c-x c-f , locate file, cursor goes original window , file not open in window placed cursor. if c-x b , identify buffer, cursor goes original window well. hope can put cursor in other window, , open file in window, no matter whether file opened already. how can that? 1 way seems work use mouse, go file menu , choose open file, not nice... that 1 easy! command c-x 2 split window showing buffer in 2 horizontally. relevant command split-window-vertically .

linux - creating two child processes in C and execute them one after the other -

i have 2 programs program_a , program_b, called c code. program_b has executed after program_a finishes work. i tried use fork() , execl() accomplish goal, seems program_b wont executed @ all.. can 1 give me correct structure on in order should create child processes? you need wait first child finish, fork , execl next child. #include <stdio.h> #include <stdlib.h> #include <unistd.h> void die(char *msg) { fprintf(stderr, "error: %s\n", msg); exit(exit_failure); } int main(void) { pid_t pid = fork(); if (pid < 0) die("fork a"); if (pid == 0) { // child execl("./program_a", "program_a", (char*)0); die("exec a"); } else { // parent wait(null); pid = fork(); if (pid < 0) die("fork b"); if (pid == 0) { // child execl("./program_b", "program_b", (char*)0);

c# - Why do I keep getting 403 User does not have sufficient permission for this profile error from Analytics API -

edit: have read following posts on stack overflow, don't think have solution looking for: google analytics throws 403 error google analytics api: "user not have sufficient permissions account." i creating installed application in c# access , display google analytics data. i have read google's documentation oauth v2.0 , analytics v3 api, , cannot retrieve analytics data. here have done far. navigate following url in web browser prompted log in google account (the account owns analytics account , has full ownership , permission) or if browser has saved login, accept screen comes asking me confirm want allow app access analytics data. here url: https://accounts.google.com/o/oauth2/auth?redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=code&client_id=xxxxxx.apps.googleusercontent.com&scope=https%3a%2f%2fwww.googleapis.com%2fauth%2fanalytics.readonly&approval_prompt=force&access_type=offline"); after code returned , retrieved brow