Posts

Showing posts from February, 2011

How do I get the template type of a given element at runtime in C++? -

i'm designing simple array class capability of holding type of object, vector can hold multiple types of data in 1 object. (this learning purposes.) i have empty base class called container : class container {}; and templatized subclass called object : template <class t> class object : public container { t& object; public: object(t& obj = nullptr) : object(obj) {} }; i have array class holds vector of pointers container s use hold object s: class array { std::vector<container *> vec; public: template <class t> void add_element(const t&); auto get_element(int); }; add_element stores elements object s , puts them vec : template <class t> void array::add_element(const t& element) { vec.push_back(new object<t>(element)); } get_element removes element it's object , passes caller. problem lies. in order remove element object , need know type of object is: auto array::get_element(int i) { return (object</* ??? */> *...

Symfony/Doctrine: How does addJoinedEntityResult work for a one-to-many relationship? -

i have following problem. guess misunderstanding. after googling hours without finding solution post here. i have native query in doctrine: $rsm = new resultsetmapping; $rsm->addentityresult('acme\commentbundle\entity\comment', 'c'); $rsm->addfieldresult('c', 'comment_id', 'id'); $rsm->addfieldresult('c', 'slug', 'slug'); $rsm->addfieldresult('c', 'comment', 'comment'); $rsm->addfieldresult('c', 'created', 'created'); $rsm->addjoinedentityresult('acme\accountbundle\entity\worker', 'w', 'c', 'komments'); $rsm->addfieldresult('w', 'worker_id', 'id'); $rsm->addfieldresult('w', 'worker_name', 'name'); $rsm->addjoinedentityresult('acme\commentbundle\entity\document', 'd', 'c', 'documents'); $rsm->addfieldresult('d', 'document_...

javascript - FB.login not firing for HTML5 iOS web app -

this non native solution, responsive website i'm building. works fine in browser, nothing happens when call fb.login(); $(function() { $.getscript("https//connect.facebook.net/en_us/all.js", function() { fb.init({ appid : fbappid, status : true, cookie : true, oauth : true }); alert(fb); // [object object] fb.getloginstatus(function(response) { alert(response.status); // if ios simulator logged facebook // says "connected" // if ios simulator not logged in // says "unknown" }); fb.login(function(res) { // never gets here on ios simulator // works fine on browsers }); } }); the problem when i'm not logged facebook, i'm trying app pop open facebook looking screen. never gets inside of fb.login, though same code works in browser. thanks can help! it turns out, can't call fb.init , fb.login() on mobile browser. trying save loading sdk until user needed login, guess have use hover intent or else. once loaded sdk on page load, did fb.log...

opengraph - How can I customize Facebook open graph notifications -

when using facebook open graph, notifications on right side of page indicates url accessed from. there way remove this? when go "activity log" show phrase "user on " , display object again right. foursquare or instagram notifications don't display object again. can't find customization features anywhere , if can point me in right direction great. thanks you can customize open graph well. try text template. see complete picture here .

reverse engineering - How to decompile an Android .apk file? -

i decompile on mac os x, android .apk file. it's possible have difficulties. jd gui down. solution? you dont need jd-gui, there several options so, use ded, comes script can run. uses jasmin-classes , soot, helps in making class files more efficient. use apktool manifest.xml

iphone - if([aString writeToFile: @"outfile" atomically: YES]) -

for code like if([astring writetofile: @"outfile" atomically: yes]) i wondering if atomically parameter or parameter name? parameter name variable called. guess call parameter parameter general term in opinion. i think correct thing it's method name, it's part of it. can have parameters in between kind of split up. and btw 1 of things love in objective c, code gets readable :)

javascript - jQuery bind/change to Drop Down Form -

i had longer post describing trying do, don't think necessary i'm making simple. i'm working on getting zurb foundation work datatables. it's been pretty easy except drop down menu. i've had bit of tough time getting working js novice. here general syntax of foundation drop down. <label for="customdropdown">dropdown label</label> <select style="display:none;" id="customdropdown"> <option select="selected">this dropdown</option> <option>this option</option> <option>look, third option</option> </select> <div class="custom dropdown"> <a href="#" class="current">this dropdown</a> <a href="#" class="selector"></a> <ul> <li class="selected">this dropdown</li> <li>this option</li> <li>look, third option</li> </ul> </div> where i...

css - Custom font works locally but not on server? -

i have @font-face defined in site's cascading style sheet. font loads fine when browse site locally (served iis express). however, when loading application remote server (iis 7.5) reference font causes internal server 500 error . why below style work locally, not on server? @font-face { font-family: dejavu sans mono; src: url('../fonts/dejavusansmono.ttf'); } header h1 { font-family: 'dejavu sans mono'; font-size: 3em; padding: 0; margin: 0; } if check discover dejavusansmono.ttf file not being copied server. since it's not being copied font file not there iis 7.5 provide. works locally because iis express able find file in local directory. file types visual studio not recognize have buildaction property set none default; font files 1 such unrecognized type. having buildaction of none means visual studio ignore file when building application. there several out of box options buildaction property: none - file not included in project output group ,...

iphone - Is there any limit to add object in NSMutableArray..? -

recently i'm working on project requires large no. of object should added nsmutablearray. i'm little bit confusing how object can add in nsmutablearray ..? thanks in advance. it's dependent on memory. older generation devices smaller share of ram (memory) use newer devices apps run. therefore, limit lower on older devices newer ones. said, can't pinpointed specific number (unless mistaken). rather, should try figure out if can handle memory better here you're not worried size limit :) edit steffen itterheim's "learn cocos2d game development ios 5", based on installed memory of device, here rough estimates of amount of memory apps can expect work with: 128mb installed => 35-40mb available, memory warnings @ 20-25mb; 256mb installed => 120-150mb available, mem warning @ 80-90mb; 512 mb installed => 340-370mb available, mem warning @ 260-300mb. of course these rough estimates, depending on device can see size of nsmutablearray depen...

How to find doubles with SQL? -

Image
this question has answer here: select statement find duplicates on fields 6 answers using chinook test database wrote sql statement show tracks ordered 2 specific customers: select inv.billingcity,cus.lastname,tra.name invoice inv join customer cus on inv.customerid=cus.customerid join invoiceline inl on inv.invoiceid=inl.invoiceid join track tra on tra.trackid=inl.trackid cus.lastname in ('schneider','schröder') order inv.billingcity,cus.lastname,tra.name i see there track ordered twice 1 customer: how write sql statement find doubles this, i.e. "return tracks ordered multiple times 1 customer"? try this: select cus.customerid,tra.name,count(cus.customerid) tot invoice inv join customer cus on inv.customerid=cus.customerid join invoiceline inl on inv.invoiceid=inl.invoiceid join track tra on tra.trackid=inl.trackid group cus.customerid,tra.name having tot > 1

jquery - How to import .js files -

hi developing phonegap application. if use console.log in index.html file prints, if use in file doesn't print. if suppose import files in index.html file like: <!doctype html> <html> <head> <link rel="stylesheet" href="jquery.mobile/jquery.mobile-1.1.0.css" /> <link rel="stylesheet" href="docs/assets/css/jqm-docs.css" /> <link rel="stylesheet" href="docsdemos-style-override.css" /> <script type="text/javascript" charset="utf-8" src="cordova-1.6.1.js"></script> <script type="text/javascript" src="jquery.mobile/jquery-1.7.2.min"></script> <script type="text/javascript" src="jquery.mobile/jqm.autocomplete-1.4.js"></script> <script type="text/javascript" src="jquery.mobile/jquery.mobile-1.1.0.js"></script> <script type="text/javascript">...

Should I use POM first or MANIFEST first when developing OSGi application with Maven? -

there 2 main approaches when developing osgi application maven: pom-first , manifest first. i'm looking answer in form of table shows pros , cons of each method. to more specific, know how relates to: maturity of toolset vendor independence development ease (which includes finding people can development on tooling) compatibility avoiding classnotfound avoiding manual work at present can come with pom-first pros (using maven-bundle-plugin) leverages existing maven skills, repositories , tooling. likely easier find people know how manage pom.xml rather manifest.mf along pom.xml most of information in manifest.mf can obtained pom.xml itself. can work other ides not eclipse based ones. less invasive, add single plugin , change packaging type "bundle" pom-first cons classnotfoundexception more occur @ runtime. however, can mitigated using pax-exam (although complicated set up). still need understand how manifest setup make sure instructions confi...

php - Get billing information in order review section of one page checkout in Magento -

i trying display billing , shipping information in "order review" section of 1 page checkout in magento 1.7.0. however, doesn't want co-operate @ all. tried several methods mentioned in various forums , in well. none of these methods seem work. here ones have tried. http://www.magentocommerce.com/boards/viewthread/55281/ http://www.magentocommerce.com/boards/viewthread/55281/ any appreciated! in advance. mage::getsingleton('checkout/session')->getquote() ->getshippingaddress() ->getdata(); mage::getsingleton('checkout/session')->getquote() ->getbillingaddress() ->getdata(); will give arrays billing , shipping information current order. depending on context, may have call mage::getsingleton('checkout/session')->getquote() ->collecttotals(); for order taxes, subtotals, etc correct.

java - json string becomes null in action class in struts 1.3.8 -

i developing web application in struts 1.3.8 using $.ajax() jquery post json data action class receiving null .my code var dataobj={data:[{code:code1,hd1:h1,hd2:h2}]}; $.ajax( { url: "editablepage.do?data="+dataobj, datatype: "json", method:"post", data:dataobj }); java code string data=request.getparameter("data"); jsonobject jobj = new jsonobject(); jsonobject newobj=jobj.getjsonobject(data); string data=request.getparameter("data"); becoming null not understanding doing wrong iam new in jquery, hint great me your way of creating jsonobject wrong. change code this: string data = request.getparameter("data"); jsonobject jobj = new jsonobject(data); also, sending json data parameter string isn't advisable. rather send entity body in javascript.

android - java.lang.RuntimeException: An error occured while executing doInBackground() -

exception stack trace: java.lang.runtimeexception: error occured while executing doinbackground() e/androidruntime( 695): @ android.os.asynctask$3.done(asynctask.java:200) e/androidruntime( 695): @ java.util.concurrent.futuretask$sync.innersetexception(futuretask.java:273) e/androidruntime( 695): @ java.util.concurrent.futuretask.setexception(futuretask.java:124) e/androidruntime( 695): @ java.util.concurrent.futuretask$sync.innerrun(futuretask.java:307) e/androidruntime( 695): @ java.util.concurrent.futuretask.run(futuretask.java:137) e/androidruntime( 695): @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1068) e/androidruntime( 695): @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:561) e/androidruntime( 695): @ java.lang.thread.run(thread.java:1096) e/androidruntime( 695): caused by: java.lang.noclassdeffounderror: com.google.gson.gson e/androidruntime( 695): @ com.amphisoft.mebox.loginactivity$logintask.doinbackground(login...

c++ - How to know if a std::list has been modified -

possible duplicate: create std::list of value instead of std::list of pointers in recursive function i have class: class c { public: c* parent; std::list<c> children; }; i can use class in way example: c root; c child; root.children.push_back(child); // or other method of std::list (es: push_front, insert, ...) // here child.parent root // how can set parent of child? i want work internally class without losing functionality of std::list , possible? if understanding question correctly, want this: class c { public: c* parent; std::list<c *> children; explicit c(c *p = 0) : parent(p) { if (p) p->children.push_back(this); } }; c root; c child(&root); note changed children list take pointers. fine long c not expected manage memory nodes, refer them. the title of question was: how know if std::list has been modified . comments, seems want proxy : class listproxy { std::list<c *> children; public: // replicate list traits // ... void push_back (c *...

graph - Java - Implementing interface with Object argument -

i implementing java graph library (to learn ...). accordingly, wrote interface public interface digraphinterface { public boolean isempty(); public int size(); public boolean isadjacent(object v, object w); public void insertedge(object v, object w); public void insertvertex(object v); public void eraseedge(object o, object w); public void erasevertex(object v); public void printdetails(); } as first step towards implementing, writing digraph class implements above interface. however, keep things simple, want node identifiers integers, defined functions as @override public boolean isadjacent(int v, int w) { // todo auto-generated method stub return adjlist[v].contains(w) || adjlist[w].contains(v); } but, getting error, need override or implement method supertype. can explain me underpinnings behavior. also, if can explain, how design libraries allow flexibility add components of type. you interface says: public boolean isadjacent(object v, object w); you implement: public ...

windows - Determining volume cluster size without using GetDiskFreeSpace -

i'd programmatically determine cluster (a.k.a. allocation unit) size of volume (a.k.a. file system) mounted on windows system. various reasons, i'd find solution not use getdiskfreespace() . are there fsctl_xxx or ioctl_xxx requests can used purpose? you can use deviceiocontrol ioctl_storage_query_property . on input, set propertyid in storage_property_query structure storageaccessalignmentproperty . that storage_access_alignment_descriptor , contains members both bytesperlogicalsector , bytesperphysicalsector . linked reference page includes demo code retrieve , display logical/physical sector sizes device.

shell - Run some commands in Debian package script from current user -

how run commands in installations scripts of deb-package (preinst, postinst, prerm, postrm) not root current user (user invoked installation)? root current user. should never expect installation of package performed sudo you can check sudo_user environment variable user may have invoked script, if installation performed context of simple sudo dpkg -i - sudo may not have been installed, installation may have been performed su , means environment variable not set. if want invoke scripts user invert sudo - viz: sudo -u $sudo_user -c <command invoke> but need ensure know user invoked script - i.e. sudo_user root! typically, though, because can have arbitrary number of users on linux system, should not this, leave system in state 1 user can use package. should create state/configuration on first invocation ordinary user. finally, don't expect gui, don't expect terminal on installation if it's being shipped dpkg.

CakePHP displaying "admi" at the top of any page -

i'm trying deal strange cakephp behaviour. enabled "admin" prefix in core.php , have "admi" @ top of page... admi<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> literally out of nowhere, no trace of in layout @ default.ctp. looks cakephp bug, ideas appreciated. running on localhost, apache 2.2.17, php 5.3.5, mysql 5.1.63, cake 2.o found it, "admi" @ beginning of core.php, added accidentally when changing "admin prefix" there.

Explanation of small Redis snippet -

i'm referring great answer given @sripathi krishnan question asked here on so: redis cache i'm trying learn how use redis , research brought me question on so. can please explain reason these 2 lines in code because i'm still finding difficult understand usefulness in code sripathi gave in answer. $ hincrby unique_ids question 1 $ hincrby unique_ids answer 1 i know creates hash 'unique_ids' key fields 'question' , 'answer' first initialised 0 increased 1. apart this, don't see link of unique_ids key flow i'm not sure if noob mind missing something. these commands way generate synthetic primary keys. in sri's example, people can add questions , answers in system. these entities need referenced, need identified unique keys. may imagine using kind of uuid mechanism this, using numeric keys simpler. the unique_ids convenient container store next available keys of objects stored in system. add new question, increment question fiel...

PHP equivalent of Date.UTC function in javascript? -

i'm fetching dates mysql strings ( y-m-d format). need display chart using highcharts . highcharts uses javascript date.utc function: return number of milliseconds between specified date , midnight january 1 1970. data: [ [date.utc(1970, 9, 27), 0 ], [date.utc(1970, 10, 10), 0.6 ], [date.utc(1970, 10, 18), 0.7 ], [date.utc(1970, 11, 2), 0.8 ], [date.utc(1970, 11, 9), 0.6 ], but i'd avoid javascript , in in php (assigning json object - chart - page itself). what's equivalent of date.utc function in php (regardless server datezone)? $date = '2012-07-07'; $millisecs = 1000 * unix_timestap_utc_regardless_server_zone($date); i use date_default_timezone_set('utc'); $today = date(getdate()); that set $today date. edit: niclas right, how it. edit 2: can replace getdate() valid timestamp in php, if like... edit 3: sorry... misunderstanding... use strtotime() make valid timestamp!

android - Mobile App Development Plan with REST Api is Good Idea? -

i'm new mobile native app development. but i'm familiar web app development. i going develop iphone native app first , develop android native app after that. to minimize work, plan develop rest apis apps. api server going handle database crud , session native app call data database in abstract manner. so ios, android , etc native apps use rest apis to read , write photos, text, latlng etc. i'm not sure recommended way develop native apps. perhaps direct communication native app , database have better performance i'm worried on developing logics in every other native app version. yes, , recommended approach in android. there no official support soap in android, though ksaop2 works in android apps. implement client consume restful web svc, need in separate thread. android 4.x not support network connections in main thread. ios: may based if webapplciation provides restful webservice or can use soap. connecting network url in soap consumes more memory. rest...

ruby - Spec testing EventMachine-based (Reactor) Code -

i'm trying out whole bdd approach , test amqp -based aspect of vanilla ruby application writing. after choosing minitest test framework balance of features , expressiveness opposed other aptly-named vegetable frameworks, set out write spec: # file ./test/specs/services/my_service_spec.rb # requirements test running , configuration require "minitest/autorun" require "./test/specs/spec_helper" # external requires # minitest specs eventmachine require "em/minitest/spec" # internal requirements require "./services/distribution/my_service" # spec start describe "myservice", "a gateway amqp server" # connectivity "cannot connect unreachable amqp server" # line breaks execution, commented out # include em::minitest::spec # ... # (abridged) alter configuration specifying # invalid host such "l0c@alho$t" or such # ... # try connect , expect fail exception myapp::myservice.connect.must_raise eventmachine::co...

error with special characters when load .htm into a div with jquery -

i'm using jquery load .htm file div on main page, when so, special character such æ, ø, , å turns '�'.. ideas on how display characters correctly ? use character codes, ones starting &# (e.g. :&#162)

c# - CompileXaml failed unexpectedly -

i`ve created new project of windows 8 application. want create c#/xaml. i'm creating project , press f5 , get the "compilexaml" task failed unexpectedly. system.nullreferenceexception: object reference not set instance of object. @ microsoft.windows.ui.xaml.build.tasks.compilexaml.checkfordesigntimebuildmode() @ microsoft.windows.ui.xaml.build.tasks.compilexaml.execute() @ microsoft.build.backend.taskexecutionhost.microsoft.build.backend.itaskexecutionhost.execute() @ microsoft.build.backend.taskbuilder.d__20.movenext() i didn`t change anything. same thing happens when chose blanktemplate, splittemplate, gridtemplate. dunno do i solved problem. tbh i`m not sure how did this. i've uninstalled visual stuidos , downloaded latest version of visual studio 2012 rc ms site. installed scratch , worked

javascript - How to increment a value at localStorage -

i have values dynamically stored @ localstorage incremented values this: localstorage["value0"], localstorage["value1"],.... when try access them this: javascript: localstorage["counter"]=0; var = localstorage["counter"]; var d =localstorage["value"+i]; = + 1; // becomes "01" var f = localstorage["value"+i]; the i's value "01" not 1 ... there way increment i's value correctly? localstorage can store string values. can use parseint converts string integer: var new_value = parseint(localstorage.getitem('num')) + 1 you can use libraries store.js things automatically you. have include library: <script src="store.js"></script> set new storage: var numbers = new store("numbers") put things it: numbers.set('num', 2) get value , want it: numbers.get('num') + 1 //output: 3 and can go crazy , use arrays: numbers.set('nums', [1...

JQuery Autocomplete without using label, value, id -

is possible have jquery autocomplete work without using conventional id,label,value? for instance, not wish use: [ { "id": "botaurus stellaris", "label": "great bittern", "value": "great bittern" }, { "id": "asio flammeus", "label": "short-eared owl", "value": "short-eared owl" }] but rather: [ { "my_id": "botaurus stellaris", "first_name": "great bittern", "last_name": "great bittern" }, { "my_id": "asio flammeus", "first_name": "short-eared owl", "last_name": "short-eared owl" }] so like, jquery autocomplete takes id,value,label , can make take my_id, first_name, last_name , make jquery autocomplete treat same id,label,value ? this might useful, when don't wish modify data's keys coming datasource, display on jquery autocomplete. ...

java - Drawing a sphere in OpenGL ES 2.0 -

Image
i'm trying draw sphere in opengl es 2.0 on android. looked @ related questions , tried of code still can't work. based on android developer examples , this code found on gamedev.net came code below. not drawing correctly; when using gldrawarrays() rendering works results not correct, when using gldrawelements() gl_invalid_operation error. listed contents of buffers below. sphere.java public class sphere { private int stacks; private int slices; private float radius; //buffers private floatbuffer vertexbuffer; private floatbuffer colorbuffer; private shortbuffer indexbuffer; //buffer sizes in aantal bytes private int vertexbuffersize; private int colorbuffersize; private int indexbuffersize; private int vertexcount; private int program; static final int floats_per_vertex = 3; // het aantal floats in een vertex (x, y, z) static final int floats_per_color = 4; // het aantal floats in een kleur (r, g, b, a) static final int shorts_per_index = 2; static final int bytes_per_...