Posts

Showing posts from January, 2010

java - How to let missing entries expire more quickly in Guava -

i have java service translates string key long id, through database lookup. i'm wrapping in guava cache reduce database queries. mapping key id doesn't change once it's set, can use long expire time existing keys. there timing issue (not in guava in app) might lookup id key before in database. not want cache "missing" mapping long. want cache though, avoid rush of queries same missing key. i read question: handle null value ... , , there cobbled solution 2 caches. have "missing keys" cache, let expire more , has no auto-load function. check cache first, , if find there know it's missing key. otherwise, try "real" cache, catching executionexception indicate "missing" , manually populate "missing keys" cache. feels quite awkward, part throw exception in load method when there's no mapping. wonder if there isn't more elegant way handle kind of problem. you might try based on refresh , implem

c# - Why is System.ComponentModel.AttributeCollection indexer inconsistent? -

in reference system.componentmodel.attributecollection.this[type t] indexer, docs @ http://msdn.microsoft.com/en-us/library/yadycs8s.aspx following if attribute not exist in collection, property returns default value attribute type. with in mind following code works expected: (> represents output) using system.componentmodel; var attrcollection = new attributecollection(); console.writeline(attrcollection[typeof(browsableattribute)] != null); > "true" prints "true" expect. trying random attribute debuggerdisplay, indexer returns null: var attrcollection = new attributecollection(); console.writeline(attrcollection[typeof(system.diagnostics.debuggerdisplayattribute)] != null); > "false" any ideas on different between these attributes, causing different behavior? unclear me msdn means 'default value attribute type' not null. thought perhaps problem attribute type no parameterless constructor, browsableattribute requires

javascript: clone a function by assigning it to a variable -

why can't clone function in javascript assigning variable? e.g: var $ = document.getelementbyid; usage attempt: typeof $; //--> "function" $('nav'); //--> "typeerror: illegal invocation" think duplicate function, , still callable. can explain why not? when assigning document.getelementbyid variable lose this === document part you'd have when calling method of document . avoid this, use .bind() explicitly set this context function uses: var $ = document.getelementbyid.bind(document);

javascript - Changing CSS from AngularJS -

dom changes angularjs controllers not practice. in application, after clicking on link, changing class of html element inside ngview. intended behaviour is, have 3 divs, , changing if middle 1 shown or not. doing controller. have read, doing dom manipulation should done in directive, mind not broad enough find solution. please, if have suggestion, glad. use ng-class . e.g: http://jsfiddle.net/rd13/ettzj/75/ app = angular.module('myapp', []); app.directive("click", function () { return function(scope, element, attrs) { element.bind("click", function() { scope.boolchangeclass = !scope.boolchangeclass; scope.$apply(); }); }; }); some html: <div id="page"> <div>one</div> <div ng-class="{'my-class':boolchangeclass}">two</div> <div>three</div> <button click>click me</button> </div> when cl

wpf - No binding to IValueConverter DependencyProperty Occuring -

for wpf datagrid, i'm using ivalueconverter inherits dependencyobject, can add parameters. problem converter not being notified parameters have changed. when convert function runs, properties default values. here's of code. note property names have been changed protect innocent. xaml: <usercontrol x:class="uselesstool" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:my="clr-namespace:lots.of.useless.stuff" x:name="myself"> <grid x:name="layoutroot"> <grid.resources> <my:invasiveweightconverter x:key="totalweightconverter" departme

linux - Erratic average execution times for C function -

i'm trying optimize chunk of code given me friend baseline average execution times of extremely erratic , i'm lost why/how fix it. code: #include <sys/time.h> #include <time.h> #include <stdio.h> #include "wall.h" /* code */ int main() { int average; struct timeval tv; int i; for(i = 0; < 1000; i++) /* running code 1,000 times */ { gettimeofday(&tv, null); /* starting time */ start(); /* launching code */ int ret = tv.tv_usec; /* finishing time */ ret /= 1000; /* converting milliseconds */ average += ret; /* adding average */ } printf("average execution time: %d milliseconds\n", average/1000); return 0; } output of 5 different runs: 804 milliseconds 702 milliseconds 394 milliseconds 642 milliseconds 705 milliseconds i've tried multiple different ways of getting average execution time, each 1 either doesn't give me precise en

Accessing cookies from a chrome app -

i can see when issue xhr chrome app sends cookies, , these cookies kept track of in app. servers sending set-cookie headers updating them correctly. need read cookie though, , tried using "cookies" permission chrome yelled @ me... there api can use? edit: using new packaged apps. cookies apparently dark area of chrome packaged apps. with extensions, extension shares cookie jar normal browsing activities. packaged apps, each app has separate jar. the current behaviour seems xhr requests sites specified in manifest in permissions section set cookies in jar there no way how rid of them, except reinstalling app. there no api packaged apps manage cookies , cookies not show in developer tools or about://settings/cookies page. the crbugs include https://code.google.com/p/chromium/issues/detail?id=70391 https://code.google.com/p/chromium/issues/detail?id=152758 https://code.google.com/p/chromium/issues/detail?id=157474 and these 2 issues filled in resp

javascript - How to implement custom events using Google Visualization? -

i have following code below using google's visualization library charts. currently, have selecthandler function returns alert column row. instead of alert column number, trying implement javascript sends alert of 'key' of item shown below. how this? <% @frequency.each |key,value| %> ['<%= key %>', <%= value %>], <% end %> javascript <script type="text/javascript"> google.load("visualization", "1", {packages:["corechart"]}); google.setonloadcallback(drawchart); function drawchart() { // options var options = { title: 'most common phrases in pro-microsoft reviews (<%= @reviews.count %> reviews analyzed)', vaxis: {title: 'phrases', titletextstyle: {color: 'red'}}, tooltip: {ishtml: true}, animation:{ duration: 2000, easing: 'out&#

android - How to get rid of double decimal place -

i'm trying rid of of decimal places in double,i'v done on other part's of app cant figure out here. double coming in in , i'm setting edit text double dryfree = sender.getextras().getdouble("resultfree"); else if (getintent().hasextra("resultfree")) { answer.settext( dryfree + ""); this i'v tried app crashes else if (getintent().hasextra("resultfree")) { answer.settext(string.format("%.2f", dryfree + "")); activity number coming from, tried using string.format here getting errors, know i'm using wrong total = (int) (a * b * c) / 0.424753;

android - EmPubLite Crashing on Tutorial #16 -

once again running crash on tutorial right @ end: 04-17 17:39:36.278: e/androidruntime(536): fatal exception: main 04-17 17:39:36.278: e/androidruntime(536): java.lang.nullpointerexception 04-17 17:39:36.278: e/androidruntime(536): @ com.commonsware.empublite.bookcontents.getchaptercount(bookcontents.java:26) 04-17 17:39:36.278: e/androidruntime(536): @ com.commonsware.empublite.contentsadapter.getcount(contentsadapter.java:23) 04-17 17:39:36.278: e/androidruntime(536): @ android.support.v4.view.viewpager.populate(viewpager.java:744) 04-17 17:39:36.278: e/androidruntime(536): @ android.support.v4.view.viewpager.setadapter(viewpager.java:344) 04-17 17:39:36.278: e/androidruntime(536): @ com.commonsware.empublite.empubliteactivity.setuppager(empubliteactivity.java:88) 04-17 17:39:36.278: e/androidruntime(536): @ com.commonsware.empublite.modelfragment.delivermodel(modelfragment.java:36) 04-17 17:39:36.278: e/androidruntime(536): @ com.commonsware.empublite.modelfragment.acce

c - Bubble sort not working at all, if statement not executing -

i'm working on program going used sort students test scores , retrieve mean, median, , mode of scores. strange reason bubble sort not working.. i'm unsure why. #include <stdio.h> #include <stdlib.h> #include <string.h> #define n 3 int main (void) { char vstudents[n][15], trans = 'y', vtemp2; int vscores[n], vtemp, x, = 0, j=0, newn; printf("\t\twhatsamatta u scores system\n\n"); { printf("please enter students name: "); gets(vstudents[i]); trans = 'n'; while (trans == 'n') { printf("enter students score: "); scanf("%d", &vscores[i]); fflush(stdin); if (vscores[i] >= 0 & vscores[i] <= 100) trans = 'y'; else printf("score invalid, please re-enter score.\n"); } i++; j++; } while (j != n); for(x = 0; x < n - 1; x++) { if ((x < n - 1) && (vs

Switch view template based on model state in Ember.js -

i have notification box in ember.js app change text, styling, , buttons based on value of status model. how switch view (or template) notification box? don't want transitionto because rest of page shouldn't update, notification box. i have jsfiddle complete example . here's relevant parts glance at: the main template render notification bar ("statusstate") , regular view data. <script type="text/x-handlebars" data-template-name="status"> {{render "statusstate" content}} <p> other information not related status state, still related status goes here. </p> {{outlet}} </script> there's separate template each status state ("pending", "ready", "finished"): <script type="text/x-handlebars" data-template-name="status/pending"> <div style="background-color: grey"> status pending. </div> </script> <

argument passing - Can't get PHP string variable to expand -

i define string variable this: $menu = '../views/menus/documentation-menu.html'; later in script try use so: $content = file_get_contents("{$menu}"); but when run script, warns me "warning: file_get_contents(): filename cannot empty in ". if fact, i've tried sorts of combinations double quotes , single quotes , no braces, wrong. if put string in directly, works expected: $content = file_get_contents("../views/menus/documentation-menu.html"); but want $menu argument file_get_contents, not hard-coded string. i'm missing simple because don't know php .... have tried $content = file_get_contents($menu); ? that said, want manipulate file contents, or include in page? if latter, use include or require .

drop down menu - asp.net mvc How to add placeholder for html.dropdownlist -

i'm using asp.net mvc 3. i have dropdownlist of countries , want add placeholder it. here's code: @html.dropdownlist("country", new selectlist(viewbag.countries system.collections.ienumerable, "name", "name"), new { @class="chzn-select", @placeholder="-select-", @style="width:160px;" } ) but placeholder doesn't work, while style works. how set placeholder this? ps. want use @html.dropdownlist , not @html.dropdownlistfor in collection viewbag.countries insert dummy record @ of collection name "-select-". should able force selected item alternate constructor this: @html.dropdownlist("country", new selectlist(viewbag.countries system.collections.ienumerable, "name", "name", "-select-"), new { @class="chzn-select", @style="width:160px;" } )

c# - Show similar products or variants -

i want show similar products called variants product. doing below: public ilist<product> getvariants(string productname) { efcontext db = new efcontext(); //using entity framework return db.products .where(product = > product.productname == productname) .tolist(); } but , results exact match, current product itself. thinking use levenshtein distance basis similar products. , before want check majority developers getting variants? is use levenshtein distance ? used in industry purpose? do have add table in database showing variants product while adding product database? i used jaro-winkler distance account typos in 1 system wrote while back. imo, it's better simple edit distance calculation can account string lengths effectively. see this question on open source implementations. i ended writing in c# , importing sql server sql clr function, still relatively slow. worked in case because such queries executed infreq

c# - Best way to for handling paths -

in project, have 2-3 classes having paths local filesystem folders. below: class 1: private static string upload_root = "~/uploads/"; private static string images_folder = "images"; class 2: private static string upload_root = "~/uploads/"; private static string psd_folder = "generated photoshop psds"; so, can see, upload_root repeating wherever need it. want keep these paths in single file. how should that? possible solution can see put these files in static class , use below: public static class pathsettings { public static string upload_root = "~/uploads/"; public static string images_folder = "images"; public static string psd_folder = "generated photoshop psds"; } then using class below: file.saveas(pathsettings.upload_root + filename); how should store then? using static class best solution? used in cmses? the static class constants valid. main downside approach a

jsp - Java : download file outside server context -

i need save file , download file in directory outside server context. using apache tomacat able in directory present in webapps directory of application if directory structure follows, --src --webcontent -- uploaddir -- myfile.txt then able download in simply. <a href="uploaddir/myfile.txt" target="_blank">download</a> but, problem when file in other directory d:\\uploadedfile\\myfile.txt then wont able download it, resource not in server context above. i have file path uuid mapping, like, d:\\uploadedfiles\\myfile.txt <-> some_uuid then want file should downloaded, on click of following, <a href="filedownloadservlet?ref_file=some_uuid">download</a> so, how make file downloadable when outside server context, heard getresourceasstream() method , 1 me on how this, simple code snippet? try below code can write in filedownloadservet. fetch file name request parameter , re

Inheriting from the DOM Element object in javascript ! Whats wrong with this code? -

i trying inherit dom element object,all code runs fine when create object when try call appendchild() method ,it gives error saying : myobject doesn't have appendchild method here code: var content=document.createtextnode("this dynamically created"); function myobject(tagname){ element.constructor.call(this,tagname); this.prototype=element.prototype; this.prototype=object.defineproperties(this.prototype,{ newmethod:function(){ //dosomething } }); } var newobj=new myobject("div"); newobj.appendchild(content); though you're doing incorrectly (more on later) , you're trying pass object inherits dom element instead of dom element itself. not allowed. it seems should work, dom elements , dom methods host objects. don't play same rules you'd expect native objects. .appendchild() method wants element, , nothing else. you're trying won't work. with respect approach inheritance, it

asp.net mvc - English Email Displays Chinese-like Characters -

i'm using postal send emails html , text portion. when email sent gmail, displayed correctly. however, when displayed in @ least 2 other email systems (mail enable's webmail interface, , unknown system @ client), text rendered similar chinese. when client forwards email gmail account, "chinese" rendering visible. example email generated: x-sender: no-reply@thecompany.com x-receiver: therecipient@thecompany.com mime-version: 1.0 from: no-reply@thecompany.com to: therecipient@thecompany.com date: 17 apr 2013 22:11:25 -0700 subject: subject content-type: multipart/alternative; boundary=--boundary_0_83808b99-ef32-4f47-8835-ba4a435a2141 ----boundary_0_83808b99-ef32-4f47-8835-ba4a435a2141 content-type: text/plain; charset=utf-16 content-transfer-encoding: base64 mime encoded contents here== ----boundary_0_83808b99-ef32-4f47-8835-ba4a435a2141 content-type: text/html; charset=utf-16 content-transfer-encoding: base64 mime encoded contents here= ----boundary_0

html - Viewport, media queries, usable in lower than html5 -

is viewport usable in html versions before html5? , can 1 please enlighten me how use viewport , media queries? trying make site resposive website , @ same time 'mobifying' it. don't think it's built using html5. insights please? in advance. first of should not thing of "html5" single concrete entity , particular things usable before html5 or not. whether can use viewport (i assume mean <meta name="viewport"> ) depends largely on device. <meta name="viewport" content="width=device-width"> , more commonly used smaller devices such phones, not need use larger screens. depends on situation, though, i'll reiterate: depends on device , user agent (browser). as using media queries part of css3 spec , has nothing html5 @ all. once again, whether or not media queries supported (and how they're supported) depends on user agent.

android - Multiple Notification is getting from (GCM)Google Notification Server? -

i have multiple different deviceids in database table pointing same device because google send me different device id when device reinstall/install. due devices getting multiple notifications hurting me , users much. there way tell google send 1 notification single device? or there way check id new or old before sending request? experience weird issue? btw, using pushsharp/asp.net in backend. update : relying on native device id. so, remove/replace old registration ids database table native device id same. i think need remove device id database once unregistered error code. unregistered device existing registration id may cease valid in number of scenarios, including: if application manually unregisters issuing com.google.android.c2dm.intent.unregister intent. if application automatically unregistered, can happen (but not guaranteed) if user uninstalls application. if registration id expires. google might decide refresh registration ids. if application updated new vers

html - Validate XML and DTD in browser -

i have make validation of xml , dtd, question happen if remove xml tag defined required field in dtd?, continue displaying xml in browser?, or mark me error? , or in case validate such situations?. annex dtd , xml <?xml version="1.0" encoding="utf-8"?> <!doctype dispositivos system "productosdtd.dtd"> <dispositivos> <dispositivo id="kos1000" nombreproducto="cafetera" marca="oster" precio="275 mxn"> <fechaimportacion> 05/04/1992</fechaimportacion> <precioaduana>85</precioaduana> <idpedido>mtg08042013</idpedido> <nombreaduana>viva mexico</nombreaduana> <observacionesproducto> excelente estado :d </observacionesproducto> <fabricantedispositivo nombre="la rivera" calle="av de las granjas" numero="1230" delegacion="azcapotzalco" entid

php - Change Default Date to firstday of previous month -

i trying change default date first day of previous month in yii cjuidatepicker. date displaying in textfield correctly,but in datepicker popup shows current date. code $model_form->suspended_date_from =date("d-m-y", mktime(0, 0, 0, date("m")-1, 1, date("y"))); $date= date('dd-mm-yy', strtotime($model_form->suspended_date_from)); $this->widget('zii.widgets.jui.cjuidatepicker', array( 'model' => $model_form, 'attribute' => 'suspended_date_from', 'htmloptions' => array( 'class' => 'reporttext-field fromdate', 'id' => uniqid(), ), 'options' => array( 'dateformat' => 'dd-mm

javascript - Questions about jQuery patterns -

so decided learn jquery , needed simple function 1 of projects, started search pattern. i began official guide found many other possible templates. reference 2 of them ask questions: first one second one the first pattern seems lot more cleaner me, idea of namespace much. but, how used? write whole functions methods of namespace, calling of them in init() , call 1 method init() in iife , or should call necessary methods directly in iife ? i feel question idiotic, can't understand usage. the second pattern more complicated me. have @ this: ;(function ( $, window, document, undefined ) { //... })( jquery, window, document ); what these parameters, set them , why needed? disadvantage of wrapper in first sample? the diversity of possibilities overwhelming, don't know start or how figure ot right thing me. check excellent article on smashing magazine . covers multitudes of jquery plugin patterns , explains each , every 1 of them. edit: ther

Android - how to handle saving file on low device memory(Internal/External memory) -

how can handle file saving on low device memory(internal/excternal memrory). know if sufficient space not available os throw ioexception there way handle gracefully. file path = environment.getdatadirectory(); statfs stat = new statfs(path.getpath()); long blocksize = stat.getblocksize(); long availableblocks = stat.getavailableblocks(); return formatter.formatfilesize(this, availableblocks * blocksize);

Java - Static and Dynamic Array Initialization -

is true every array initialized during runtime dynamic , every array initialized during compiling static? for example: int array[]; public main() { array = new int[100]; } the compiler knows how many elements array has can initilize during compiling right? or need give every int value becomes static? this: int array[3] { 1, 2, 3}; and posible define how many elements array should have outside main() function? (without giving every int value) this: int array[100]; public main() { } i programming little game , has run fast. read dynamic arrays need bit longer process want try static arrays, not sure when array becomes static or dynamic. searched in many diffrent tutorials couldn't find answer that. reading. the distinction of dynamic , static allocation ambigous (it depends on language means). in general sense, static allocation means size has been predetermined, maybe @ compile time. in java, objects (t

c# - NotifyIcon not showing complete message -

i'm using notifyicon displaying information regarding background process-result of c# windows application. not show complete message. hides of lines of given message. can 1 tell me there restriction in message body? or how can force notifyicon display complete message? the length of text of notifyicon limited 64 characters. there's 'hack' around this, please take @ solution of this question . hope helps!

c# - Avoid from running more than one instance -

i'm trying set mutex in order allow running application in 1 instance only. wrote next code (like suggested here in other post) public partial class app : application { private static string appguid = "c0a76b5a-12ab-45c5-b9d9-d693faa6e7b9"; protected override void onstartup(startupeventargs e) { using (mutex mutex = new mutex(false, "global\\" + appguid)) { if (!mutex.waitone(0, false)) { messagebox.show("instance running"); return; } base.onstartup(e); //run application code } } } regretfully code isn't working. can launch application in multiple instances. has idea wrong in code? thanks you disposing mutex after running first instance of application. store in field instead , don't use using block: public partial class app :

java - How to Backup and Restore a MySQL Database using NetBeans? -

i'm developing software netbeans , i'm using mysql database server. i' planning use 2 buttons as, "backup database" , "restore database" respective functions. how accomplish these functions? , both functions, awesome if file chooser window used functions too. in advance! :) what creating dump , saving it? , running when want restore? http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html edit: well since dont know how achieve ill more specific. mysqldumpl must run commandline pls read link: http://docs.oracle.com/javase/7/docs/api/java/lang/runtime.html your code should this: string yourcommand = "mysqldump -h localhost -u [user] -p[database password] -c --add-drop-table --add-locks --all --quick --lock-tables [name of database] > sqldump.sql"; runtime.getruntime().exec(yourcommand); after should have succefully saved file data of database the last part of string "sqldump.sql" name of file, can set ow

ios - How to get div id in cocoa webview xcode -

anyone tell me how div id script webview used code not working nsstring *strtitle1=[webview stringbyevaluatingjavascriptfromstring:@"document.getelementbyid('div_indicator').innerhtml;"]; nslog(@"strtil:%@",strtitle1); try code objective-c-hmtl-parser , hpple and have tutorial how parse html on ios

why onConfigurationchanged is not called for android:configChanges="locale"? -

i want when change language occurs. put activity in manifest.xml in attribute andorid:configcahnges locale: <activity android:name=".mainactivity" android:configchanges="orientation|keyboardhidden|screensize|locale" android:hardwareaccelerated="true" android:label="@string/app_name" android:theme="@android:style/theme.devicedefault.noactionbar.fullscreen" > <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </intent-filter> </activity> but when run app , go setting , change language method onconfigurationchanged isn't call in mainacitvity. why? docs android says should. develop api 16. i find out if put add android:configchanges layoutdirection , set andro

oauth - Multiple OAuth2 access tokens for single application? -

maybe clarify me, not finding written in documentation... i have single application, running on multiple machines. oauth2 have obtain access token in order work google api. need use single access token across hosts , take care synchronized across them (which increases complexity level, once token expires - must refreshed , again distributed across hosts), or possible each host own token , cache locally? i not sure either 2nd option safe (though easier implement), documentation writes token can become invalid once refreshed. happen, while 1 host creating "own" token other tokens (from other hosts) become automatically invalid? i assume application web application deployed in cluster, correct? is there session state distributed on cluster? if so, add access token session. in theory can have multiple access tokens, don't rely on that. there rate limits can run into, if machine getting multiple access tokens not issue.

c - Debugging program with pointers and arrays -

kindly in resolving this,the error i'm getting here syntax near '{' since had declared unsigned char near dac_table got error,so define outside function wrong...i have not posted complete code here...in part of code i'm getting problem.. unsigned char dac_table[16]; unsigned char *ptr2tbl; void fnselectvoltage(void) { line_display(1, "volt sel"); sprintf(line_buf," %d v",(unsigned int)*ptr2tbl); line_display(2, line_buf); dac_table[16] = ( 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f); *ptr2tbl = &dac_table; while (start_key) { if (!up_key) { wait_for_any_key_counter_0 = 0; (i = 0; i<15; i++) { p2 = *ptr2tbl++; // delay_ms(1000); } } else if(!down_key) { wait_f

Android Maps API v2 - event onClick on my location cursor -

i have application using maps api v2 , use method map.setmylocationenabled(true); display user location. works in classic google maps application, blue radius around position cursor implement on click on position cursor display accuracy in toast or pop up. have not found in maps api v2 reference nor in stackoverflow that... the thing know can accuracy map.setonmylocationchangelistener() , location.getaccuracy(); maybe should put custom marker on own position same imageresource default own-location marker own onclicklistener, way same built-in one, don't forget track user's location, , update marker @ every location changed event.

wpf - Events for Listbox Item -

what recommended event use listbox items. have 3 static items in list , should navigate page upon clicking. know there's no click event listbox items or listbox. bind in view model. have in mind selected event, correct? method used binding how syntax of navigation when item selected? in advance! <listbox x:name="lbviewlist"> <i:interaction.triggers> <i:eventtrigger eventname="selected"> <command:eventtocommand command="{binding viewlistcommand}"/> </i:eventtrigger> </i:interaction.triggers> <listbox.items> <listboxitem content="by product" fontsize="25"/> <listboxitem>by vendor</listboxitem> <listboxitem>by best combination</listboxitem> there 2 listbox-events can achieve this: uielement.tap event selector.selectionchanged event in both cases can item through selectedindex or

Drawing and Animation in iOS -

my background processing , html5 canvas. want write ios app, , include kind of canvas, can draw shapes , images on, similar sketch in processing (2d). what's common / simple way in ios development? appreciate links tutorials started, if know some. the simple way is, assuming not using java libraries in processing, use processing.js , .pde file in phonegap can compile native code ios. have done , works although performance simular in mobile safari html5 app.

php - Submitting form - using javascript -

i have page loops though 15,000 entries importing them in database. after each 50 entries user presented continue button. <form name="contine" method="post" action="<?php echo $continue?>"> <input type="submit" name="submit" value="continue"></input> </form> this works well, slows script down doesn't load server (nas drive running php4), , gets around php page timeout. $continue contains script name , current position of import, after submission page start there. i'm trying user doesn't need sit there clicking continue after ever 50 entries. 15,000 in total it's lot of clicks. i've tried using header('location: '.$continue.'/'); works if try importing around 3,000 entries, more , chrome complains looping. so i'm hoping can replace input button javascript submit form me. is possible , how ? thanks :) using plain js, submit f

c - Field within structure take random values -

i'm new c , i'm trying define matrix using struct , methods change int** field of struct. matrix supposed dynamically allocated , resizable in how many rows can have. when run program below , print out values of matrix in main, matrix have random values, not ones inserted in genmatrix() , addrow(). doing wrong? grateful help. i define struct this: typedef struct matrix { int** matrix; int rows; int cols; int capacity; } matrix; and have following methods should change field of struct: matrix* genmatrix() { matrix* matrix = malloc(sizeof(matrix)); initmatrix(matrix, 100, 3, 200); (int = 0; < 10; i++) { (int j = 0; j < 10; j++) { int row[] = {i+j, i*j, i-j}; addrow(matrix, row); } } return matrix; } void initmatrix(matrix* matrix, int rows, int cols, int capacity) { matrix->matrix = malloc(rows * sizeof(int*)); (int = 0; < rows; i++) { matrix->

android - Media Recorder Start Failed-22 inside a thread -

hi trying make video recorder android app> reason need audio, have tried libraries nothing extracted me audio. approach instead of using native libraries can record video , audio separately? main thread records video , thread records audio. getting error when call start() method of media recorder class inside thread , start failed -22. following code. public class mainactivity extends activity { private surfaceholder surfaceholder; private surfaceview surfaceview; public mediarecorder mrec ; imageview recordingbt; public mediarecorder mrec2 = new mediarecorder(); file video; private camera mcamera; file audiofile = null; file audiofile2 = null; boolean recording=false; textview tv; view myview; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); recordingbt= (imageview) findviewbyid(r.id.camera); surfaceview = (surfaceview) find

c# - Bliting two WriteableBitmap with WriteableBitmapEx -

i tried blit 2 writeablebitmap. however, debugger prompted error message stating followings: the input writeablebitmap needs have pbgra32 pixel format. use bitmapfactory.converttopbgra32format method automatically convert input bitmapsource ?to right format accepted class. here code. rect crect =new (320,240); writeablebitmap _bitmap = new writeablebitmap(320, 240, 96, 96, pixelformats.bgr32, null); _bitmap.writepixels(new int32rect(0, 0, 320, 240), _image, 320*240, 0); //_image image stream _bitmap.blit(crect, _imageframe, crect); //_imageframe writeablebitmap actually _imageframe writeablebitmap canvas change content @ regular time. there more effective way blit writeablebitmap , canvas? can change line: writeablebitmap _bitmap = new writeablebitmap(320, 240, 96, 96, pixelformats.pbgra32, null); and similiar on _imageframe writeablebitmap

php - TYPO3 mm-Query giving me no output and no error -

i've tried output data 2 linked tables , had @ examples find, i'm still not getting results. (note: i've tried exec_selectquery on either table , worked charm) so here's code $globals['typo3_db']->debugoutput = true; $res = $globals['typo3_db']->exec_select_mm_query( 'tx_pagecat_category.title', // $select_fields 'tx_pagecat_category', // $local_table 'pages_tx_pagecat_category_mm', // $mm_table 'pages', // $foreign_table '', //$where_clause '', // $groupby '', // $orderby '' // $limit ); while( $row = $globals['typo3_db']->sql_fetch_assoc($res) ) { $c= $row['tx_pagecat_category.title'].chr(10); } return $this->pi_wrapinbaseclass($c); i have absolutely no idea i'm doing wrong, debug-output not working? probably easiest way is: $globals['typo3_db']->store_lastbuiltquery = 1; // query here

iphone - complex tableview with horizontal and vertical scrolling -

Image
i making complex tableview. should do it should have section headers title when scroll horizontal whole tableview should scroll horizontal you can not scroll in 1 section. here little screenshot. now question is, how can this? since not familiar uicollectionviews , try following: 1. create uiscrollview , set frame backgroundview.frame , add backgroundview 2. create uitableview . guess content dynamic, should possible calculate maximum width summing width of elements in each section / row. make tableview.size.width calculated width, add tableview scrollview . 3. set scrollview.contentsize.width calculated tableview.size.width . if understood question correctly, should have uitablview can scrolled horizontally , vertically. let me know if helped. edit: i created simple project doing described above. until now, datasource array of texts. should no big deal use array of e.g. custom uiviews add cell.contentviews . it seems work. feel free test i

Undefined symbols for architecture x86_64 error when linking OpenCV in Xcode -

i have problem linking opencv in xcode. installed opencv using brew: brew tap homebrew/science sudo brew install opencv i started new xcode commandline project, added /usr/local/lib , /usr/local/include library , header search path. added output of pkg-config --libs opencv other linker options . but when try compile small sample program: #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> int main(int argc, char *argv[]) { cv::mat test; cv::namedwindow( "display window", cv_window_autosize );// create window display. cv::waitkey(0); // wait keystroke in window return 0; } i following linker error: undefined symbols architecture x86_64: "cv::namedwindow(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int)", referenced from: _main in main.o ld: symbol(s) not found architecture x86_64

java - loss of precision-->Required double but compiler required int? -

i beginner in java , faced error. write method named pay accepts real number ta's salary , integer number of hours ta worked week, , returns how money pay ta. example, call pay(5.50, 6) should return 33.0. the ta should receive "overtime" pay of 1 ½ normal salary hours above 8. example, call pay(4.00, 11) should return (4.00 * 8) + (6.00 * 3) or 50.0. public double pay(double x,int y){ int sum=0; double hours=8.0; if(y>hours){ sum=(y-hours)*(1.5*x) + (hours*x); } return sum; } error: you have mismatch between data types. occurs when try store real number (double) variable or parameter integer (int). possible loss of precision found : double required: int sum=(y-hours)*(1.5*x) + (hours*x); ^ 1 error 19 warnings but error pointing @ + sign.what wrong it? says found:double. want output double. said required int. since sum int , you're returning sum in you're method, that&#

vhdl - 8 bit ALU for microprocessor -

i have project supposed develop risc microprocessor . involves creating alu in behavioral model . there seems problems/errors/warnings while simulating design . of operations work except following : comparing 2 inputs : when numbers equal , 0 flag not getting set . ( unequal numbers working ) . warning: there 'u'|'x'|'w'|'z'|'-' in arithmetic operand, result 'x'(es). ( appears every 1 ps , presumably due wait statement in process ) i wish work std_logic_vector, though read messy . also, there problem when try use comparing commands ( update flags dont store difference in output register ) . how if commands executed in vhdl ?? executed @ same time ?? or line line ?? code below : library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; entity alu port( input1 , input2: in std_logic_vector(7 downto 0 ) ; carryin : in std_logic ; zero,carryo

iphone - Which ViewController Concept to use? -

Image
i need following view layout in application. the green view viewport of ios application. on top (the blue ones) views should swipeable left , right 1 view (different content) visible @ time. views should snap in place if swipe. under this, there more views arranged horizontally (the orange ones). should snap in place (always centered 1 view in grey section) after swiping. here more 1 view visible @ time. there concepts pageviewcontroller , uiscrollview , uicollectionview , one. which 1 choose this? also idea add subviewcontrollers layout? controller each of scroll views? thanks in advance. for top go 3 uiviewcontroller's uiview (depending on complexity of objects). if simple things add 3 uiview's , and handle logic in same uiviewcontroller . either putting 3 inside uiscrollview (with pagingenabled ) or handling gestures both valid possibilities. botton uiviews (orange) uicollectionview (so handle memory you). uiscrollview botton, work, if

java - htop and top showing multiple instances of process? -

Image
i running java process ant. running 1 process. when use htop, seeing following information: scrolling right gives: basically, middle section comprised of just java process. when ps aux | grep java , see: $ ps aux | grep java victor 27982 1.0 1.9 3799504 163112 pts/1 sl+ 02:00 0:06 /usr/bin/java -classpath /usr/share/ant/lib/ant-launcher.jar:/usr/share/java/xmlparserapis.jar:/usr/share/java/xercesimpl.jar -dant.home=/usr/share/ant -dant.library.dir=/usr/share/ant/lib org.apache.tools.ant.launch.launcher -cp tag victor 28003 19.0 6.6 3523136 544812 pts/1 sl+ 02:00 1:51 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java -xmx2048m -classpath /home/victor/giordano/java/lib/commons-math3-3.0.jar:/home/victor/giordano/java/lib/guava-14.0.1.jar:/home/victor/giordano/java/lib/joda-time-2.2.jar:/home/victor/giordano/java/lib/postgresql-9.2-1002.jdbc4.jar -jar /home/victor/giordano/java/build/jar/giordano.jar 15 victor 28135 0.0 0.0 9388 924 pts/3 r+ 02:

php - get value of variables defined in shell script -

how can value of variable defined in shell script? (the script configuration file, contains variable-definitions) cannot use "source" command in exec: echo exec('var=2; echo $var'); //writes "2" echo exec('source config.sh; echo $var'); //writes "" how can value of variables defined in shell script? userthis worked me on terminal: echo var=2 > shellscript echo "<?php echo exec('source /home/user/shellscript; echo $var'); ?>" > phpscript.php ls | grep script phpscript.php shellscript php phpscript.php 2 so wrote shellscript, php read shell script , ran php script. did wanted. maybe can add other exec components clue? <?php echo exec('source /home/user/shellscript; echo $var',$out,$ret); echo "\nout0: ". $out[0]. "\nret: $ret\n"; ?> this shows me: ~]$ php phpscript.php 2 out0: 2 ret: 0

Android Layout positioning incorrectly -

Image
i'm trying create layout list child. here should like: but when text name large displaced like: i'm using following code <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="35dp" android:background="@color/text_blue" android:orientation="horizontal" android:weightsum="51" > <textview android:id="@+id/tranid" android:layout_width="fill_parent" android:layout_height="34dp" android:layout_marginbottom="1dp" android:layout_marginright="1dp" android:layout_weight="11" android:background="@color/app_bg" android:gravity="center_vertical|center_horizontal" android:lines="2"

tooltip - Cannot get Bootstrap popover to work at all, despite reading numerous replies on here -

ok trying twitter bootstrap popovers work on forum theme coding, , cannot them work @ all. i have read countless similar threads , tried no luck, i'm hoping if can post exact code can tell me i'm going wrong. ok have included javascript in page, required tooltip , popover js files in head: <script src="{$mybb->settings['bburl']}/jscripts/bootstrap-tooltip.js"></script> <script src="{$mybb->settings['bburl']}/jscripts/bootstrap-popover.js"></script> now here html/javascript markup: <a id="pop" title="" data-content="vivamus sagittis lacus vel augue laoreet rutrum faucibus. <p>hi</p><p>hihowareyou</p><p>hi</p>" data-placement="bottom" data-toggle="popover" class="btn" href="#" rel="popover" data-original-title="popover on bottom" data-html="true">popo

html - Twitter bootstrap fixed layout issue -

i have gotten weird problem columns using twitter bootstrap. setting test page should behave example here: http://twitter.github.io/bootstrap/examples/hero.html . here's html: <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" type="text/css" href="/assets/24d7eb4f/css/bootstrap.css" /> <link rel="stylesheet" type="text/css" href="/assets/24d7eb4f/css/bootstrap-yii.css" /> <link rel="stylesheet" type="text/css" href="/assets/24d7eb4f/css/bootstrap-responsive.min.css" /> <script type="text/javascript" src="/assets/8b15478e/jquery.js"></script> <script type="text/javascript" src="/assets/24d7eb4f/js/bootstrap.js"></script> </head> <body> <div class="container&