Posts

Showing posts from May, 2015

javascript - Different size images in website depending on screen resolution -

i have website images, , page loading can slow on mobile devices have mobile internet connection. so, question is: assign different images, smaller or bigger depending on device, when page loaded solution? example img in dom be: <img src="" id="img1" alt="img1" /> and then, adding script in head: $(document).ready(function () { loadimg(); }) the loadimg function can like: if((window.screen.availheight < 1234)&&(window.screen.availwidth < 1234)) document.getelementbyid("img1").src = "small"; else document.getelementbyid("img1").src = "big"; try js library https://github.com/scottjehl/picturefill i don't know how affects seo, though.

Use PHP + jQuery when click on a button -

i have button on page : <button class="play"></button> when click on it, launches video via jquery $('.play').on('click',function(){ player.play(); }); but want add php code save user id in database when clicks on button. how can mix php & jquery? i'm not used ajax, solution? thanks help! try using ajax $('.play').on('click',function(){ player.play(); $.ajax({ type: "post", url: "some.php", // php file name data:{id :"id"}, //pass user id success:function(data) { if(data==true) alert("success"); else alert("error"); } }); } some.php <?php $success=false; //declare , initialize variable // code update database //and check if database updated , if set $success=true echo $success; ?>

text - Grab LDAP Attribute from stdin in Python -

i've got ldap query , i'm not versed in text-processing in python. i'm sending script via stdin , can read out, given reads single line little more lost how grab value of protocol. given protocol=http, want store value after delimiter. my stdin looks (but not exactly): discover-repository-location=null, file name=null, date-detected=tue jun11 12:44:14 utc 2013, endpoint-machine-name=null, incident-id=545527, sender-ip=12.1.141.87, sender-email=winnt://tmpdm/tmpcmp, assigned to=null, sender-port=-null, endpoint-domain-name=null, business unit=null, endpoint-dos-volume-name=null, file-access-date=null, date-sent=tue jun 11 12:44:14 utc 2013, endpoint-file-name=null, file-modified-by=null, country=null, manager email=null, plugin-chain-id=1, discover-server=null, data-owner-name=null, dismissal reason=null, last name=null, first name=null, phone=null, subject=http incident, sender email=null, userid=null, endpoint-user-name=null, endpoint-volume-name=null, discover-nam

java - Recycling an inflated view on Android -

i have complicated viewgroup fragment created every , then. 1 instance fragment can shown @ time. i wondering if possible somehow store inflated view , reuse when fragment created again. obviously view properties have changed, @ least view not need inflated again. i tried store view element static element , check if exists, , if does, use it. however, believe view element has fragment specific properties , if use fragment has different reference id, fail - well..it failed. has tried cache inflated views , reuse them? it seems risky reuse views across different fragments (although it's safe reuse them in same fragment). what if context changes, example if activity gets recreated? guess have hope no views call getcontext() , try use activity context because invalid , may lead unexpected results. what can sure optimized layout (like avoiding nested weights , relativelayouts when possible) or use custom views simplify layout.

What commands Entity Framework 6 enable migrations? -

in entity framework 5.0, supports single dbcontext per database, use syntax enable-migrations -contexttypename mydbcontext // enable migration update-database - verbose // update database schema how same things in entity framework 6 multiple dbcontext single database? please include example or link. anticipated thanks regards zulfiqar i think article answer question: entity-framework-6-code-first-migrations-with-multiple-data-contexts

php - Search MySQL database with Filter options selected by the user. Database structure -

i have form user can fill out, , wish search mysql database entries user has selected. instance, if user enters keyword, , checks option 2 , 3, want search database keyword , options 2 , 3. i'm not sure how set database however. need column in table each option, or there way store array within table? technique occurred me have separate table options. i've seen done before, i'm not sure on proper execution. if knows proper way this, great. edit: database of places, (say, music stores), , options different instruments sold. when user fills out form, want return list of stores names include 'keyword' string , sell instruments selected user. i'm not sure how set database in order proper query. should have each option separate column boolean value, or can have column array of boolean values? note: 'instruments' 1 of many options. want able filter other criteria the html : <form> <input type="text" name ="

c# - {"The INSERT statement conflicted with the FOREIGN KEY constraint The statement has been terminated."} -

there userstats table, want 1 one relationship, i'm getting above error when try , register user.thanks help! user table: public class user { [key] public int id { get; set; } public int userstatsid { get; set; } public virtual userstats userstats { get; set; } } userstats table [key] public int id { get; set; } public int userid { get; set;} [required] public user user { get; set; } registerdetailscontroller [httppost] [validateantiforgerytoken] public actionresult create(user user) { if (modelstate.isvalid) { db.users.add(user); db.savechanges(); if (user.gender == gender.male ) { return redirecttoaction("registermale", "registerstats", new {id = user.id }); } else { return redirecttoaction("regist

java - Detect test failure in testng @AfterMethod -

i want take screenshot if test fails. rather wrapping test methods try/catch blocks, add logic @aftermethod. how can detect in @aftermethod if current test has failed? if @aftermethod takes itestresult parameter testng automatically inject result of test. (source: testng documentation, section 5.18.1 ) this should job: @aftermethod public void teardown(itestresult result) { if (result.getstatus() == itestresult.failure) { //your screenshooting code goes here } }

javascript - Does jQuery class selector event binding attach eventHandler to each instance? -

im learning jquery , when read $('.classname').bind('click',function(){}) method 1 doubt arose. does method attach event handler each instance of classname in dom? if approach -- attaching event handler lot of instances on page overhead right? or making use of event delegation -- say, handler bound common parent make use of e.target equalto classname , execute click event, handler bound 1 dom element? please me understand. thanks. one more doubt. if attach event each , every dom element overload come effect? cause load browser while execution or make dom heavy (by heavy mean, difficulty in parsing dom)? it sure bind callback each , every 1 of elements. if have lot of elements matching selector, better use event delegation. however, don't have manually fiddle around e.target . jquery has overloaded .on() method scenraio: $('#parent').on('click', '.children', function (){}); you should attach event handler close

list to map in python -

i have list , want convert list map mylist = ["a",1,"b",2,"c",3] mylist equivalent mylist = [key,value,key,value,key,value] so input: mylist = ["a",1,"b",2,"c",3] output: mymap = {"a":1,"b":2,"c":3} p.s: have written following function same work, want use iterator tools of python: def fun(): mylist = ["a",1,"b",2,"c",3] mymap={} count = 0 value in mylist: if not count%2: mymap[value] = mylist[count+1] count = count+1 return mymap using iter , dict-comprehension: >>> mylist = ["a",1,"b",2,"c",3] >>> = iter(mylist) >>> {k: next(it) k in it} {'a': 1, 'c': 3, 'b': 2} using zip , iter : >>> dict(zip(*[iter(mylist)]*2)) #use `itertools.izip` if list huge. {'a': 1, 'c': 3, '

active directory - updating lastLogonTimestamp using Java code -

did set value of lastlogontimestamp in active directory using java program? i found following convert lastlogontimestamp java.util.date format: https://forums.oracle.com/message/10133757#10133757 using same logic, trying modify attribute's value: long llastlogonadjust=11644473600000l; long currenttime = system.currenttimemillis(); long currenttimead = currenttime * 10000-llastlogonadjust; system.out.println(currenttimead); modificationitem[] mods = new modificationitem[1]; mods[0]= new modificationitem(dircontext.replace_attribute, new basicattribute("lastlogontimestamp", long.tostring(currenttimead))); ldapcontext.modifyattributes(dn, mods); however getting following error: javax.naming.operationnotsupportedexception: [ldap: error code 53 - 0000209a: svcerr: dsid-031a0dd5, problem 5003 (will_not_perform), data 0 any idea, how solve it? looking @ documentation lastlogontimestamp , system can update value. cannot s

jquery - Distinct values in dropdown from JSON object -

i trying exttract distinct values drop down list using following code not bringing in unique strings, can please? function build_refinesearch_cancer_combo() { $('#combolist-cancer-type').empty(); var list = []; var htmlresults = '<option value="-1" selected>select cancer type_</option>'; (var = 0; < user.length; i++) { cancerid = user[i].fkcancertypeid; cancer = user[i].cancer; if (cancer != list) { htmlresults += '<option value="' + cancerid + '">' + cancer + '</option>'; list = cancer; } } $('#combolist-cancer-type').append(htmlresults); } $('#combolist-cancer-type').html(function() { var ret = '<option value="-1" selected>select cancer type_</option>', u = user.slice(), arr = []; (function get() { if (u.length) { va

delphi - Service does not start -

i created windows service delphi , used 2 method install, start , stop. method 1 if install service using commandline c:\myservice\serviceapp.exe /install it installed , can start , stop in service console. method 2 but if install same service different name using sc e.g. c:\windows\system32>sc create myservice binpath= c:\myservice\serviceapp.exe i see installed can not start service using service console sc start myservice when query using sc , result follows c:\windows\system32>sc query myservice service_name: myservice type : 10 win32_own_process state : 2 start_pending (not_stoppable, not_pausable, ignores_shutdown) win32_exit_code : 0 (0x0) service_exit_code : 0 (0x0) checkpoint : 0x0 wait_hint : 0x7d0 up till using /install want install same service multiple times different names, got idea of using post. ( how i

Why Hibernate Eager Fetch Does Not Work? -

i trying write simple testing program simulate 2 objects in project , run trouble. have 2 simple object, parent , child 1 many relationship. following 2 objects: import java.util.list; import javax.persistence.cascadetype; import javax.persistence.column; import javax.persistence.entity; import javax.persistence.fetchtype; import javax.persistence.id; import javax.persistence.joincolumn; import javax.persistence.onetomany; import javax.persistence.table; import org.hibernate.session; import org.hibernate.transaction; import com.fhp.ems.common.data.dao.hibernateinitializer; @entity @table(name = "parent") public class parent { private integer id; private string data; private list<child> child; public parent() {} @id @column(name = "id", nullable = false) public integer getid() { return this.id; } public void setid(integer id) { this.id = id; } @column(name = "data", length = 128) public string getdata()

mysql - Eloquent ORM using WHERE in both inner join tables -

i'm trying results 2 tables need filter kind of information need both tables. have far this: // list of students in class; $students = db::table('students') ->join('userinfo', 'students.studentuserid', '=', 'userinfo.userinfouserid') ->select('userinfo.userinfoinfo', 'userinfo.userinfouserid') ->where('students.studentclassid', '=', $cid) ->get(); this works fine want further filter outcome. way have userinfo columns this: id | userinfo.userid | userinfo.userinfotype | userinfo.userinfoinfo 2 | 3 | firstname | johnny 3 | 3 | lastname | baker 4 | 3 | phone | 5551234543 i want firstname information. this: ->where('userinfo.userinfotype', '=', 'firstname') how can run query in eloquent? i'm using laravel. you can using querybuilder: $students

jquery - sticky footer slide up to reveal -

what trying create sticky footer half hidden slide reveal hidden part on end of page scroll. sticky footer itself, can easy enough. but, want appear if end of page catches footer , pulls hidden part. hope explained correctly. seems should able figure out, im not. need use jquery not sure functions use. searched everywhere tut or no avail. if might point me in right direction awesome! thanks in advance :) i'm not going write code, try , send in right direction... you don't technically need jquery this, may make easier. need make footer catch , pull bottom hook in document scroll event: document.addeventlistener('scroll', function(){ // if bottom of page reached, slide footer }) you can know when , how move footer comparing window scroll, window height , document height.

plsql - How can I easily use a collection in an Oracle where clause in a package? -

it understanding cannot use collection in clause unless defined @ db level. have distinct dislike random type definitions laying schema. it's religious thing don't try dissuade me. types contained within package cool, because found , related work @ hand. having said have package defines structure (currently table type collection) looks like; type word_list_row record( word varchar(255)); type word_list table of word_list_row; there routine in package instantiates , populates instance of this. useful able use instantiated object, or analog therof in clause. so being clever (or thought) programmer, said why don't create pipelined function make table collection did, , looks like; function word_list_table(in_word_list word_list) return word_list pipelined out_word_list word_list := word_list(); begin in 1 .. in_word_list.count loop pipe row(in_word_list(i)); end loop; return; end word_list_table; then in routine call fun

opencv - Embeddable / No installation web servers or Free live video steam services -

first ask question in short , sweet way. i working on c++/cli program records live video (i use opencv). need facilitate broadcast support other people can watch using web browser. know videos sequence of images need web page new "frame" grabbed web cam , display in web page in speed of 5 times in every 1 second (5fps). this, in order allow others access web page, need web server (running in localhost ok because connected machines can access it). i not upto web technologies have used apache tomcat , microsoft default server.but in both, have setup server, upload files , more. there programs this , this not require such servers need install , setup still job. think using embedded web servers. so, there servers matches requirements? please note program in c++/cli , need distribute server well, above 2 programs do. please help. ,,.......edit.......... please note mentioned c++ / cli give clear understanding system , not because seeking server cgi script suppo

mysql - PHP/PDO function return value from database varriabele parameters -

i trying write basic function value table. <?php function getvalue($value, $from, $id){ //returns value of table require('includes/connect.php'); $db = new pdo('mysql:host=localhost;dbname='.$database, $username, $password); $db->setattribute(pdo::attr_errmode, pdo::errmode_exception); $sql = "select :value value :from id = :id limit 1"; $stmt = $db->prepare($sql); $stmt->bindparam(':value', $value, pdo::param_str); $stmt->bindparam(':from', $from, pdo::param_str); $stmt->bindparam(':id', $id, pdo::param_int); $stmt->execute(); $data = $stmt->fetch(); $return = $data['value']; return $return; }//function ?> it gives fatal error: uncaught exception 'pdoexception' message 'sqlstate[42000]: syntax error or access violation

javascript - Using jqtransform plugin on all but one form -

we're using jquery jqtransform plugin style our site's forms. there's 1 form though don't want change. modified script runs jqtransform on forms following: $('form:not(.classofformwedon'twanttochange)').jqtransform(); it still has same effect running on forms though. wrong way :not selector being used? thanks this should work. $('form').not('.classofformwedontwanttochange').jqtransform(); fiddle illustration of type of syntax.

apache - Wampserver : localhost 403 forbidden after adding allow from all -

i trying make outside access localhost. edited httpd.conf file replacing allow localhost allow 127.0.0.1 ::1 allow 127.0.0.1 by allow nothing happenned. however, when tried recover old configuration, nothing works, can't access localhost or 127.0.0.1. '403 forbidden' my httpd.config: documentroot "c:/" <directory "c:/wamp/www"> # # possible values options directive "none", "all", # or combination of: # indexes includes followsymlinks symlinksifownermatch execcgi multiviews # # note "multiviews" must named *explicitly* --- "options all" # doesn't give you. # # options directive both complicated , important. please see # http://httpd.apache.org/docs/2.4/mod/core.html#options # more information. # options indexes followsymlinks # # allowoverride controls directives may placed in .htaccess files. # can "all", "n

android - Adding positive / negative Button to DialogFragment's Dialog -

hi i've written dialogfragment. i've realized want have positive , negative button alertdialog. how can achieve such thing while maintaining code i've written? public class doubleplayerchooser extends dialogfragment { @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setstyle(dialogfragment.style_normal,0); } @override public dialog oncreatedialog(bundle savedinstancestate) { return new alertdialog.builder(getactivity()) .settitle("title") .setpositivebutton("ok", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int whichbutton) { // something... } } ) .setnegativebutton("cancel", new dialoginterface.onclicklistener() { public void onclick(dialoginterface d

c# - How to dispatch a lambda expression to a background (non-UI) thread? -

i looking perform action: deployment.current.dispatcher.begininvoke(() => { ... // ui specific stuff }); but instead of sending lambda expression ui thread, want send background worker. the situation such, have messagebox response need have know whether or not additional processing (in case copy file). how can 1 accomplish this? open refactor solution of sorts not include lambda expression dispatch. thanks reading messagebox runs on ui thread, when returns modal display, you're on ui thread. dispatching ui dispatcher @ point doesn't make sense. you'd want run lambda on background thread (e.g., threadpool.queueuserworkitem, via task, etc), when finishes use dispatcher return ui thread. need dispatcher ui thread; not sure if different 1 mention in code.

Excel converts hyphened text into a date -

when copy data query results of sql server db , pasted on excel hyphenated text converted date. like 2-12 gets converted 12-feb. how can avoid that? one way in sql server query convert sql server column text , append apostrophe in front of it. when paste excel should pasted text, not date. e.g. select '''' + convert(nvarchar,field_name) table_name you need select column in excel, right click it, select format cells , change format text. can replace apostrophe , column preserved text , not automatically converted date format.

c++ - Operator overloading and iterator confusion -

i use code find point of box ( g ) furthest in direction d typedef vector_t point_t; std::vector<point_t> corners = g.getallcorners(); coordinate_type last_val = 0; std::vector<point_t>::const_iterator = corners.begin(); point_t last_max = *it; { coordinate_type new_val = dot_product( *it, d ); if( new_val > last_val ) { last_val = new_val; last_max = *it; } } while( != corners.end() ); return last_max; i have template operator overload operator != class vector_t in namespace point . namespace point { template < typename lhs_vector3d_impl, typename rhs_vector3d_impl > bool operator!=( const typename lhs_vector3d_impl& lhs, const typename rhs_vector3d_impl& rhs ) { return binary_operator_not_equal<lhs_vector3d_impl, rhs_vector3d_impl>::apply( lhs, rhs ); } }; the overload works fine in cases when use iterators (i.e. it != corners.end() ) breaks dow

javascript - Handle a keyboard that produces only keypress instead of keydown/keyup events -

i have weird situation specialty pc keyboard produces strange codes in javascript when pressing number keys. using site ( http://unixpapa.com/js/testkey.html ), found keyboard produces when pressing number 4: keydown keycode=18 which=18 charcode=0 keydown keycode=101 (e) which=101 (e) charcode=0 keyup keycode=101 (e) which=101 (e) charcode=0 keydown keycode=98 (b) which=98 (b) charcode=0 keyup keycode=98 (b) which=98 (b) charcode=0 keyup keycode=18 which=18 charcode=0 keypress keycode=52 (4) which=52 (4) charcode=52 (4) a regular keyboard produces this: keydown keycode=52 (4) which=52 (4) charcode=0 keypress keycode=52 (4) which=52 (4) charcode=52 (4) keyup keycode=52 (4) which=52 (4) charcode=0 so basically, strange device holds alt key, adds 2 other characters, lets go of alt key, , fires keypress event actual key

distributed caching - How to do HTTP Session Replication between apache karaf containers? -

does know of way http session replication between web apps running in distributed apache karaf osgi containers? in post, http://karaf.922171.n3.nabble.com/pax-web-failover-loadbalancing-td4029552.html , jean-baptiste onofré says it's not available in apache cellar yet. capability available anywhere yet? i've been googling day , haven't found options -- help. steve karaf not have pax-web confirmed jb in above post. waiting him provide us. if in hurry you can use hazelcast (already cellar) session replication. hazelcast supports , provide hazelcastwm same purpose. jetty provide session replication , use jetty servlet-container.you have check possibility it. try on forum putting tomcat instead of jetty.

php - Change storage folder when create zip -

i use code create zip file php zip correctly created, have little trouble when download zip. on browser, zip name appear this .._.._storage_temp_2013-09-03-1378245354.zip i'm mantain only 2013-09-03-1378245354.zip here code use: $files = array($frente, $verso); //$zipname = '../../storage/file.zip'; $zipname = "../../storage/temp/".date('y-m-d')."-".time().".zip"; // zip name $zip = new ziparchive; $zip->open($zipname, ziparchive::create); foreach ($files $file) { $new_filename = substr($file,strrpos($file,'/') + 1); $zip->addfile($file,$new_filename); //$zip->addfromstring(basename($file), file_get_contents($file)); } $zip->close(); header('content-type: application/zip'); header('content-disposition: attachment; filename='.$zipname); header('content-length: ' . filesize($zipname)); ob_clean(); flush(); readfile($zipname) i have solved in way: $new_z

c# - Translating to lambda expression -

how translate select part of linq expression lambda? var query2 = method in typeof(double).getmethods() // integrated method c# reflection orderby method.name group method method.name groups select new { methodname = groups.key, numberofoverloads = groups.count()}; so far have this: var methods = typeof(double).getmethods(); var query3 = methods.orderby(x => x.name).groupby(y => y.name); i tried select compilor errors. var query3 = methods.orderby(x => x.name).groupby(y => y.name) .select<new { methodname = groups.key, numberofoverloads = groups.count()}>(); would appreciate thanks. this exact translation. have no idea why need orderby tho, considering not using elements in select var methods = typeof(double).getmethods() .orderby(x=>x.name) .groupby(x=>x.name) .select(x=> new { methodname = x.key, numberofoverloads = x.count()}); the same result obtained by var methods

Kendo UI ListView -TypeError: a is undefined -

update action doesn't fire on clicking save button on edit template, can please help? error see in firebug typeerror: undefined ...ages.overwritefile,e),"confirm"))return null;if(l)return l;for(t=0,n=s.length;n>... var datasource = new kendo.data.datasource({ transport: { update: { url: appurl('productdescriptionupload/update'), datatype: "json", type: "post" } pagesize: 1, serverpaging: true, schema: { data: "data", total: "total" }, model: { id: "id", fields: { id: { editable: false, nullable: true }, name: "name", language: { type: "string" }, discontinued: { type: "string" } } } }); var listview = $("#listview"

python - how to set custom forloop start point in django template -

there forloop in java can tell start , end: for(int i=10;i<array.length;i++){ } but how can implement int i=10 in django template? how can set starting , ending point on own? there forloop.first , forloop.last , defined inside loop , cannot this?: {{forloop.first=10}} {% athlete in athlete_list %} <li>{{ athlete.name }}</li> {% endfor %} {{forloop.last=20}} i read django doc feature seems not there how using built-in slice filter: {% athlete in athlete_list|slice:"10:20" %} <li>{{ athlete.name }}</li> {% endfor %} if need make numeric loop (just python's range ), need custom template tag, one: http://djangosnippets.org/snippets/1926/ see other range snippets: http://djangosnippets.org/snippets/1357/ http://djangosnippets.org/snippets/2147/ also see: numeric loop in django templates by way, doesn't sound job templates - consider passing range view. and, fyi, there proposal make such ta

PHP string compare: odd result, possible type juggling, no idea why -

i'm aware numeric strings may type juggled in php, can't see why it's happening here or giving result: $a="00010010001101000000101"; $b="00010010001101000000001"; $c = (($a == $b) ? "true" : "false"); $d = (($a === $b) ? "true" : "false"); echo $c . " " . $d . "\n"; // true false but in case $a , $b defined same way, of same length, different contents many chars in. how ($a == $b) evaluating true? it bug. test on http://3v4l.org/cmld0 . version 4.3.1 - 5.0.5 , 5.1.1 - 5.4.3 return true false . versions 5.4.4 - 5.5.3 return false false .

google app engine - How to create AppEngine Key object with assigned namespace with Java API? -

i create appengine key -object assigned given namespace . python api provides corresponding parameter in key.from_path(...) -method, none of methods in java api's keyfactory mention namespaces anywhere. is way use namespacemanager.set(...) before call constructor of key? or work magic entities.createnamespacekey(...) ? maybe using result of parent when create actual key ? you can not use entities.createnamespacekey(...) create namespace-aware key (i.e. switch namespaces). method helper method when using namespace metadata queries . so way switch namespaces via namespacemanager.set(...) .

How to build MongoDB connector for hadoop latest version (1.2.1) -

i'm trying build mongodb connector hadoop 1.2.1 montogdb instruction page ( https://github.com/mongodb/mongo-hadoop ) i'm getting following error. 1 thing mention, hadoop 1.2.1 not included in list of supported version. tried install 1.1 not included in hadoop download page or of mirrors, has ideal if possible build connector hadoop 1.2.1? sbt.resolveexception: unresolved dependency: commons-logging#commons-logging;1.1.1: configuration not found in commons-logging#commons-logging;1.1.1: 'compile'. required commons-configuration#commons-configuration;1.6 compile @ sbt.ivyactions$.sbt$ivyactions$$resolve(ivyactions.scala:214) @ sbt.ivyactions$$anonfun$update$1.apply(ivyactions.scala:122) @ sbt.ivyactions$$anonfun$update$1.apply(ivyactions.scala:121) @ sbt.ivysbt$module$$anonfun$withmodule$1.apply(ivy.scala:114) @ sbt.ivysbt$module$$anonfun$withmodule$1.apply(ivy.scala:114) @ sbt.ivysbt$$anonfun$withivy$1.apply(ivy.scala:102) @ sbt.ivysbt.liftedtree1$1(ivy.scala:49)

android - Async Task OnProgressUpdate CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views -

i using asynctask download database progressdialog shows progress on ui. of users receiving error: calledfromwrongthreadexception: original thread created view hierarchy can touch views. as understand it, should happen if trying update views off of ui thread. here error: com...updateops.dbcreate.onprogressupdate(dbcreate.java:70) @ com...updateops.dbcreate.onprogressupdate(dbcreate.java:1) and here code: public class dbcreate extends asynctask<string, string, string>{ private static context mctx; private static progressdialog mdialog; public static amazonsimpledbclient msdbclient; public static amazons3client ms3client; private static int mappversion; private static boolean mcreate; public dbcreate(context ctx, int versioncode, boolean create) { mctx = ctx.getapplicationcontext(); mappversion = versioncode; mdialog = new progressdialog(ctx); mdialog.setprogressstyle(progressdialog.style_horizontal); mdialog.setmessage("checking server a

c++ - Order of function definition during template instantiation -

i have trouble understanding order of template instantiation. seems compiler not consider function if defined "too late." following steps illustrates main ideas of code below: the framework should provide free function convert<from, to> if can find working overload function generate . the function to<t> shortcut convert<from,to> , should work if convert<from,to> valid. users should able provide overload of generate , able use to , convert . the corresponding code: #include <string> #include <utility> #include <iostream> // if move code down below @ [*] location, works // expected. // ------------- framework code ------------- // can generated can converted string. template <typename from> auto convert(from const& from, std::string& to) -> decltype( generate(std::declval<std::back_insert_iterator<std::string>&>(), from) ) { to.clear(); auto = std::back_inserter(t

symfony - Parameters in behat.yml -

i want make behat.yml - default: extensions: behat\minkextension\extension: base_url: 'my-url' a parameter pulled parameters.yml... possible? made mink_base_url parameter in parameters.yml , added imports: - { resource: parameters.yml } to behat.yml. no matter do, this [symfony\component\dependencyinjection\exception\parameternotfoundexception] service "behat.mink.context.initializer" has dependency on non-existent parameter "mink_base_url" behat configuration in no way related symfony's. it's true behat uses symfony's di container, it's separate instance. if wanted implement it, you'd need create own behat extension support imports section.

android - AndroidPocketSphinx: How does the system know which recognizer is invoked? -

i studying source code of testpocketsphinxandandroidasr.java , first thing not clear me how system knows which recognizer (i.e. google or cmusphinx) invoke. i can see recognition activity started by: intent intent = new intent(recognizerintent.action_recognize_speech); intent.putextra(recognizerintent.extra_language_model, recognizerintent.language_model_free_form); startactivityforresult(intent, voice_recognition_request_code); but far know code isn't specific either gvr (google voice search) or cmusphinx. so how android know which recognizer start? earlier in oncreate(), there reference androidpocketsphinx setting: musepocektsphinxasr = prefs.getboolean(preferenceconstants.preference_use_pocketsphinx_asr, false); but searching on entire project yields next statement uses boolean display different toast: if (musepocektsphinxasr){ toast.maketext(testpocketsphinxandandroidasr.this, "would working offline, using pocketsphinx speech recognizer...&q

java - How should I handle the IOException thrown by the function BufferReader.readline()? -

everytime encounter java exception ,i fell dilemma whether should throw exception directly or catch exception .if catch exception ,should print stack trace or more work in catch block?for example , reading file line line,the function bufferedreader.readline() throws ioexception ,it seems checked (compared unchecked exception) exception because user told deal exception explicitly,right?although have deal , seems can nothing else print stack trace, ,it strange.should catch or throw exception? if catch it,what should in catch block? this which part responsible exception . if, example, you're developing tool package jar, maybe should throw ioexception in method prasadioutils.readfile(string path) , should provide function read file, not handle exception. in contrast, should catch exception when invoking method prasadioutils.readfile(string path) in code. because logic part, , 1 responsible handling exception make own project more robust , fault-tolerant. thi

ios - executing blocks stored in NSMutableArray with a parameter -

i'm trying understand blocks bit more. i have these definitions: @property (nonatomic, retain) nsmutablearray * callbacksonsuccess; @property (nonatomic, copy) void (^callbacksuccesswithuiimage) (uiimage *) ; when image download finishes in completion block , things fine uiimage *coverimage = [uiimage imagewithdata:data]; callbacksuccesswithuiimage(coverimage); now i'd able same callback blocks stored in callbacksonsuccess nsmutablearray don't know how approach this. i'm trying in loop, that's not working because of ambigous id class definition: uiimage *coverimage = [uiimage imagewithdata:data]; (id callbackblock in callbacksonsuccess) {callbackblock(coverimage);} please push me towards right approach. thank you! first of all: consider use typedef blocks, in order ease syntax: typedef void (^myblock)(uiimage*); //declare somewhere then, can iterate through array this, executing each block inside it: uiimage *coverimage = [ui

javascript - Windows 8 HTML5 - Adjusting the layout of a Split App? -

how can adjust location of buttons (group?) on main page liking, or otherwise reformat them? in css files, or somewhere in js files? not believe code example required question. suggestions appreciated, thanks! the default template split app doesn't contain button groups mere divs,in case need alter styles need make changes in items.css page.i believe want style left pane.. try following css in items.css page, .itemspage .itemslist .item { -ms-grid-columns: 1fr; -ms-grid-rows: 1fr 90px; display: -ms-grid; height: 100px;//you can make adjustments height here width: 250px; } .itemspage .itemslist .item .item-image { -ms-grid-row-span: 1; }

algorithm - Which one is more secured md5 or whirlpool (hashes) and Why? -

i new in cryptography section. want raise question here regarding md5 hashes , whirlpool hashes. far have found md5 can broken , hence not safe use. learned little bit whirlpool hashes. now, question "which 1 more secured?" except knowing md5 can broken. one more question, need know applications use both md5 , whirlpool hashes in program. helpful me if can come forward share knowledge. cheers the more bits hash contains, more secure. md5 128-bit string, sha-1 160-bit string , whirlpool 512-bit string. based on alone, whirlpool superior both sha-1 , md5.

java - Exception when downloading huge files using struts framework -

sorry if question similar other present, posting none of solutions offered have worked me. i have struts action of type 'stream' called download, leads downloading file website(running in https). code: inputstream inp; public string execute { inp = //get inputstream; return success; } struts <action name="download" class="abc"> <result name="success" type="stream"> <param name="contenttype">application/octet-stream</param> <param name="inputname">inp</param> <param name="contentdisposition">attachment;filename="abc"</param> <param name="buffersize">1024</param> </result> </action> for downloading large files across browsers, throws exception : java.lang.illegalstateexception: getoutputstream() has been called response @ org.apach

wix - How to execute .exe file in MSI without bootstrapper? -

i have .exe file executed during installation. executed when msi file launched bootstrapper(an .exe file launches main msi file) not executed when launched msi itself. seems problem related privilege, because bootstrapper acquires privilege when launched , if execute msi in cmd.exe has privilege, executes .exe file well. it's real problem comes when enter maintenance mode arp menu in control panel. .exe file executed according feature's action state. executed when enter maintenance mode original msi launched bootstrapper(it has privilege), not executed when enter maintenance mode arp menu in control panel. i want executed equally when enter manintenance mode arp menu in control panel. below part of code. <customaction id="ca1" binarykey="file.exe" execommand="" execute="deferred" return="asyncnowait" /> ... <custom action="ca1" before="installfinalize"><![cdata[&feat1=3]]><

How would a "hot" hash key affect throughout in practice on Amazon DynamoDB? -

first, here's support document dyanamodb giving guidance on how avoid "hot" hash key. conceptually, hot hash key simple , (typically) straightforward avoid - documents give examples of how so. not asking hot hash key is. what want know how throughout performance degrade given level of provisioned read/write units @ limit, is, when read/write activity focused on 1 (or few) partition(s). distributed hash key activity (uniform across partitions), dynamodb gives single millisecond response times. so, response times in worst case scenario? here's post on aws asking related question gives specific use-case knowledge of answer matters. dynamodb guarantee single millisecond response times, 'hot' hash key, but see lot throttled requests. , when seem have plenty of unspent provisioned throuput. because provisioned throuput gets divided number of partitions. don't know how many partitions there @ given time, varies how of provisioned throuput ca

how to implement PHP session manually -

i new php. want implement php session manually. on php pageload, check if cookie set. if yes, display required information, , if not, ask user enter details , display information. not allowed use php sessions. can use cookies. information needed displayed users (browsers) in session (so have save static global array). appreciated. thanks. try this setcookie('cookie_name', 'cookie_value', time()); echo $_cookie['cookie_name']; now check cookie if exists. if(isset($_cookie['cookie_name'])) { echo "your cookie set"; } else { echo "return error or thing want"; } this give browser(s) information. echo $_server['http_user_agent'];

php - How to force string variable to evaluate to hex char in a string? -

i trying represent character hex value inside string. works if hex explicit not work when hex variable used: $hex = '5a'; echo "hex explicit: \x5a, hex evaluated: \x$hex"; the output is: hex explicit: z, hex evaluated: \x5a the question - how modify \x$hex z instead of \x5a ? hope helps. integer literals <?php $a = 1234; // decimal number $a = -123; // negative number $a = 0123; // octal number (equivalent 83 decimal) $a = 0x1a; // hexadecimal number (equivalent 26 decimal) ?> this answer $hex = chr(0x5a); echo "hex explicit: \x5a, hex evaluated:".$hex; or $hex = chr(0x5a); echo "hex explicit: \x5a, hex evaluated: $hex"; try link http://www.w3schools.com/php/func_string_chr.asp

http - Azure blob file download link -

Image
i have blob i've stored in azure blob storage (using development emulator). its saved , can see in server explorer in blob store (file.mp3 if matters). i'm linking in site when click link i'm getting 206 (partial content) (and no file). if right click save happy , file downloads. i'm sure pretty noobish i'm missing cant see it. that because, browser not download media file whole, browser requests range blob storage correctly responds 1 byte , headers. called http streaming, parts of file downloaded in ranges , played progressively. in form of streaming can skip parts of file , go end play end part of media without downloading whole file. imagine watching big movie, , movie of 100 mb. , want watch last 1 minute of it, can move player's tracker forward on timeline , browser download last few megabytes per timeline structure in media file. mp4 & similar media containers support file byte position tracking. browsers & media players t

javascript - regular expression not working in IE8 -

i'm going test inserted character if rtl or ltr , used code: function checkrtl(s) { var ltrchars = 'a-za-z\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u02b8\u0300-\u0590\u0800- \u1fff' + '\u2c00-\ufb1c\ufdfe-\ufe6f\ufefd-\uffff', rtlchars = '\u0591-\u07ff\ufb1d-\ufdfd\ufe70-\ufefc', rtldircheck = new regexp('^[^' + ltrchars + ']*[' + rtlchars + ']'); return rtldircheck.test(s); } ; function checkspecialchars(s) { var schars = '0-9`~!@#$%^&*()_+\\-=\\|\\[\\]{};\'":,.<>/', checkchar = new regexp('^[' + schars + ']+'); return checkchar.test(s); } var input = $('#password').on('keypress', keypress); function keypress(e) { settimeout(function () { var isrtl = checkrtl(string.fromcharcode(e.charcode)); var isspecial = checkspecialchars(string.fromcharcode(e.charcode)); var dir = isrtl ? 'rtl'