Posts

Showing posts from March, 2011

python - Django generic views - sending data to project templates -

i try send data generic views app urlpatterns = patterns('', (r'*', listview.as_view( queryset=post.objects.all().order_by("-created")[:2], template_name="/mysite/templates/index.html" )), ) however, data cannot sent c/p query , result returned. what's missing? in mysite/templates/index.html {% post in object_list %} {{ post.title }} {% endfor %} prints nothing you not providing enough information. r'*' not valid regular expression - * needs act on - , django report if tried use in urlconf. need show how including url in main urls.py.

I want to make a spinner in android such that it acts as dropdown instead of poping out -

Image
in image ..the button shows settings spinner dropsdown ...so want make such spinner dropsdown.. thanks in advance.. i guess example wasn't implemented spinner, since there 2 items don't benifit using spinner instead of making own "dropdown" layout, , making visible upon press of button. if have relatively few things want in drop down suggest going route , staying away spinner one. if have long list of data user choosing though , wanting make dropdown (similar combo box etc.) overriding spinner, change way ondraw() works display inline view in parent, rather popping out. though think stock spinner provide better user experience this.

c# - Winforms - Underline part of text to be displayed in textbox -

i have line of text display , want underline heading portion of text in display. how accomplish please? message: message name of client. where "message:" underlined. if want show text using rich text box, this: richtextbox1.selectionfont = new font("times new roman", 10, fontstyle.underline); richtextbox1.selectedtext = "message:"; richtextbox1.selectionfont = new font("times new roman", 10, fontstyle.regular); richtextbox1.selectedtext = " message name of client."; or, if message dynamic , header , text separated colon, this: string message = "message: message name of client"; string[] parts = message.split(':'); richtextbox1.selectionfont = new font("times new roman", 10, fontstyle.underline); richtextbox1.selectedtext = parts[0] + ":"; richtextbox1.selectionfont = new font("times new roman", 10, fontstyle.regular); richtextbox1.selectedtext = parts[1]; or, if wa...

c# - Elegant MVC code for optional surrounding tag -

what more elegant code accomplish following: foreach(var filter in model.filters) { if(filter.selected) { <div class="crumb crumb_selected" id="@filter.id"> @* more html can here *@ @filter.title <span class="counter"> (@filter.count) </span> </div> } else { <div class="crumb" id="@filter.id"> <a href="@model.clickurl(model.selectedfilters, filter)"> @* more html can here similar code above *@ @filter.title <span class="counter"> (@filter.count) </span> </a> </div> } } the repeated html code div / span seems bad code also css-class specification should solved in elegant version @helper myhelper(somedatatype filter) { @* more html can here *@ @filter.title <span class="counter"> (@filter.count) </span...

c# - Crystal Reports Data Not On Same Rows It's Skip The Row -

i have crystal sub reports on main reports' pageheader section below: sub-report1: report header label purchase sales details section field purchase sales display result is: purchase sales purchase account sales account the above result not on same row it's skip same row of sales field want in same row below. purchase sales purchase account sales account what problem it?. why data not show in same rows , how it?. not have running total field on sales amount , purchase amount.

iphone - xcode counting JSON items -

i need count number of items (post) in json response, 2012-06-04 14:09:57.872 horitable[72261:11903] json : { posts = ( { post = { eventdate = "2012-03-31"; eventid = 2; eventimage = "http://hernandoz.local/~hernandoz/kopict/02_31march2012.jpg"; eventinfo = "02 event"; eventname = "xplosion 02"; }; }, { post = { eventdate = "2012-07-07"; eventid = 3; eventimage = "http://hernandoz.local/~hernandoz/kopict/greg_vs_turner.jpg"; eventinfo = "02 event"; eventname = "xplosion 02"; }; }, { post = { eventdate = "2012-04-29"; eventid = 4; eventimage = "http://hernandoz.local/~hernandoz/kopict/ko_itclub_apr_2012.jpg"...

android - Specifying a Single Request To Use Credentials with HttpClient -

i using oauth2 on android project. idea use singleton httpclient used threadsafeclientconnmanager. for normal request server construct authorization header , send that. header constructed values received server. works fine. every 15 minutes must new values server construct header. received these values must set credentials so. client.getcredentialsprovider().setcredentials( new authscope(authscope.any_host, authscope.any_port), new usernamepasswordcredentials(creds.clientid, creds.clientsecret)); in order work must set , new defaulthttpclient. if use original singleton httpclient receive errors. question is.. possible set credentials used on 1 request? i noticed there authscope. host , port not suitable maybe realm would? can't find tells me realm or how use it. 06-05 10:12:55.969: w/system.err(23843): org.apache.http.nohttpresponseexception: target server failed respond 06-05 10:12:55.969: w/system.err(23843): @ org.apache.http.impl.conn.def...

c# - Run function whenever a change is made in database -

i want run function whenever change made in database. is there way avoid 3 loops ? here code: public void save() { system.data.linq.changeset changeset = db.getchangeset(); foreach (user user in changeset.inserts) { this.dosomestuff(); } foreach (user user in changeset.updates) { this.dosomestuff(); } foreach (user user in changeset.deletes) { this.dosomestuff(); } db.submitchanges(); } just "converting" @adrianm comment answer: foreach (user user in changeset.inserts.concat(changeset.updates).concat(changeset.deletes) { this.dosomestuff(); }

objective c - How to record and play a captured video using AVAssertWriter and AVAssertReader in iphone sdk -

i displaying camera data (video) on preview layer.now want record video , store in local file , access play on screen. i had seen websites possible avassertwriter , avassertreader . difficult me understand. can 1 advice me in clearcut manner or sample code. anyone's appreciated. thanks all, monish.

What JQuery Plugin is being used here? -

i found brilliant image map plugin on bbc here: http://www.bbc.co.uk/news/uk-18295433 the highlighted links normal tags have had position set absolute hover them in different places on image. using javascript plugin file zoom areas on image depending on tag clicked. javascript plugin file here: http://node1.bbcimg.co.uk/glow/glow/map.1.7.7.js however can't find open source version anywhere. know of similar or plugin called? this using microsoft's deep zoom - seadragon ajax . the seadragon component comes asp.net ajax control toolkit . it's licensed under open-source compatible bsd license .

sql - Joining results of two queries: #1248 - Every derived table must have its own alias -

i'm trying combine results produced 2 queries on database... q1: select * werkgevers join werkgevers_branches on werkgevers.werkgever_id = werkgevers_branches.werkgever_id join plaatsen on werkgevers.plaats_id = plaatsen.plaats_id join branches on werkgevers_branches.branche_id = branches.branche_id group werkgevers_branches.werkgever_id q2: select werkgever_id, count(werkgever_id) aantalvacatures vacatures group werkgever_id ... this: select * ( select * werkgevers join werkgevers_branches on werkgevers.werkgever_id = werkgevers_branches.werkgever_id join plaatsen on werkgevers.plaats_id = plaatsen.plaats_id join branches on werkgevers_branches.branche_id = branches.branche_id group werkgevers_branches.werkgever_id ) tbl1 left outer join ( select * ( select werkgever_id, count(werkgever_id) aantalvacatures vacatures group werkgever_id ) tbl2 ) using (werkgever_id) but keep getting error #1248 - every derived table must have own alias i'm ...

c# - Xml generated with fields & attributes entered by webform -

i have following problem! need generate xml document in asp.net. this, need enter following information: - number of tags. - name of each tags (example: , , , etc). - attributes of each tag (example: alex... etc).. i have function received list (taglist) name of xml tags. public void functionxml() { string rutasave = string.format(@"c:\xml.xml"); var serializer = new xmlserializer(typeof(list<string>)); textwriter textwriter = new streamwriter(rutasave); serializer.serialize(textwriter, tagslist); } but xml generated function looks this: <?xml version="1.0" encoding="utf-8"?> <dictionary> <item> <key> <string>campo1</string> </key> <value> <anytype xmlns:q1="http://www.w3.org/2001/xmlschema" d4p1:type="q1:string" xmlns:d4p1="http://www.w3.org/2001/xmlschema-instance">test</an...

python - How do I database off Heroku to my local machine? I have a Django app (not Rails) -

how database off heroku? i'm trying figure out how sync local machine. i found instructions rails app, not django. while convenient, using taps may not replicate data , may run errors larger transfers. import or export data production system, highly recommend using pgbackups instead. https://devcenter.heroku.com/articles/pgbackups

C++ transform vector of pointers -

hey trying transform vectors of pointers object vector of pointers different object. i have been given following classes: class test; class test2 { public: test2(test*); } i unfamiliar on how create functor. part of sample exam exams later week confused on question though. following link explains use of transform quite problem little different. great! reference: http://www.cplusplus.com/reference/algorithm/transform/ a functor 1 overloads operator() . can define functor as: struct test2generator { //this called std::transform test2* operator()(test1 *param) const { return new test2(param); } }; then use as: std::vector<test1*> v1; //fill v1 std::vector<test2*> v2(v1.size()); std::transform(v1.begin(), v1.end(), v2.begin(), test2generator()); in c++11, don't need define functor, instead can use lambda as: std::transform(v1.begin(), v1.end(), v2.begin(), ...

django - Why do I get this error when I run "python manage.py syncdb --all"? -

i trying apply tutorial http://docs.django-cms.org/en/2.1.3/getting_started/tutorial.html . but didn't succeed perform initial database setup why error when run "python manage.py syncdb --all" ? traceback (most recent call last): file "manage.py", line 10, in <module> execute_from_command_line(sys.argv) file "c:\python27\lib\site-packages\django\core\management\__init__.py", line 442, in execute_from_command_line utility.execute() file "c:\python27\lib\site-packages\django\core\management\__init__.py", line 381, in execute self.fetch_command(subcommand).run_from_argv(self.argv) file "c:\python27\lib\site-packages\django\core\management\base.py", line 195, in run_from_argv self.execute(*args, **options.__dict__) file "c:\python27\lib\site-packages\django\core\management\base.py", line 230, in execute self.validate() file "c:\python27\lib\site-packages\django\core\manageme...

Importing data from a csv file to mysql db -

i trying load data csv file still in excel. far statement have sql query: load data local infile 'c:\\documents , settings\\j03299\\desktop\\tmeter.csv' table edata columns terminated ',' enclosed "" lines terminated '\n' (year,month,day,mjd,xpiles,xstacks,utilites); the file called tmeter , has 7 columns. has 366 rows. able read first row , first 4 columns(till mjd) else null after that. secondly in second row puts columns file (tmeter.csv) in row 124 first column of second row in edata table. confused to why doesn't read data column piles,stacks ,utilites? (mind column names in csv file weird , not same edata table e.g in database table piles while in actual csv file x(piles), stacks in table y(stacks) in csv file. mysql doesn't not allow me create etable names format had improvise. why not reading , mapping csv file table in mysql? why statement putting first row in csv file in first row in mysql table skipping down row 124 , ins...

c# - Multi-Portal CMS for MONO -

i searching cms system based on asp.net (preferable mvc 3) runs under mono on linux system , able host multiple portals can host 2+ pages 1 installation , share resources , has basic stuff articles, image gallery , on built in, can extended using c#. similar questions asked years ago without suitable answers, many things have changed since then. i checked out kooboo 3 (basic system looks nice, there no modules image gallery) , mojoportal (no multi protal , backend did have layout problems chrome). does know fit needs (better)? maybe little late, checkout kooboo cms - kooboocms pretty extensible , how don't push heavy cms paradigm on you. there little learning curve honest, had easier time getting site done umbraco or orchard. plus it's plugable on backend. kooboo 4 awesome!

drupal 6 - D6 to D7 - Content Migration -

i have existing site in drupal 6 , need rebuild same in drupal 7. experiencing problems content migration d6 d7. tried node export module drupal var export format , csv format both did not work. there other approach migrate contents d6 d7? reference or tutorial use migrate module content migration. any solution issue appreciated. you can use drupal 7 version of cck module migrate data d6 installation d7 installation. for assistance, take @ migrating d6 content construction kit (cck) d7 fields

.net - Port Sqlite application to a server/client application -

i have wrote application organisation , had let app run in lan using samba, worked perfect. want work on internet. problem have written app sqlite, means working so: they have exe , sqlite dll , sqlite database on samba server , connected network drive on windows pc run it. means every pc writing on samba sqlite database. i tried on internet, thought sqlite local database , slow, if ping under 50ms. i create tcp server, handles , writes sqlite database, have written around 20.000 code lines project, not best option lazy me. have used 1 sqlite class in client querieng, thought work without work, if replace sqlite database adapter mysql database adapter, since sqlite has same syntax mysql. or has better idea? sqlite not designed concurrent transaction (it can done, that's post). if it's going available via internet best bet migrate database 1 of free databases (mysql, sql server express, oracle express...etc)

c# - DateTime conversion to FileTimeUtc -

i have datetime variable defined datetime.now. need "convert" filetimeutc. must misunderstanding because assumed work: datetime runtime; runtime = system.datetime.now.tofiletimeutc(); but error cannot implicitly convert type long system.datetime. any help? thanks. datetime.tofiletimeutc returns long, not datetime . documentation: a windows file time 64-bit value represents number of 100-nanosecond intervals have elapsed since 12:00 midnight, january 1, 1601 a.d. (c.e.) coordinated universal time (utc). windows uses file time record when application creates, accesses, or writes file. this should be: long runtime; runtime = system.datetime.now.tofiletimeutc(); if want current coordinated universal time, , not windows file time , can use: datetime runtime = system.datetime.utcnow; see utcnow details.

Copy missing rows from one table to another in sql server with stored procedure -

i have tables in different databases (on same server) identical. need transfer data rows left database table right database table, want transfer rows aren't in right database table already. is there neat way of doing this? im using sql server 2008 r2 assuming can uniquelly identify row column id : insert databasename..tablename select * datababasename2..tablename2 id not in (select id databasename..tablename)

validation - JQuery - grab corresponding event of blur-Action -

hi have form , on 1 input field set blur event. user leaves input field, validate , decide if okay. if value of field not okay alerting information box. anyway if user hits link leave page cannot stop him. if link clicked user have prevent default behaviour. how recognize event user has left input field? in advance. have @ http://api.jquery.com/unload/ as says in doc the unload event sent window element when user navigates away page. mean 1 of many things. user have clicked on link leave page, or typed in new url in address bar. forward , buttons trigger event. closing browser window cause event triggered. page reload first create unload event. you can use event prevent users navigating away page. like this $(window).unload(function() { alert('you have unsaved form values.'); });

c# - Combining RotateTransform and TranslateTransform -

i using thumb class let user drag , drop image across canvas. when right button gets pressed, want user able rotate image. rotation based around center of image. have following xaml code <grid> <canvas background="red" grid.rowspan="2" x:name="canvas" previewmouserightbuttonup="canvas_mouseup" previewmousemove="canvas_mousemove"> <usercontrol mouserightbuttondown="canvas_mousedown" rendertransformorigin="0.5,0.5"> <thumb name="myroot" dragdelta="myroot_dragdelta"> <thumb.template> <controltemplate> <grid> <image source="/wpfapplication1;component/someimage.png" /> <rectangle stroke="#ff0061ce" strokethickness="1" width="230" height="25...

algorithm - Dynamic programming approach or a case that fails the greedy -

i have string of length 1 <= |s| <= 100 , k (1 <= k <= 10) this string contains digits < k , question marks. want replace these question marks digits < k , no 2 neighboring digits being equal. string circular can't this: 1?1 or 11? . the resulting string must lexicographically smallest one. example input , output input: k = 4 string = ????? output: 01012 i've tried greedy approach fails unknown testcases. think needs dp approach couldn't figure out states, , pure recursion code won't fit in time. any dp approach, or tricky test cases fail greedy? thanks, if have digit @ 1 end of string, greedy algorithm give right answer. if string starts , ends question mark, have 2 possibilites first character (0 or 1), run greedy algorithm on both cases , take best. wrong answer pointed out likao: the greedy works must start first question mark after known digit.

android - how to launch certificate installer intent from the application to access root keystore -

i trying install ca certificate application no luck. using android sdk 2.3.3. i have found reference launch credential storage dialog application. can share cod why need install ca certificates? in android 2.x, certificates , keys stored in credential storage used vpn , wifi. api not public, can start certificate installer "android.credentials.install" intent action.

doctrine - ODM: References not being created on both documents -

say have 2 simple documents this, person can have many papers, paper can belong 1 person. namespace dashboard\document; use doctrine\odm\mongodb\mapping\classmetadata; use doctrine\odm\mongodb\mapping\annotations odm; /** @odm\document(db="testing", collection="person") * @odm\inheritancetype("collection_per_class") */ class person { /** * @odm\id */ protected $id; /** @odm\field(type="string") */ protected $slug; /** @odm\field(type="string") */ protected $name; /** @odm\referencemany(targetdocument="paper", cascade={"all"}) */ protected $papers; public function __get($property) { return $this->$property; } public function __set($property, $value) { $this->$property = $value; } public function toarray() { return get_object_vars($this); } } namespace dashboard\document; use doctrine\odm\mongodb\mapping\classmetadata; use doctrine\odm\mongodb\mapping\annotations odm; /** @odm\d...

asp.net mvc 3 - MVC3 Consuming java web services only works with ip address -

i calling java web service asp.net mvc web application. web service works if endpoint address in web.config references server ip address or localost. when replace ip adderess host name can not find server. here service section of web.config <system.servicemodel> <bindings> <basichttpbinding> <binding name="testinterfacebeanservicesoapbinding" closetimeout="00:01:00" opentimeout="00:01:00" receivetimeout="00:10:00" sendtimeout="00:01:00" allowcookies="false" bypassproxyonlocal="false" hostnamecomparisonmode="strongwildcard" maxbuffersize="65536" maxbufferpoolsize="524288" maxreceivedmessagesize="65536" messageencoding="text" textencoding="utf-8" transfermode="buffered" usedefaultwebproxy="true"> <readerquotas maxdepth="32" maxstringcont...

jquery - jqGrid with inlineNav: is there a way to force the Add button to re-enable? -

i'm using jqgrid 4.3.2 inlinenav option. editing on grid done locally using loadonce: true , clientarray . when user finishes editing, click save button on form , entire grid posted server. works great, part, i've run oddity. if user adds new row , clicks save button before hitting enter confirm edit or deselecting newly added row, add button on inline navigator remains disabled after calling saverow before posting , reloading. i've tried resetselection , restorerow after saverow call, neither of these work. save code: $("#submitbutton").click(function () { $("#thegrid").jqgrid('saverow', $("#selectedrowid").val(), false, 'clientarray'); if (!validategriddata()) return false; var rowdata = $("#thegrid").jqgrid('getrowdata'); var datatosend = json.stringify(rowdata); $.ajax({ url: '@url.action("updategriddata")', type: 'post'...

jquery - Passing a variable into an alert -

when correct string, foo , entered .guess trying pull value .clicks , pass alert. when load page current code (below) alert reads correct! guessed in clicks. . why clicks variable not being passed? thanks jquery: $('.guess').keyup(function() { if ($('.guess').val() == "foo") { var clicks = $('.clicks').val(); alert('correct! guessed in ' + clicks + ' clicks.'); location.reload(); } }); html: <div class="bar"> <h2 class="clicks">0</h2> <input type="text" class="guess" /> </div> .val() used getting value of form input elements. i think want use $(".clicks").text() , return "0" .

How to set Facebook Access (from server) in JavasScript SDK -

if using server side flow authenticate user , acquire access token, how can set access token in javascript sdk , use make calls client side? once user has finished server side authentication flow user authorized app, need use fb.getloginstatus method: fb.getloginstatus(function(response) { if (response.status === "connected") { console.log("authresponse: ", response.authresponse); fb.api("me", function(response2) { console.log("hey there " + response2.name); }); } else if (response.status === "not_authorized") { // user logged in facebook hasn't authorized app, should not happen if went through server side authentication } else { // user logged out of facebook, should not happen } } as can see can use js sdk query graph, there's no need token manually, in case still need it, authresponse should have following format: authresponse: { ...

html5 - contenteditable click anywhere around element and it's selected in Chrome -

in chrome have simple contenteditable="true" span , , if user clicks anywhere around it, cursor shows , he/she can start editing. annoying b/c want cursor show when user clicks on span itself, not outside of it. example: http://jsbin.com/oyamab/edit#javascript,html,live html below... <body> <span id="hello" contenteditable="true">hello world</span> </body> if visit link in chrome, click anywhere in rendered html box (the far right column in jsbin), , can start editing. in firefox on other hand, have click on actual span edit (yay!). do need accept chrome thing, or there hack around it? thanks. i suspect it's webkit thing. can work around though making span contenteditable when it's clicked demo: http://jsfiddle.net/timdown/nv4gp/ html: <body> <span id="hello">hello world</span> </body> js: document.getelementbyid("hello").onclick = function(ev...

osx - Java -Xmx1028m not working in Mac OS X -

i trying use command "java -xmx1028m" it giving me list of available commands after hit enter, , doesn't change maximum memory size java. please help! it's not meant change maximum heap size java in general - it's meant set that invocation of java command . so you'd typically run: java -xmx1028m com.foo.someapplication (or executable jar file, possibly adding options etc). i don't know of way of changing default maximum heap size java - doing assume applications have equal requirements anyway.

HTML5 file api support in XTK -

is there way or plan reading files (images or color tables) local file system? yes, there (since commit https://github.com/xtk/x/commit/f7f7e8c362dfcbb573394ff1668e0fe1e8e16f09 )! check out following jsfiddle http://jsfiddle.net/haehn/taeef/ or big version on xtk sandbox http://sandbox.goxtk.com/fileapi_test/ you can choose to 1 volume 1 labelmap 1 color table 1 mesh 1 curvature file 1 trk file at once in file dialog. choosing files can done multiple times - limitation per file dialog.

HTTPS-friendly jQuery CSS theme from Google CDN -

just trying https friendly version of google's hosted jquery css themes, i.e http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css loading https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css works, except there problems of icons not served https. namely: the page @ https://mysite.com ran insecure content http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css . page @ https://mysite.com/ displayed insecure content http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/images/ui-bg_flat_75_ffffff_40x100.png . page @ https://mysite.com/ displayed insecure content http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/images/ui-icons_222222_256x240.png . page @ https://mysite.com/ displayed insecure content http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/images/ui-bg_flat_0_aaaaaa_40x100.png . page @ https://mysite.com/ displayed insecure content ...

php - Zend Framework Generate HTML in Loop -

i new zend framework , advice on how best loop through database data generate list of links. understanding model should contain of application logic controllers , views being light possible. i querying db set of records , want loop through them , generate html links. psuedocode below. controller: $this->view->mylist = model->generatehtml(); model: function generatehtml() { query db loop through record set build string of html within loop including links return string controller } view: echo $this->mylist; this seems put logic in model , leave controller light , view rendering. one problem have want use $this->view->url generate routing links in html output cannot in model. reading have done online suggests should not building html in model. can generate array of required data in model , return , loop through in either controller or view generate html unsure correct approach , appreciate advice. thanks given. new proble...

iphone - "Legality" of using web resources and appcache inside UIWebView/Phonegap -

we trying develop hybrid app can update using css/javascript/html internet, instead of storing them in phonegap project. like html5 cache manifest in uiwebview? html5 appcache in uiwebview it work fine on ios 5 , 5.1 in fact, inside phonegap index.html or location.href redirect web site. web site has offline manifest, allows phonegap app start , work second time in offline mode (after resources cached first time). , changes manifest update app correctly. have tried terminating app in phone, , restarting while web site down - still works. there solutions allow self update - example phonegap-based worklight. silent self-update doesn't seem issue anymore. so question is, did submit similar app appstore? there's potentially no code @ in app, goes web site. apple appears allow apps download data updates , javascript/html use in uiwebviews. presented wwdc session on data driven apps couple years back. but note item in apple's app review guidelines: ...

ios - Objective c - Core Data saving approach -

i have nsmanagedobject subclass in app, , i'm trying understand when , how save changes. try explain myself, example class a nsmanagedobject subclass. during app life cycle do: app launched ... create instance of class ... change properties of instance ... app go background ... app becomes active again ... change more properties of instance ... app terminates when need call [context save:] ?? call after every change in instance? or maybe call when app go background? should call after creation or deletion of instance? a nice approach place uimanageddocument in appdelegate. can call [context save] whenever change occurs in app (like crash). order follow like: create uimanageddocument object (in application did load or wherever) , assign property setup document (check whether exist on disk or open, etc.. , respond accordingly) pass uimanagedobjectcontext initial uiviewcontroller in app (from there can pass context other view controllers) uimanaged docu...

c++ - proper use of std::vector.push_back() with a user defined type -

i'm getting segmentation faults (i think) current method of vector.push_back(). here example code: so have class zombie class zombie { public: zombie(); ~zombie(); sdl_surface* image; sdl_rect box; bool dead; protected: private: // gets random coordinates around screen sdl_rect get_zombie_rect(); }; with constructor being: zombie::zombie() : dead(false), image(load_image("player.png")), box(get_zombie_rect()) { } and zombie has handler class manage vector function called create_new_zombie(). (here problem) void zombie_manager::create_new_zombie() { zombie newzombie; zombies.push_back(newzombie); } is correct way add element vector? i'm able working version use of pointers, there has easier , more correct way of accomplishing this, right? why getting seg fault if std::vector.push_back() shallow copies new elements? wrong in assuming that? you need implem...

c# - reportviewer.LocalReport.GetTotalPages() returns 0 or error -

i'm using user control, , added report viewer , custom toolbar. want create custom navigation aswell, reason when want check total pages decide whether or not show navigation buttons either returns 0 or "this expression causes side effects , not evaluated" error.. i've ran out of ideas , not quite sure go here.. <rsweb:reportviewer id="rvreports" runat="server" showtoolbar="false" sizetoreportcontent="true" asyncrendering="false" /> codebehind: rds = new microsoft.reporting.webforms.reportdatasource("dsname", myclasstoload()); rvreports.localreport.datasources.add(rds); rvreports.pagecountmode = pagecountmode.actual; rvreports.localreport.refresh(); rvreports.databind(); if (rvreports.localreport.gettotalpages() > 1) { lifirst.visible = true; liprevious.visible = true; linext.visible = true; lilast.visible = true; } this on databind event in usercontrol (.ascx). more appr...

ios - Query regarding app distribution system -

i have question regarding app distribution system via app store. i have app on app store interacts different client-servers @ various locations. functions version 1.0 of iphone app able interact version 1.0 of client-server. problem few of clients late/reluctant in upgrading server iphone users connect. once release update(say 2.0) iphone app there few client-server still running 1.0 version. , if end users of these clients installs update (2.0) iphone app (unknowingly, client-server gonna connect still on 1.0), makes app unusable. how deal these types of scenarios? can develop new updates application interacts server before upgrading or can develop automatically rolls update if server version mismatches? kindly suggest how deal problem! would extremely grateful suggestions. many thanks, manu you can't either things mentioned. app store guidelines forbid removing functionality (aka compatibility 1.0) app, lenient this. regardless, it's bad user experience...

objective c - UIButton Selector Not Called in ARC -

i have 2 classes, view , viewcontroller. view creates button follows: _button = [[uibutton alloc] initwithframe:cgrectmake(50, 0, buttonimage.size.width, buttonimage.size.height)]; [_button setimage:buttonimage forstate:uicontrolstatenormal]; [_button setimage:[uiimage imagenamed:@"btn_learn_focus_pad"] forstate:uicontroleventtouchupinside]; [_button addtarget:self action:nil forcontrolevents:uicontroleventtouchupinside]; [_someview addsubview:_button]; in viewcontroller , after instantiated view in loadview , add selector follows: [view.button addtarget:self action:@selector(buttonpressed:) forcontrolevents:uicontroleventtouchupinside]; the selector not being called. tried nslog in viewcontroller button's position , printed out zero. suspect arc releasing button. _button however, strong pointer ( @property ). not sure why happening. how around this? you not utilizing proper getter/setter methods generated property synthesis. if change first...

android - How many LayoutInflater are instantiated in an application? -

i using factory interface on layoutinflater able set custom typeface on textview in application. unfortunately there places in application doesn't work. after investigation, seems in adapter of listview example, layoutinflater used inflate cells different 1 has been used fo rest of application (my activity has complex structure fragments). is behaviour normal ? how can make sure same layoutinflater used, whatever way retrieve ? thanks as reference layoutinflater context.getsystemservice(context.layout_inflater_service) ( viewgroup.inflate , activity.getlayoutinflater convenient wrappers) presume returns reference same inflater service, until destroyed , recreated, , newly created returned, , on... presume manager object aquired getsystemservice method sth "normal" service's binder objects. edit: , saying above wrong ;) i checked out source code , in android.view.contextthemewrapper (which activitie's super class): @override public objec...

Does MSI file support CRC checks on Windows? -

i curious if it's possible tell if msi file modified since built? possibly not in manner expecting, if sign msi files modifications after have been signed invalidate digital signature. signing msi idea, uac prompt unsigned msi different 1 valid digital signature. for more information refer msdn - how to: sign setup files signtool.exe (windows installer)

Magento Homepage HTML layout issue with Jquery Slider - Code/Pictures Within -

thank taking time read this. easiest way describe problem see http://foscam-uk.com/index.php (note running correct styles.css , not theme316 per later on post) as can see featured products , bestsellers blocks have been moved far right of page, when should image jquery slider above them : http://i.imgur.com/cl9fc.jpg i believe there in style.css can found here http://foscam-uk.com/skin/frontend/default/mt_segina/css/styles.css had copy parts previous style css here http://foscam-uk.com/skin/frontend/default/theme316/css/styles.css also code jquery can found here : http://foscam-uk.com/widget (note running original theme316 css file). i know bit of long post, thank in advance takes time @ this. regards am correct in assuming mean blocks have moved far left of page? what can see happening have float:left on div.col-main causing stick left. width have set div 680px small both best sellers , featured products fit. try upping width match jquery slider abov...

javascript - Is there a way to wrap the toolbar buttons to the next row in TinyMCE if the width of the editor is too small? -

i using tinymce in advanced theme. today must specify in advance buttons in each toolbar row: theme_advanced_buttons1, theme_advanced_buttons2 , theme_advanced_buttons3. is there way specify single list of buttons , let buttons wrap next row if width of editor small contain them in single line? no, unfortunately, not possible (using tinymce3). tinymce4, issue.

c++ - warpPerspective -

Image
i tried inverse perspective frame captured in real-time camera plane using following code: mat dst; dst=dst.zeros(frame.cols,frame.rows,frame.type()); if(found){ mat mmat; mmat.create(3,3,cv_32fc1); mmat=getperspectivetransform(templpoints,imgpoints); cout<< mmat<<endl<<endl; warpperspective(frame,dst,homo,dst.size(),inter_linear ); imshow("out",dst); } the problem dst image totally black , what's wrong code? the image seeing result of sending source points getperspectivetransform in wrong order. means points crossing each other , triangular shapes appear. check order of points , make sure match order of destination points.

has and belongs to many - Cakephp hasAndBelongsToMany with countercache? -

anyone know how countercache working on habtm setup? - categories ;id, name, test_count - tests ; id, name - test_to_categories ; test_id, category_id use counter cache in join model (test_to_categories) through belongsto associations. if not job you'll have implement custom counter method , call in aftersave() of model should count updated. by way "test_to_categories" not following conventions. should categories_tests. conventions there reason. ;)

ruby - How can I refactor these methods and remove the dependency checks on the first lines -

i'm making form pre-calculates of fields. so, have bunch of methods rely on previous methods, or should return nil. @ moment i'm doing series of checks, , i'd remove them. (ignore calculations, examples) def age return unless dob # not bad... date.today - dob end def age_at_start return unless dob && start_date # getting worse start_date - dob end def compensation return unless age_at_start && time_worked && salary && staff_rating # shoot me some_calculation(age_at_start, time_worked, salary, staff_rating) end it partially depends on you're really doing, aside example--without context it's difficult know meaningful under circumstances. can't better than: def age date.today - dob if dob end same one--i wouldn't break out guard clause yet: def age_at_start dob && start_date ? start_date - dob : nil end here i'd break out guard clause, because (a) can, , (b) imo testin...

C - having trouble using stat() to get bytes -

char string[50], s[50]; struct stat buf; int counter = 0; while (fgets(string, sizeof string, stdin)) { if (strspn(string, "size ") == 5) { (int = 5; < strlen(string); i++) { s[counter] = string[i]; counter++; } s[counter] = '\0'; if (stat(s, &buf) < 0) return 1; //problem occured printf("file: %s\n", s); printf("size: %d\n", (int)buf.st_size); } } the context of program not important, trying use because after "size " name of file input. pass stat supposed give me bytes of given file if exists. ultimately, program returns 1 every time using stat wrong. please! fgets() returns trailing newline character(s), 'filename' never correct. replace: for(int = 5; < strlen(string); i++) { s[counter] = string[i]; counter++; } s[counter] = '\0'; with: char *source = &(string[5]), *dest = s; while...

c# - If statement and assignments in lambda expressions -

i have lambda statement has mapping this: public enum status { completed, incomplete, ok } query: var courses = query.select(c => new somemodel { status = c.somequery() ? status.completed : status.ok }); so want status have multiple if statements , not ternary operation. eg. var courses = query.select(c => new somemodel { status = if(c.somequery()) { return status.completed; } else if(c.someotherquery()) { return status.incomplete; } else if(c.someotherquery1()) { return status.ok; } }); so how accomplish this? using entity framework orm. you nest ternary operations: status = c.somequery() ? status.completed : c.someotherquery() ? status.incomplete : status.ok

EJB3 Singleton with HashMap vs JPA 2nd Level @Cacheable on Entity -

i'm trying determine methodology caching better using ejb3 singleton session bean hashmap or using 2nd level caching @cacheable annotation on entity. not sure mean singleton sessionbean, doesn't sound good. use @cacheable.

Tunnelling HTTP over a custom protocol in Clojure/Java -

i want tunnel http request stream on custom transport protocol. there clojure or, fallback, java http clients that'd let me access underlying request streams or lets me filter serialised requests , responses? i know clj-http wraps apache httpcomponents, doesn't seem provide lot of hooks hc internals, , i've looked hc itself, have hard time navigating jungle of factories, interfaces , managers. clj-http includes ability read , write input stream (client/get "http://site.com/bigrequest.html" {:as :stream}) (client/post "http://site.com/resources" {:body (clojure.java.io/input-stream "/tmp/foo") :length 1000}) you can wrap stream in transport of choice.

C++: Make an array out of the elements of a two dimensional array that meet certain requirements -

i new multi-dimensional arrays, question struggling right following: have "maxn" number of days, , highest , lowest temperature recorded these days , have things data. 1 of these things determine days when temperature has been both below , above 0 (i.e.: lowest recorded temp below , highest above). program has output number of days when such thing occurred index of these days. however, no matter loop use , how, mess , either absolutely irrelevant or infinite loop. here have far: void abovebelow (int n, float days[maxn][2]{ int counter=0; float a[maxn]; (int i=0; i<n; i++){ (int j=0; j<n; j++){ if ((days[i][0]<0 && days[i][1]>0) || (days[i][1]<0 && days[i][0]>0)){ counter++; i=a[j]; cout<<counter<<" "<<a[j]<<" "; } } } you simple for-loop. why use 2 nested loops that? and plus, if-condition modified to: for (int i=0; i<n; i+...

sorting - yii sort by a custom attribute -

in vacation model vac have function public function getvaccount(){ this function returns how many days there in 1 vacation. and want add custom column cgridview this: <?php $this->widget('zii.widgets.grid.cgridview', array( ... array( 'name' => 'count', 'value' => '$data->getvacperiod()' ), ... ), )); ?> it works fine. don't know how can sort upon custom attribute. tried use csort not work. idea? to use csort sorting, you'll need convert vacation function sql query , stash results in public variable in model. csort works sql statements/functions, underneath it's using order sorting. more info (and demo code) available here here's sample of how i'm doing on site of mine: $criteria->select = array( "*", new cdbexpression("if(survey.requestdate,...

Is it possible to write type-generic entities in VHDL? -

so, inherited vhdl code, , first reaction was, "vhdl has structs, why use bit-vectors everywhere?" , realized because there not seem way write this: entity queue generic ( el : type ); port ( data_in : el; data_out : el; ... ); end entity queue; i wish possible. there remotely approximating it? if have retype entity or component declarations, way avoid retyping architecture definition every (modulo generic width) type? yes, , implementing queue 1 of classic reasons it! this has been in vhdl since vhdl-2008. tool support variable of mid-2012. talk slow-moving industry! aldec supports completely . modelsim has partial support - can't find public link capabilities. if have installed, it's in /technotes/vhdl2008.note xilinx (xst/isim) doesn't support it, or vhdl-2002. can't find simple link, these pdfs have sections on vhdl compatibility, talk of vhdl-1993. altera's tools have par...

javascript - Sencha Touch 2 Map using different Latitude and Longitude for each item in List (Sencah) -

i building app contains list of addresses. app working in such way once user clicks on each of items (addresses) in list, next page shows map, , map has marker points exact location of address clicked on. made possible due latitude , longitude coordinates stated in code. problem have more 1 address, , each of these addresses have unique longitude , latitude. want make app work in such way when user clicks on address interested in, app open page , show map , marker pointing exact location of address on map. code's below: working perfectly, when user clicks on address, takes them same logitude , latitude. my store: ext.define('list.store.presidents', { extend : 'ext.data.store', config : { model : 'list.model.president', sorters : 'lastname', grouper : function(record) { return record.get('lastname')[0]; }, data : [{ firstname : "ikhlas hq", lastname : "tower 11a, avenue 5, b...

javascript - XML Parsing Error: not well-formed while parsing XML string with browser's built in parser -

i trying parse xml string browser's built in parser using javascript. xml string looks this: <?xml version='1.0' encoding='utf-8' ?> <xsd:schema xmlns:xsd='http://www.w3.org/2001/xmlschema' xmlns:xsi='http://www.w3.org/2001/xmlschema-instance' xsi:schemalocation='http://www.w3.org/2001/xmlschema xmlschema.xsd' elementformdefault='qualified' version='1.0'> <xsd:element name='probemetadata' type='oasis.system.processor.linuxprocessorprobe' /> <xsd:complextype name='oasis.system.processor.linuxprocessorprobe'> <xsd:complexcontent> <xsd:extension base='oasis.system.processor.processorprobe'> <xsd:sequence> <xsd:element name='nice_time' type='xsd:unsignedlong' /> <xsd:element name='iowait_time' type='xsd:unsignedlong' /> <xsd:element name='ir...