Posts

Showing posts from August, 2014

android HttpURLConnection no result -

i trying webpage android app following code. try { //processresponse(searchrequest(edittext.gettext().tostring())); stringbuilder response = new stringbuilder(); url url = new url("http://www.google.com"); log.v("gsearch", "url :" + url.tostring()); httpurlconnection httpurlconnection = (httpurlconnection) url.openconnection(); if (httpurlconnection.getresponsecode() == httpurlconnection.http_ok) { log.v("gsearch", "http ok"); } log.v("gsearch", "loaded"); } catch (exception e) { log.v("web content error", "e:"+e.getmessage()); } however, got following in logcat. v/gsearch﹕ url :http://www.google.com v/web content error﹕ e:null i have permission in manifest. <uses-permission android:name="android.permission.internet" /> please give me hint. you can idea code try...

android - Reset all Views in fragment -

so in fragmenta.java, class consists of different edittext s , checkbox es users press , input. my question is, have reset button, how can reset entire fragment view? (e.g. edittext set empty string, or value 0, when created). p.s. of course can set edittext/checkboxes 1 one programically, there quite lot of them , other views, know if there way reset of them. let's break down steps: 1. getting references how done depends on have. if fields created in-code, it's easy: store references in list<commonbasetype> . if loaded xml layout, there multiple options. if want views of type(s) reset, can iterate through view hierarchy getting reference holding viewgroup (the layout) , iterate on children getchildcount() , getchildat(int) . then, check type of child. if it's viewgroup , check it's children. if it's edittext or checkbox , add them list. if need more control , don't want all views reset, can tag ones want something. can tag v...

github - Latex \newcommand in kramdown -

i understand cramdown not support \newcommand type macros. there workaround not involve pandoc, used jekyll in github blog? this input markdown: --- layout: post --- \newcommand{\a}{\alpha} test $$\a$$. the output should jekyll blog, mathematical notation, this . there seems 2 questions here — first, can 1 define commands in kramdown similar latex's \newcommand syntax, , second, can kramdown support mathematics. regarding first issue, kramdown doesn't support syntax or i'm aware of, and isn't going in future , can't define non-math kramdown commands. you'd need use language that's focused on completeness rather ease , simplicity, latex, features that. for math, though, mathjax (the parser kramdown uses) parse \newcommand : go ahead , use in first code block. example, $$\newcommand{\a}{\alpha} \a{}/2 $$ yields expected fraction expected computer modern italic greek alpha, , you'll able use \a in every subsequent code block....

regex - PHP - how to explode a string using a comma, except situtation when this comma is inside apostrophes? -

i have following text: $string=' blah<br> @include (\'file_to_load\') <br> @include (\'file_to_load\',\'param1\',\'param2\',\'param3\') '; i'd catch (and replace using preg_replace_callback) occurences of "@include" parameters (e.g. @include ('file_to_load','param1','param2','param3') ) so this: $string=' blah<br> @include (\'file_to_load\') <br> @include (\'file_to_load\',\'param1\',\'param2\') '; $params=[]; $result = preg_replace_callback( '~@include \((,?.*?)\)~',//i catch @include, parenthesis , between them function ($matches) { echo '---iteration---'; $params=explode(',',$matches[1]);//exploding comma echo '<pre>'; var_dump($params); echo '</pre>'; re...

html - PHP mail function doesn't complete sending of e-mail -

<?php $name = $_post['name']; $email = $_post['email']; $message = $_post['message']; $from = 'from: yoursite.com'; $to = 'contact@yoursite.com'; $subject = 'customer inquiry'; $body = "from: $name\n e-mail: $email\n message:\n $message"; if ($_post['submit']) { if (mail ($to, $subject, $body, $from)) { echo '<p>your message has been sent!</p>'; } else { echo '<p>something went wrong, go , try again!</p>'; } } ?> i've tried creating simple mail form. form on index.html page, submits separate "thank submission" page, thankyou.php , above php code embedded. code submits perfectly, never sends email. please help. there variety of reasons script appears not sending emails. it's difficult diagnose these things unless there obvious syntax error. without 1 need...

php - How to speed up slow MySQL UPDATE queries with InnoDB tables -

Image
i have simple mysql update query on innodb table. update `players_teams` set t_last_active=now() t_player_id=11225 , t_team_id=6912 , t_season_id=2002 limit 1 my table structured so: create table `players_teams` ( `id` int(11) unsigned not null auto_increment, `t_player_id` int(11) default null, `t_team_id` int(11) default null, `t_league_id` int(11) default null, `t_season_id` int(11) default null, `t_div` varchar(64) default null, `t_player_number` varchar(3) default null, `t_player_jersey_size` enum('unknown','xs','s','m','l','xl','xxl','xxxl') default 'unknown', `t_player_registration_number` varchar(64) default null, `t_player_class` enum('roster','spare','coach','injured','holiday','suspended','scorekeeper') default 'roster', `t_access_level` enum('player','manager','assistant') default ...

ajax - How to send file upload path with normal data to controller in jquery -

i want send file upload image path normal data controller in jquery ajax call . when send normal data works properly. when send image path works when send both in 1 time doesn't work. creates issue sometime ajax call doesn't work or sometime value shows null in controller. i found many things on net not find exact solution. found solutions like.... missing " enctype" & way getting file upload path & many others. this js file coding. working , getting complete image path in controller. var data = new formdata(); var files = $("#btnuploadfile").get(0).files; if (files.length > 0) { data.append("helpsectionimages", files[0]); } $.ajax ({ type: 'post', url: '/login/submituserprofile', processdata: false, contenttype: false, data: data, success: function (result) { }, error: function (result) { } }); controller [httppost] public void submituserprofile() { request.file...

push notification - How to register for GCM in iOS -

i can't seem gcm push notifications working. problem don't know how registration id gcm. can token apn fine. i'm not quite sure next. tried following tutorial not working me. i'm beginner please explicit. what i'm asking is, after obtaining token apn, do? thanks in advance. https://developers.google.com/cloud-messaging/ios/client the registration token given registration handler didregisterforremotenotificationswithdevicetoken all code below taken gcm sample google. first, declare handler in application:didfinishlaunchingwithoptions: _registrationhandler = ^(nsstring *registrationtoken, nserror *error){ if (registrationtoken != nil) { weakself.registrationtoken = registrationtoken; nslog(@"registration token: %@", registrationtoken); nsdictionary *userinfo = @{@"registrationtoken":registrationtoken}; [[nsnotificationcenter defaultcenter] postnotificationname:weakself.registrationkey ...

javascript - Changing element background color with jQuery .append -

so javascript code creating list of table items, want able change color of row according selections made, each time new item added. here's code if ( valid ) { $( "#tasks2 tbody" ).append( "<div id='tasklist'><ul class='taskscreen2'><tr>" + "<td><h1>" + type.val() + "</h1></td>"+"<td class='title'><h3>"+ title.val() + " </td>" +"<td>"+ wordcount.val() + "</h3></td>" +"<td><p>"+ description.val() + "</p></td>" + "<td>"+ deadline.val() + "</td>"+ "</tr></ul></div>" + "<script> if ($('#type').val()=='dissertation')" + "{document.getelementbyid('tasklist').style.backgroundcolor = 'red';} ...

sql - How can we merge the results of two queries have group by and two conditions -

Image
i have these 2 tables: (games) and (rounds) table: i game id's, there round count, , count of how many rounds player1 wins. created 2 sql queries this: but want results in 1 table. how can combine results this: you can use conditional aggregation : select game_id, count(*) roundscount, count(case when winner = player1_id 1 end) p1winscount games g inner join rounds r on g.id = r.game_id group game_id demo here

java - Netbeans not using available memory during compilation -

using netbeans on linux, compiling program ~6000 lines long, , appear have reached threshold of sort. compilation time has jumped 1 minute on 25. it's memory issue, ide taking 300meg , not 1 byte more, despite needing to. i've added -j-xmx600m netbeans.conf file, , modified xms command 132m , although log file reports: compiler: hotspot client compiler heap memory usage: initial 132.0mb maximum 580.0mb non heap memory usage: initial 160.0kb maximum -1b garbage collector: copy (collections=23 total time spent=1s) garbage collector: marksweepcompact (collections=3 total time spent=0s) it's not working. is there configuration option in ide need tinkering with? thanks incredibly helpful person on netbeans user mailing list, solved me. it wasn't memory after all; bug in version 8u5 of jdk. switched down couple of versions, , works now.

c++ - How to Code max(abs) in MATLAB -

i have following code in matlab trying rewrite in mex file using c (or c++): [a,b] = max(abs(c)); where c vector, maximum absolute value of elements in vector c, , b index of a. please can me solution this? tried use "abs" function returned positive integers (but want them remain double decimal values included). many in advance. man abs tells why got result: abs -- integer absolute value function you want fabs here: "floating-point absolute value function". note need include math.h ( abs in stdlib.h ).

javascript - socke.io could not connect to flashsocket? -

i upgraded socket.io 1.3.3, , force socket.io connect flash socket. socketobj = io('http://localhost:9090', {'transports' : ['flashsocket'],'reconnection delay': 20}); i'm getting following messages on console. socket.io.js:199 connect attempt timeout after 20000 socket.io.js:324 attempting reconnect socket.io.js:199 connect attempt timeout after 20000 socket.io.js:324 attempting reconnect socket.io.js:199 connect attempt timeout after 20000 socket.io.js:324 attempting reconnect socket.io.js:199 connect attempt timeout after 20000 socket.io.js:324 attempting reconnect socket.io.js:199 connect attempt timeout after 20000 socket.io.js:324 attempting reconnect i'm using chrome version 43.0.2357.125 . please tell me either it's browser creating issue or it's socket.io bug? or it's me mis-configuring something. try connect without reconnection delay or transport.just host

cq5 - JCR session created using ResourceResolver returns null -

i trying implement example https://helpx.adobe.com/experience-manager/using/querying-experience-manager-data-using1.html but in following code resourceresolver resourceresolver = resolverfactory.getadministrativeresourceresolver(null); session = resourceresolver.adaptto(session.class); resourceresolver.adaptto returns null everytime any appreciated.thanks in advance. please check whether resolverfactory returning object. if not, session null. if have not made use of @reference annotation resolverfactory reference, please make use of , see if returns resolverfactory,reference follows: @reference private resourceresolverfactory resolverfactory; if using httpslingservlet , can session using sling request shown below. slinghttpservletrequest.getresourceresolver() method reference can follow below api. https://sling.apache.org/apidocs/sling5/org/apache/sling/api/resource/resourceresolver.html this might solution. if doesn't work, can please share entir...

echo php code by php; is that possible -

i want echo out php code educational purposes. possible? @ same time need code php code executed. adding html special-chars this: $this->art = file_get_contents("$this->mainpage/$this->dir/$this->article"); it becomes: $this->art = htmlspecialchars( file_get_contents("$this->mainpage/$this->dir/$this->artikel")); but still not output code php interpreter seems hold of code , directly interprets it. htmlspecialchars () has got effect on html code, see article in brackets. i tried using .html files instead of .php files. php interprets if rename .jpeg . i'm @ wit's end. grateful answer. thanking in advance. i dont understand, why 1 consider doing way, pretty easy. file_get_content not run code, while include will. define('ds', directory_separator); // logic starts here public function main() { echo '<hr><pre>' . $this->educlude($this->mainpage . ds. $this->dir ....

Android Java: bitmap resize define height and width auto -

i setimagebitmap url imageview. want define height, , want app set width automatically, proportionally. this code: url imageurl = new url("url"); httpurlconnection connection = (httpurlconnection) imageurl.openconnection(); inputstream inputstream = connection.getinputstream(); bitmap = bitmapfactory.decodestream(inputstream); image_projet.setimagebitmap(bitmap); float aspect = bitmap.getwidth() / (float) bitmap.getheight() int newwidth = newheight * aspect; you can calculate new width.

javascript - Creating Arrays Dynamically with a for loop -

i making application needs read 10 song names , 5 ratings per song. thing having 1 array each song store name , 5 different ratings ideal don't know how dynamically create arrays loop. ideas? here sample: for (var song = 1; song < 11; song++) { prompt("give song title, no:" + " " + song); (var = 1; < 8; i++) { prompt("give song no:" + " " + song + " " + ", rating:" + i); } } i suggest have array of objects, each object contains title , array of ratings, giving structure looks this: [ { title: "first song", ratings: [ 5, 3, 4, 1, 4 ] }, { title: "second song", ratings: [ 2, 3, 2, 1, 1 ] } ] create array first, create object each song empty array ratings. can put ratings in array: var songs = []; (var song = 0; song < 10; song++) { var title = prompt("give song title, no: " + song); songs[song] = { title: titl...

performance - When, if ever, is loop unrolling still useful? -

i've been trying optimize extremely performance-critical code (a quick sort algorithm that's being called millions , millions of times inside monte carlo simulation) loop unrolling. here's inner loop i'm trying speed up: // search elements swap. while(myarray[++index1] < pivot) {} while(pivot < myarray[--index2]) {} i tried unrolling like: while(true) { if(myarray[++index1] < pivot) break; if(myarray[++index1] < pivot) break; // more unrolling } while(true) { if(pivot < myarray[--index2]) break; if(pivot < myarray[--index2]) break; // more unrolling } this made absolutely no difference changed more readable form. i've had similar experiences other times i've tried loop unrolling. given quality of branch predictors on modern hardware, when, if ever, loop unrolling still useful optimization? loop unrolling makes sense if can break dependency chains. gives out of order or super-scalar cpu possibili...

javascript - Redactor - Uncaught TypeError: Cannot read property 'insert' of undefined -

i'm trying use redactor in project. want add text editor upon button click. the api says can this: function inserthtml() { var html = '<h3>inserted</h3>'; $('#redactor').redactor('insert.html', html); } well, code looks this: <button onclick="inserthtml();">insert</button> <script type="text/javascript"> function inserthtml() { var html = '<h3>inserted</h3>'; $('.redactor-box').redactor('insert.html', html); } </script> redactor editor: <div class="redactor-box"> <ul class="redactor-toolbar" id="redactor-toolbar-0" style= "position: relative; width: auto; top: 0px; left: 0px; visibility: visible;"> <li> <a class="re-icon re-bold" href="#" rel="bold" tabindex="-1"></a> </li> <li...

opengl es - How to display a textured quad without the texture loaded yet(Android,opengles 2.0) -

currently in app using opengl es, have display bunch of quads different textures. want asynchronously load textures quads displaying "blank" until texture loaded , start displaying texture texture finishes loading.... desired way achieve this? you have several options here, desirable depends on situation. possibilities: write shader, doesn't sample texture, , use until texture streamed in , ready. create 'blank' texture, , bind appropriate slot until create real texture. then, switch bindings. same #2, except can update blank texture instead, , switching bindings not necessary.

node.js - No express view engine -

in express, set view engine this: app.set('view engine', 'jade'); in application, not need view engine. output json, without templates. have uninstalled jade. which value set view engine if not want use one? as long don't use res.view() , stick res.json() shouldn't have issue.

c - fprintf outputting ')' in txt file -

i have been trying create c program print current content of .txt file, allow user enter content wish there instead, , print content on previous txt file. resulting .txt file has ')' printed, replacing characters is printed. #include <stdio.h> #include <stdlib.h> int main(void) { file *filedisplay = fopen("password1.txt", "r" ); char c; printf("current password is: "); do{ c = fgetc(filedisplay); printf("%c", c); } while (c != eof); fclose(filedisplay); char np[]=""; printf("\nplease enter new password: \n"); scanf(" %s", np); file *file = fopen("password1.txt", "w" ); fprintf(file," %s", np); fclose(file); return 0; } for example, if user inputs password as char np , output fprintf is p')'uord the array np has room 1 character (the terminating '\0...

java - Updating information like TextViews and Buttons from the main Activity class -

i hope find well. new android , trying follow tutorials on androidhive on developing android applications. cam across following tutorial on developing drawers. http://www.androidhive.info/2013/11/android-sliding-menu-using-navigation-drawer/ . wondering if have button inside 1 of layout files fragement_home.xml how go updating main activity class. <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <textview android:id="@+id/txtlabel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerinparent="true" android:textsize="16dp" android:text="home view"/> <imageview a...

c - Shifting array elements returns unexpected value -

i programming stm32 arm based board , following problem: i moving elements inside array unexpected values not part of array. here code: int temp=*manual_items[selec].byte_control[2]; *manual_items[selec].byte_control[2]=*manual_items[selec].byte_control[1]; *manual_items[selec].byte_control[1]=*manual_items[selec].byte_control[0]; *manual_items[selec].byte_control[0]=temp; the values inside array (0,0,1) example, expect (0,1,0) but, instead (224,1,0). makes me suspect kind of garbage being stored in temp, have tried initializing 0 when declared, getting same result. also, using same approach in different part of code works: int temp=*manual_items[selec].byte_control[3]; *manual_items[selec].byte_control[3]=*manual_items[selec].byte_control[2]; *manual_items[selec].byte_control[2]=*manual_items[selec].byte_control[1]; *manual_items[selec].byte_control[1]=*manual_items[selec].byte_control[0]; *manual_items[selec].byte_control[0]=temp; this shifts values perfectly, can...

image - Imageview changes location on runtime - Swift -

Image
hello, my imageview have set in custom table view cell moves set image different place on run time. the thing confuses me if manually set image in attributes inspector image in place supposed be. when setting image programatically problem arise. below code using cell creation function generate tick or cross. // cell information if answersbool[indexpath.row] == false { cell.imageview!.image = uiimage(named: "crossicon.png") } else { cell.imageview!.image = uiimage(named: "tickicon.png") } this happens on run time. this cell looks in storyboard. first of remove constraint imageview after select imageview , click on pin menu add 5 constraint shown in below image: hope you.

SQL count date time -

i have concatenate date , time portion of 2 fields, have managed do, need test if result < getdate() select count(cast(cast(dischargedatenew date) datetime) + cast(dischargetime time))as requiredby [dbo].[main] location = 'home' , scripttypeid = '1' , requiredby < getdate() unfortunately second requiredby comes invalid column name. how can query work? need subquery? yes need subquery: select * (select someexpression requiredby [dbo].[main] location = 'home' , scripttypeid = '1') t requiredby < getdate() but think want this: select sum(case when cast(cast(dischargedatenew date) datetime) + cast(dischargetime time) < getdate() 1 else 0 end) requiredby [dbo].[main] location = 'home' , scripttypeid = '1'

meteor - Why Router.go doesn't works on observe callback -

i have template : template.playdetails.created = function () { /* catch removed documents , redirect client if happens */ games.find({_id: gameid}).observe({ removed: function () { console.log("ooops game deleted !"); alerts("the game deleted owner", "danger"); router.go("playlist"); } }); }; and when delete game log shown on console neither alerts or router.go works. i tried call router.go time out didn't change anythings meteor.settimeout(function(){ router.go('playlist'); }, 10); is there didn't ?

javascript - how to get animation automatically on loading the page -

i want make images effect automatically when page loads. right using code js $(window).ready(function(){ $(pin).click(function(){ $("#pin01").show().animate({left: '650px'}); }) }); and html <p id="pin">click me</p> <img src="mission.gif" id="pin01" style=" display:none;position:absolute;top:300px;left:300px" /> when click button animation occurs. how can make possible animation automatically after page load without button? simply put animate line within ready or load handler depending on exact needs $(document).ready(function(){ $("#pin01").show().animate({left: '650px'}); }); or $(widnow).load(function(){ $("#pin01").show().animate({left: '650px'}); }); the document.ready event occurs when html document loaded , dom ready. window onload event occurs when dom ready frames, images, etc have been loaded.

Unable to override automatic model find method calls since upgrading to Laravel 5.1 -

i have simple trait use include soft-deleted items few things: trait overridetrashedtrait { public static function find($id, $columns = ['*']) { return parent::withtrashed()->find($id, $columns); } } however, since upgrading laravel 5.1, no longer works. soft-deleted items not turn in get() lists, , if try access page i've used route model bindings, notfoundhttpexception . laravel's upgrade documentation states that: if overriding find method in own models , calling parent::find() within custom method, should change call find method on eloquent query builder: so changed trait accordingly: trait overridetrashedtrait { public static function find($id, $columns = ['*']) { return static::query()->withtrashed()->find($id, $columns); } } but appears no matter write in there, doesn't affect results. have tried put overriding find() method directly in model, doesn't appear working e...

web - E-shop creation from scratch -

i want familiar web development, decided create e-shop website, practice. there guidelines on how started? oh there's log way go. first you'll need learn html , css. in opinion http://www.w3schools.com/ it's site started there many other tutorials out there. then javascript next step, trying set events etc. can find @ w3schools or here www.tutorialspoint.com/javascript/ then surely need learn php, manage database , on. can learn in sites put link to. good luck , have fun.

c - How to copy content of a line into string by giving line's coordinates -

i want know if there way copy content of line console window string. example #include <stdio.h> #include <stdlib.h> #include <conio.h> int main() { char a[10];int b; int x1,y1,x2,y2,x3,y3; x1=wherex(); y1=wherey(); printf("enter name : "); scanf("%s",&a); x2=wherex(); y3=wherey(); printf("enter age : "); scanf("%d",&b); x3=wherex(); y3=wherey(); printf("enter gender : "); scanf("%d",&a); char copyline1[80];char copyline2[80];char copyline3[80]; gotoxy(x1,y1); copyline1[]= ??? // copy content of line 1 copyline1[] gotoxy(x2,y2); copyline2[]= ??? // copy content of line 2 copyline2[] gotoxy(x3,y3); copyline3[]= ??? // copy content of line 3 copyline3[] printf(" first line is\n"); puts(copyline1); // print enter name : abc printf(" second line is\n"); puts(copyline2); // print content of line 2 of console window printf(...

html - Scrambled menu when resizing -

when browser page full size, menu centered in middle page (that's correct position) when resizing window, menu isn't visible anymore except scrolling max right of site. looked responsiveness problem, failed solve it. ideas?? html: <div id="menu" class="menu"> <ul class="headlines"> <li id="item1"onclick="checklist(this)"><button onclick="myfunction()">aa</button></li> <li id="item2"><button onclick="myfunction2()">a </button></li> <li id="item3">b </li> <li id="item4">c </li> <li id="item5">d </li> <li id="item6">e </li> <li id="item7">f </li> </ul> </div> css: lu, li{ list-...

android - I have designed how my app would look like,,but I don't know what exactly the feature is called -

if feature in android app, , want use same in mine, how know what's feature called? , how search it!? want include 1 feature of elevate (a brain training android app)... countdown , uses background. want include kind of timer in app.

android - Add sound switch off/on button corona sdk -

i need adding sound off/on button game. in global variable lua file, have following: local sounds = {} sounds["select"] = audio.loadsound("sounds/select.mp3") sounds["score"] = audio.loadsound("sounds/score.mp3") g.playsound = function(name) if sounds[name] ~= nil audio.play(sounds[name]) end end in games.lua file, call function as: utils.playsound("score") i have soundon.png , soundoff.png files both in sprite sheet (not sure if idea), trying implement when click sound button, sounds stops , displays soundoff image, vice versa. thanks i wouldn't use sprite sheet. load both images , toggle "isvisible" field. toggle variable stop sounds. try this. myglobalsoundtoggle = true local image = display.newimage("soundon.png") local image2 = display.newimage("soundoff.png") image2.isvisible = false local function ontap( self, event ) image.isvisible = ~image.isvisibl...

arrays - Match repetitive data from file with second column from second file -

hello have file repetitive data such: england england england japan japan japan japan america america america and second file unique data has 2 columns(separated "=" ), first column being considered key: england=london japan=tokyo america=washington dc australia=sydney ireland=dublin i trying figure out how can output second column of second file using first column matching key. output should be: london london london tokyo tokyo tokyo tokyo washington dc washington dc washington dc i've tried using first file array in bash , using cat on second file piped grep array search feature. output didn't equate multiple instances of array. think there way awk using arrays, haven't been able figure out in last few days. with sed: sed -f <(sed 's|\(.*\)=\(.*\)|s/\1/\2/|' file2) file1 output: london london london tokyo tokyo tokyo tokyo washington dc washington dc washington dc

html - I can't get my JavaScript Function to work in Explorer -

i having trouble getting javascript function work in internet explorer. works in browsers other explorer. the user clicks on button, calls function checks see if password correct. if correct takes user "members page" if incorrect tells user password incorrect <script> function myfunction2() { if (passwordtextbox2.value == "!2008buzzer1") { location.href = '/jnhsdhdm3gdoeffdut68hjhu.aspx' } else { document.getelementbyid("errorlocation").innerhtml = "your password incorrect"; } } </script> <input type="text" name="passwordtextbox2" id="passwordtextbox2"> <input type="button" onclick="myfunction2()" value='submit'> <p style="color: red" id="errorlocation"></p> you should avoid referencing elements name / id directly, it's non-standard feature. instead...

c# - Writing/Reading To/From File Windows 8.1 AppStore App -

i have windows 8.1 app want write , read xml file put in "assets" folder in application package. i call following method page constructor after this.initializecomponent(); line: private async void readxml() { var uri = new system.uri("ms-appdata:///assets/gameinfo.xml"); storagefile file = await windows.storage.storagefile.getfilefromapplicationuriasync(uri); xmldocument reader = new xmldocument(); reader.loadxml(file.tostring()); xmlnodelist nodes = reader.documentelement.childnodes; string attr = nodes[0].attributes[0].innertext; int besttime; if (attr != null && int.tryparse(attr, out besttime)) besttime = besttime; } when navigate page contains code , runs argumentexception thrown on storagefile file... line. here exception detail: system.argumentexception unhandled user code hresult=-2147024809 message=value not fall within expected range. source=ms...

Android Studio ——How can I modify one Class's field before compile by build.gradle -

in android app i'm developing android studio, have class: public class config { public static final string sdk_version = "0.1"; } i want modify value of sdk_version field changing file build.gradle : def sdk_version = "0.1" android { defaultconfig { versionname sdk_version } } how can make value of sdk_version in config.java change automatically when change in build.gradle ? otherwise, might change 1 forget change other. you can example in starter activity in oncreate(), make in not final befor. config.sdk_version = buildconfig.version_name; or why don't use buildconfig.version_name; instead in place constant needed?

Unexpected behavior of binary search algorithm in python -

i new python. while trying make binary search function , facing , unexpected problem. don't understand why happening. tried modify code, result same every time. here code: def bsearch(s,e,first,last,calls): print(first,last,calls) if((first-last)<2): return (s[first]==e or s[last]==e) mid = first + int((last-first)/2) if (s[mid]==e): return true if (s[mid]>e): return bsearch(s,e,first,mid-1,calls+1) else: return bsearch(s,e,mid+1,last,calls+1) def search(s,e): bsearch(s,e,0,len(s)-1,1) this type in shell , output: >>> s=[1,2,3,4,5,6,7,8,9,10,11,12,13,15,16] >>> search(s,5) output: 0 14 1 thats it. doesn't search element in list. the mistake right here: if((first-last)<2): #this less 2 should be: if((last-first)<2):

jquery - Resizing Cycle2 with javascript is making things jittery -

i have cycle2 slideshow want dynamically resize on own when window width above 580px. @ 580px , less, want take height of screen, minus header , pager. here markup: <div class="header-container"> <div class="header"></div> </div> <div class="slideshow-container"> <div class="cycle-slideshow" data-cycle-auto-height="24:13" data-cycle-slides="> .slide-container" data-cycle-timeout=4000 data-cycle-pager=".pager" data-cycle-pager-template="blah blah blah"> <div class="cycle-prev"></div> <div class="cycle-next"></div> <div class="slide-container" style="background-image:url(yada/yada);"></div> <div class="slide-container" style="background-image:url(yada/yada/yada);"></div> </div> </div> <div class=...

ios - How to add custom UIButton in table view cell? -

Image
i have custom uibutton need add dynamic table view cell. none of tutorials i've used has worked me. uibutton appears when cell clicked, vanishes. when click button app crashes , ...viewcontroller addbuttonpressed]: unrecognized selector sent instance . need here? class tableviewcell: uitableviewcell { @iboutlet weak var addfriendbutton: uibutton! } class viewcontroller: uiviewcontroller, uitableviewdelegate, uitableviewdatasource { @ibaction func addbuttonpressed(sender: uibutton!) { println("hey") } func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { var friendscell = tableview.dequeuereusablecellwithidentifier("addfriendscell", forindexpath: indexpath) as! tableviewcell friendscell.addfriendbutton.tag = indexpath.row friendscell.addfriendbutton.addtarget(self, action: "addbuttonpressed", forcontrolevents: .touch...

Java move jlabel in animation every 0.5 second -

i want simple animation set location every 0.5 second doesnt animate set location @ end of loop. int x=1; int y=1; while(x<100){ jlabel1.setlocation(x, y); x=x+10; y=y+10; try{thread.sleep(500);}catch(interruptedexception e){} } i have tried drawing animation thread.sleep() , worked, animated correctly unfortanly not option me need move jlabel around frame wich has figure picture inside it. can pls me problem. i have tried 2 same result jlabel1.setbounds(x, y, jlabel1.width,jlabel1.height); //not working jlabel1.move(x,y); //not working instead of using java timer try swing timer more suitable swing application. please have @ how use swing timers find sample code how fix animation lags in java?

linux - Cannot start mongodb service -

i tried start mongodb service root user , fails on error cannot open file j._8, checked permissions well. working fine before. couldn't open /data/mongodb/mongodb/data/journal/j._8 errno:13 permission denied assertion: 13544:recover error couldn't open /data/mongodb/mongodb/data/journal/j._8 0xaf8c41 0xabedb9 0xabef3c 0x7400a2 0x740305 0x740828 0x740a82 0x72c8ef 0x55ca94 0x55d6cd 0x5641ae 0x565789 0x7f1bd649f76d 0x557c59 /usr/bin/mongod(_zn5mongo15printstacktraceerso+0x21) [0xaf8c41] /usr/bin/mongod(_zn5mongo11msgassertedeipkc+0x99) [0xabedb9] /usr/bin/mongod() [0xabef3c] /usr/bin/mongod(_zn5mongo3dur11recoveryjob11processfileen5boost11filesystem210basic_pathissns3_11path_traitseee+0x292) [0x7400a2] /usr/bin/mongod(_zn5mongo3dur11recoveryjob2goerst6vectorin5boost11filesystem210basic_pathissns4_11path_traitseeesais7_ee+0xc5) [0x740305] /usr/bin/mongod(_zn5mongo3dur8_recoverev+0x1a8) [0x740828] /usr/bin/mongod(_zn5mongo3dur7recoverev+0x22) [0x740a82] /usr/bin/mongod...

Commas at line end in Swift -

Image
in swift xcode autocorrect keeps forcing me add comma @ end of line, don't know why or comma doing. commas @ end of line do? looked , found lots on comma use in phrase separate different values in function example, nothing why comma or used @ end of terminating line of code. code xcode wanted add comma (the comma @ end xcode): var firstrandomnumber = int(arc4random_uniform(uint32(playerarray.count)), is glitch or there i'm missing? thanks basically it's bug in fix-it , compiler's interpretation of mistake. mistake really you've forgotten final right parenthesis: var firstrandomnumber = int(arc4random_uniform(uint32(playerarray.count))) ^ but compiler doesn't quite grasp that, , interprets missing comma: these messages might improved in future version of swift.

sql server - t-SQL what is the maximum number of tables I am able to join? -

this question has answer here: what maximum number of joins allowed in sql server 2008? 4 answers what maximum number of tables able join? or unlimited? are there shortcuts add multiple tables, without having alias , choose each field? this bad form (using * ) can keep adding tables out specifying columns so: select * table1 inner join table2 on table1.id1 = table2.id2; add table changing above to: select * table1 inner join table2 on table1.id1 = table2.id2 inner join table3 on table3.id3=table2.id2; the problem such join getting many columns , moving data around unnecessarily kills performance. don't take out clothes closet when looking shirts (i hope).

Nested Associations in Rails API -

quick question best practices apis. i have user model belongs_to role model. the role model has 2 possible predefined values: 'organizer' , 'judge'. instead of creating new user normal rails way: user: { first_name: 'sample', last_name: 'user', role: { id: 1, label: 'organizer' } } i'd users of api able create users so: user: { first_name: 'sample', last_name: 'user', role: 'organizer' } since have belongs_to: :role attached in user model, can't permit :role attribute in parameters , pass string, or error. is there nice way in rails 4 without adding ton of code? here's create action in userscontroller : def create @user = user.new( create_params ) if @user.save render json: @user, status: :created else render json: @user.errors, status: :unprocessable_entity end end def create_params params.permit( :...

assembly - given hex input should be convert to decimal -

pretty new assembly !! my assembly code takes hex input 0-9 , a-f other inputs result error, every character of input stored in array , every element in array taken print integer value, reason elements address printing. please see code below , give me solution problem. if need full code please let me know. (the idea of below code take each element of hex number , print elements in decimal number) mov ebx, array next_loop: ;this loop convert character mov al, [ebx] cmp al, newline ; here newline 10 defined je end_loop cmp al, 97 jge subblock jl numsub numsub: sub al, 48 mov [ebx], al jmp next subblock: sub al, 97 add al, 10 mov [ebx], al jmp next next: inc ebx loop next_loop ; below code print value stored in...

Not able to create user when executing jmeter script -

my test plan consist of http request , parameters passed using rest.even though test executes scuccessfully , shows me confirmation page order receipt still not creating user in database.can let me doing wrong. this due correlation error. from write , see confirmation page, when replay in jmeter or when record jmeter using browser. also in title speak "create user" while in description speak "order".

C++ my initialized string disappears when I leave the default constructor but my other member variables values don't -

i'm trying test hangman program. problem i'm running in default constructor initialize member variables. wrong , guess's values saved theres no issue there other member variables the_word , sofar don't saved. think though issue header file. think messed in hangman file declarations of member variables the_word , sofar. if can in figuring out issue(giving me solution love) grateful because has been eating brain long time. thanks! in main cpp file have #include <iostream> #include <string> #include <vector> #include "player.h" #include "hangman.h" using namespace std; int main() { hangman game1; while(1) { game1=hangman();//error object of type hangman cannot assigned //because copy assignment implicitly delated } in player.h file have: #ifndef player_h_ #define player_h_ #include <iostream> #include <string> #include <vector> #include <algorithm...

python - Wrong widget order using vbox layout PyQt -

Image
i trying put qlabel widget on top of (ie before) qlineedit widget edit. but keeps appearing after qlineedit widget. code, class centralwidget(qtgui.qwidget): def __init__(self, parent=none): super(centralwidget, self).__init__(parent) # set layouts self.layout = qtgui.qvboxlayout(self) # flags self.randflag = false self.sphereflag = false self.waterflag = false # poly names self.pnames = qtgui.qlabel("import file name", self) # label concerned self.polynameinput = qtgui.qlineedit(self) # line edit concerned # polytype selection self.polytypename = qtgui.qlabel("particle type", self) polytype = qtgui.qcombobox(self) polytype.additem("") polytype.additem("random polyhedra") polytype.additem("spheres") polytype.additem("waterman polyhedra") polytype.acti...