Posts

Showing posts from February, 2013

c - Alignment of byte array in struct -

i wondering standard how following structure aligned , allocated: struct { uint8_t b[16]; }; to extend can expect a of size 16 bytes, aligned on 16 byte boundary in array (and size of a[n] equal 16*n , e.g. no padding) , address of a first element of b ? and narrow scope bit, platforms concerned x86/x64, arm m, r, , a50. edit: clarification - "alignment" mean how compiler align objects in array on stack, e.g. each next element 16 bytes away, naturally not expect malloc aligned on platform default boundary. edit 2: after reading on answer, feel inclined ask, extend can expect platform-specific explicit alignment intrinsics work? the size of struct @ least 16. 16 in normal c implementations, not see c standard requires this, absent extenuating circumstances such special requests user. e.g., if user uses gcc’s extensions specify struct must have alignment of 32 bytes, struct have padded 32 bytes. the struct cannot expected have alignment requireme...

c# - Changes on controller do not affect the view -

i m on mac , m working on dreamweaver. have this: using system; using system.collections.generic; using system.linq; using system.web; using system.web.mvc; namespace mvcmovie.controllers { public class homecontroller : controller { public actionresult index() { viewbag.message = "modify what?!?!?!."; return view(); } } } and view: @{ viewbag.title = "home page"; } @section featured { <h1>@viewbag.title.</h1> <h2>@viewbag.message</h2> } whenever make change on controller's viewbag.message variable, change doesn't affect result. am doing wrong? of course don't compile anything, change value of variable. any ideas? of course don't compile anything that's problem. controller c# code file in project, project should built changes take place (unlike views...

php/javascript prevent page reload/refresh -

in project have php page whant in case of browser reload, or f5 page redirect one. have insert code: <script type="text/javascript"> window.onbeforeunload = function() { window.location.href = "../index.html"; } </script> if instead of window.location.href instruction insert alert("test"); code run, code in case of refresh page cannot redirect index.html. why? you can capture f5 or ctrl + r keypresses , handle events before redirect. although changing default browser behavior may considered evil , more of annoyance website users. here have provided example function handle redirecting user when try refresh page. http://jsfiddle.net/dqeew/ the heart of , handles location change event binding. $(document).bind('keydown', function( event ){ if( event !== undefined ) { if( (event.keycode == 82 && event.ctrlkey ) || (event.keycode == 116) ) { ...

c# - Disable default button click effect -

i have button created programatically: button button = new button(); imagebrush background = new imagebrush(); background.imagesource = new system.windows.media.imaging.bitmapimage(new uri(@"assets/image1.png", urikind.relative)); button.background = background; button.click += button_click; now when click on button need remove default click effect , add own image, when click on button image have added should displayed. edit the above had 2 upvotes works replacing background image, want both images displayed, onclick should add foreground image button. how can acheive ? you need play visual states of button , of style just @ style below <style x:key="style_colorbutton" targettype="button"> <setter property="background" value="transparent"/> <setter property="borderbrush" value="{staticresource phoneforegroundbrush}"/> <setter property="fore...

model view controller - How to use the Repository class in ZF2? -

Image
i trying understand repository class in zend framework in order choose right way create new software application. what need clarify concept of repository. have read can call servicelocator, entitymanager, call repository controller action , execute doctrine methods passing data view: then have read answer in stackoverflow , little bit confused: https://stackoverflow.com/a/14103376/1034359 so right way or better way call entities ? regards use existing module connect doctrine orm library: http://modules.zendframework.com/?query=doctrine+orm

What does 0; means in javascript -

looking @ grunt-strip plugin remove console.logs. realized replaces console.log statements 0; . 0; have effect? it doesn't have effect, no. js evaluates 0 , nothing picks result. idea removing console.* (with simple replace nothing) might break code this: if(condition) console.log(''); functioncall(); would become (with reformatting emphasis...) if(condition) functioncall(); so it's replaced dummy statement. if(condition) 0; // nothing functioncall(); also, code checking if console present return false because 0 falsy. if(console) { // not executed when replaced if(0) // debugging action }

eclipse - Auto generate variable for return value of method -

Image
i find myself in situation , , find annoying, have change method hand like list<mpartsashcontainerelement> list = sps.getchildren() is there way, on point shown in picture, can have first part of above assignment automatically added, such that sps.[ ctrl + space - selection on getchildren()] may directly lead upper expression? update this became part of bachelor thesis on postfix code completion, , feature right underway. if want know more check google plus announcement or postfix template implementation . no. can finish writing sps.getchildren(), cursor in getchildren selector, use ctrl+1 assign result new local. there's no way tell when you're "done" , ready have left-hand side of expression inserted--you calling on result of getchildren(), after all.

javascript - jquery has() not working as expected -

let's have markup: <div class="comment"> <span class="test">some content here</span> <p>lorem ipsum</p> </div> <div class="comment"> <p>lorem ipsum</p> </div> i want check if span.test exists within div.comment , if exists hide div.comment , show div.comment in span.test doesn't exist. i'm stuck here : if($("span.test").length) { $(".element:has(span.test)").hide(); i don't know how continue achieve want. any suggestions on how can make work ? $("div.comment").filter(function () { return $(this).find('span.test').length }).hide(); jsfiddle example

Python Decorator Code Runs Before Original Function Code -

def raw_list(function): @wraps(function) def wrapper(args, producer_data): print producer_data[2] tenant, token, url = producer_data body, status_code = do_request(url, token) return function(args, producer_data) return wrapper @raw_list def member_list(args, producer_data): # in argparse, consumer or producer data can used because # consumer aliased producer. uuid = args['uuid'] producer_data[2] = producer_data[2] + "/" + uuid + "/members" i have several functions take url, mutate it, , make api call url. reason, made wrapper function api call part. so, each function needs mutate url , decorated wrapper function. but issue having mutated url code producer_data[2] = producer_data[2] + "/" + uuid + "/members" seems running after function decorator code runs, , not before. because of this, original url being used instead of mutated url. how can fix logic flow , make api...

javascript - Getting a JSON response with ember -

i trying experimenting ember js. instead of fixtures use api. this code using data: app.itemsroute = ember.route.extend({ model: function() { return $.getjson('http://someurl.json').then(function(data) { return data.items_popular.map(function(item) { return item; }); }); } }); this json file looks like: { "popular":{ "items_popular":[ { "id":"23", "item":"some title", "url":"http://url", "user":"girl" }, { "id":"56", "item":"title of item 2", "url":"http://url", "user":"guy" } ] } } currently keep getting cannot call method 'map' of undefined would appreciate refac...

objective c - Know start and end point of a CGPathAddArc -

Image
i want know start , endpoint of arc generated cgpath method cgpathaddarc . i want draw portion of "ring" , think combining 2 arcs different radius , drawing 2 lines connecting start , end points. cgpathaddarc(anillo, null, centro.x, centro.y, r1, ang1, ang2, yes); cgpathaddarc(anillo, null, centro.x, centro.y, r2, ang1, ang2, yes); how using arctopoint instead void cgpathaddarctopoint ( cgmutablepathref path, const cgaffinetransform *m, cgfloat x1, cgfloat y1, cgfloat x2, cgfloat y2, cgfloat radius ); you specify start , end points sounds want.

css3 - How do I reverse this CSS rotate animation? -

i have css animation i'm trying reverse animation of based on class being added dom node. i've tried multiple things no avail. here code i'm using, see below: example // closed state @-moz-keyframes spin-close { 100% { -moz-transform: rotate(-0deg); } } @-webkit-keyframes spin-close { 100% { -webkit-transform: rotate(-0deg); } } @keyframes spin-close { 100% { transform:rotate(-0deg); } } // open state @-moz-keyframes spin-open { 100% { -moz-transform: rotate(-90deg); } } @-webkit-keyframes spin-open { 100% { -webkit-transform: rotate(-90deg); } } @keyframes spin-open { 100% { transform:rotate(-90deg); } } i don't know whether i'm looking @ wrong? please advise(a demo awesome). don't bother javascript or animations. use css transition this: .image { position: absolute; top: 50%; left: 50%; width: 120px; height: 120px; margin:-60px 0 0 -60px; transition:all 1s ease-out; transfor...

r - Code profiling for Shiny app? -

for r shiny web app, ways run code profiling show parts of shiny code taking processing time? i've got big, fat, complex shiny app, , i'd figure out in labyrinth of code i'm slowing shiny app down most. i've tried out rprof , profr haven't gotten insight them. a few (rough) ideas: profiling app in browser might help. have largish app uses navbarpage , page build speed getting slow. using profiling in chrome (developer tools) identified 'culprit'. fix/improvement in works https://github.com/rstudio/shiny/issues/381#issuecomment-33750794 run profiler code window in app. using shinyace package ( https://github.com/trestletech/shinyace ) can edit (and run) code, including profilers within app (i.e., call reactives etc.). see link below (r > code). note code evaluation deactivated on server source code app on github if want try out (see page) write code in regular r functions called reactive functions. in process of rewriting app can use kn...

mysql - INSERT ... SELECT, InnoDB and locking -

i came accross following behaviour innodb engine under mysql 5.5.34 (on ubuntu 12.04). when performing insert ... select statements, unexpected rows seem locked in table being read from. let me give example. suppose 2 tables table_source , table_dest following structure (particular attention indices): create table table_source ( id int(11) unsigned not null auto_increment, group_id int(11) not null, data text not null, created timestamp not null default current_timestamp, primary key (id), key group_id_created (group_id,created) ) engine=innodb auto_increment=8 default charset=utf8; create table table_dest ( id int(11) unsigned not null auto_increment, group_id int(11) not null, data text not null, created timestamp not null default current_timestamp, primary key (id), key group_id_created (group_id,created) ) engine=innodb auto_increment=8 default charset=utf8; suppose execute following transaction: begin; insert table_dest select * table...

java - Why is Ebean not loading field project from ZenTasks example application? -

i'm following zentask application play-framework tutorial , ended here: http://www.playframework.com/documentation/2.2.x/javaguide3 now think have either found bug or i'm missing in reasoning, anyway, tutorial has following line of code in application.java : task.find.all() the task class has 2 interesting fields: @manytoone public user assignedto; @manytoone public project project; now have following test cases: @test public void successuserloadtest(){ list<task> tasks = task.find.all(); for(task t : tasks){ if(t.assignedto != null) assertnotnull(t.assignedto.name); } } @test public void failingprojectloadtest(){ list<task> tasks = task.find.all(); for(task t : tasks){ if(t.project != null) assertnotnull(t.project.name); } } @test public void successprojectloadtest(){ list<task> tasks = task.find.fetch("project").findlist(); for(task t : tasks){ ...

mysql - Find and remove quotes within table -

so stupid question , i've tried finding within other find/replace posts didn't work/fit problem. i have field in table randomly has " @ beggining of line , wanted know how find , remove these quotes. thanks! i'm guessing, can update table, , set column value same value without strings? string replace update table set column = replace(column_name, '"', '');

javascript events - Dynamics CRM 2011 - opening custom activity from main grid opens "new record" window instead -

i have custom activity entity named "slfn_technischonderhoud" setup not appear in activity menus. have 1 record of in development environment. whenever try open record main.aspx grid, redirects me "new record" form. happens when opening main.aspx grid. when opening embedded subgrid on related entity, opens right record. i have javascript function (open "new record" form in new window). there way function somehow got assigned doubleclick event on main.aspx grid? , there way unbind this? did try create web resource , add custom entity form , use javascript , jquery way: $( document ).ready(function() { // insert code here add event main.aspx grid. // code loaded outside form suppose. }); note : strategy not supported microsoft dynamics crm. suggest use onload form event subgrid. you can unbind removing onclick event or supress them way: /*normal browser:*/ event.stoppropagation(); /*for ie:*/ window.event.cancelbubble = true; ...

Can session.save method in hibernate be used for updating the entity -

in hibernate, if use session.save method instead of session.update updating entity.what behavior like.i asked question colleague of mine , totally short of answers. the documentation suggest save assign id entity (or use current id if present) , try insert in database. therefore, if have constraints of uniqueness on table, end hibernate exception. if not, have twice entry. (i think)

ios - Why I cannot put a nsarray in uitableview cell -

i have error: [__nsarrayi length]: unrecognized selector sent instance 0x8d06040 when try , set nsarray cell using code: cell.textlabel.text=[message objectatindex:indexpath.row]; here code starts nsdictionary: nsdictionary *jsondict = [nsjsonserialization jsonobjectwithdata:loginresponse options:0 error:&error]; nslog(@"responsedataafternsdict: %@", jsondict); //------------------------------------------ keys = [jsondict allkeys]; values = [jsondict objectsforkeys:keys notfoundmarker:[nsnull null]]; message = [values valueforkey:@"fromuser"]; nslog(@"%@", message); this log nslog(@"%@", message); 2014-01-31 12:52:39.899 arialcraft[16694:70b] ( ( ), ( kyleunrau ), ( fixablemass09 ) ) it works nsarray, doing wrong? i think need 1 more subscript: cell.textlabel.text = [[message objectatindex:indexpath.row] firstobject]; cell.textlabel.text looking nsstring object, not nsarray object.

Bootstrap Modal + PHP + AJAX -

so can attest idiot/newb/. looking simple way have ajax transfer id modal. takes modal has php , provides necessary variables shown. ex. table =============================== [button] | data | data | data | =============================== [click button(id)] -> modal pops -> name: data , email: data, username: data i don't know if kinda helps out. able figure out how have modal add information database can't seem figure out how pull data id modal , populate it. thanks can get! edit: (update) index page displays phone inventory. "view" pops modal gives me random information, active id not 1 current order. hope helps. ( i'll take or criticism ) <?php include "../includes/db_connect.php"; $page = "chauffeur"; $pdo = database::connect(); if($_session['loggedin'] == 1){ } elseif($_session['loggedin'] == "") { header("locat...

java - How to turn off code coverage in SonarQube 4? -

how turn off code coverage in sonarqube 4? have jmockit usage in unit tests , jacoco code coverage plugin in sonar. conflict because use different javaagents edit bytecode of classes (as know). want switch off code coverage in sonar. can exclude project in settings of jacoco, doesn't help. i recommend following paragraph "ignore code coverage" in documentation: http://docs.sonarqube.org/display/sonar/narrowing+the+focus

javascript - backbone.paginator - update per page -

i'm using backbone.paginator in project. have dropdown allows users select results per page. have figure out how make work :-) so far if this: this.collection.goto(page, { data: {per_page: newresultsperpage} }); where newresultsperpage number of results user has selected dropdown. correct number of results come server, backbone.paginator doesn't correctly update number of pages. there method can call update / reset backbone.paginator plugin? it looks there howmanyper method missed in documentation. i'll leave question else searching similar issue in future.

node.js - $ne query not working with mongoose but working in mongoshell -

when execute mongoose query financedproject.find({_id:{$ne:fb.financedprojects.financedprojectid}).exec( callback); where fb object this { _id: objectid("54das4da9dsa9d4ad4a9"); name: "some", financedprojects: [ {registry:"147", financedprojectid:objectid("13da4sd4sa48da4dsa")}, {registry:"189", financedprojectid:objectid("5d5asd5a4sd5ada5sd")} ] { the result undefined , when execute in mongoshell results expected because financedprojects array have address element [] like: financedproject.find({ _id: { $ne: fb.financedprojects[0|.financedprojectid } }).exec( callback ); edit: mongoose ist javascript, follows rules of javascript. fb.financedprojects array . if use expression fb.financedprojects.financedprojectid evaluated undefined javascript interpreter, because there no financedprojectid property within array (arrays have 0 , 1 , 2 , 3 ,... prope...

jquery - Accordian Item to be placed on top of window -

i have requirement should have display active accordian on top of window currently i'm using following jquery code. $('span').click(function () { $('.hide').slideup(); $(this).parent().find('.hide').slidedown(); var myscroll = $(this).offset().top; $(window).scrolltop(myscroll); }) please see fiddle can find rest of code. if click span having text clickable, want clickable , expanded text on top of window , other clickables should do. p.s want jquery solution. thanks in advance. i'll take leap of faith , guess close want. fiddle js $('span').click(function(){ $( '.hide' ).hide(); var spanclass = $(this).attr('class'); $( '#' + spanclass ).toggle( 1000 ); });

ios - enterprise iphone application: how user can install it? -

i want create iphone application, must not published in itunes. found exist opportunity develop enterprise application i can't found information, users must install such application. application available user, or user must install or bought else? can me? if belong 1 of these countries, can opt apple's volume purchase plan. countries: australia, canada, france, germany, italy, japan, new zealand, spain, united kingdom, , united states. here the link go enjoy:)

javascript - div height changes as other fluid div height changes -

i have 3 column page 2 fixed divs on either side , fluid (100%) div in middle stretches fill remaining space , viewport enlarged. in central 100% div there image carousel, width of div increases height. question is, there anyway give right hand div css height value changes same height central div? perhaps javascript modifies div's height central div grows vertically? here's css: .container { min-width: 1100px; width: 100%; margin: auto; text-align: left; height: 100%; } .left { float: left; width: 230px; margin-left: 20px; } .middle { top: 10px; margin-left: 270px; margin-right: 270px; } .right { float: right; width: 230px; margin-right: 20px; } #imgcontainer { width: 100%; } the div #imgcontainer found within div .middle. ideally, div .right's height same div #imgcontainer. any appreciated, thanks you're going need refactor markup , css. this post covers how create equal height columns in pure css.

C# Xna interpolate edges on 2d Image like a 1d Graph -

Image
i generated caves random walk . problem output far small , want scale 10-20 times. when every pixel becomes visible need algorithm solve this. thought sinus or cubic interpolation in 1 dimension, goes along edges , interpolates between centers of pixels... basicly height of each pixel y axis of graph. image has 2 "colors" wich black , white. the black dot center of each pixel , red line interpolation archive: here how whole cave looks like: is there way realise that? or impossible? wonder how solve when caves edge goes on x axis, since graph couldnt have 2 dots each x. you can blur or antialias , posterize bw again. going smooth edges, if applied exponential smoothing function.

python - Faster to add all items to an array then write the array to file, or faster to write the item to a file and then add to array one at a time? -

so right have (in python 2.7): if y == ports[0]: array1.append(x) elif y == ports[1]: array2.append(x) elif y == ports[2]: array3.append(x) elif y == ports[3]: array4.append(x) else: array5.append(x) x in array1: target=open('array1.csv', 'a') target.write(x + ",\n") target.close() print "added ip address " + x + " array1.csv\n" x in array2: target=open('array2.csv', 'a') target.write(x + ",\n") target.close() print "added ip address " + x + " array2.csv\n" x in array3: target=open('array3.csv', 'a') target.write(x + ",\n") target.close() print "added ip address " + x + " array3.csv\n" x in array4: target=open('array4.csv', 'a') target.write(x + ",\n") target.close() print "added ip address " + x + " array4.csv\n" x in array5: target=open(...

windows - Running a batch file (with blanks) from powershell script -

i need call batch file powershell script. batch file name decided using parameters ps file user. have code not working expected. poing me mistake? seems fine getting issues actual batch file calling (one of last 4 statements) param( [string]$parts ) $shareddrive = "\\server\share" $cred = get-credential "domain\" $username = $cred.username $password = $cred.getnetworkcredential().password $net = new-object -com wscript.network $net.mapnetworkdrive("", $shareddrive, "true", $username, $password) $batchfilepath = $shareddrive + "\public\upgrade\application folder" if ($parts -eq "p1") { $selectedbatchfile = "`"" + $batchfilepath + "\p1 upgrade file.bat" + "`"" } elseif ($parts -eq "p2") { $selectedbatchfile = "`"" + $batchfilepath + "\p1p2 upgrade file.bat" + "`"" } else { write-host "invalid part specified. choos...

version control - Insight on handling static library revisions (i.e. binaries) with git -

i'm looking insight on how handle git repositories each utilize (large) static library, , have concerns solution thought about. suppose lots of separate projects, under version control, each rely upon large static library under (very) active development. let's repos a , b , c , ... have own development teams, , rely on lib . now, lib project under version control, , being worked on yet team. let's assume teams can't/shouldn't access source lib , accessing headers , static library binaries ok. now, when first thought how organize sort of situation in git repos, submodules came mind. here's quick diagram: "lib" repo: dist/ -> "lib_dist" submodule headers/ sources/ ... "lib_dist" repo: binaries/ (output "lib" repo build process) headers/ (copied "lib" repo in build script) "a" repo: headers/ libs/ lib_dist/ -> "lib_dist" submodule so...

jquery - Using Regex to allow disallow text -

i trying use regex limit characters alphabets , numbers $('#textbox').on("keypress", function (e) { var regex = new regexp("^[a-za-z0-9]+$"); // how proceed? }); however not sure how proceed now? how handle copy paste? the input event should capture keys, pasting , other inputs etc. in newer browsers, , it's matter of replacing isn't aplhanumeric character or number in value. i use /w , allows underscores , few other characters, filters out other characters aren't alphanumeric or numbers $('#textbox').on("input", function (e) { this.value = this.value.replace(/\w/g, ''); }); fiddle

algorithm - Best pratice for using array as the key of memoization in Java -

i doing algorithm problems in java, , time time problem needs memoization optimize speed. , times, key array. uses is hashmap<arraylist<integer>, integer> mem; the main reason here use arraylist<integer> instead of int[] hashcode() of primitive array calculated based on reference, arraylist<integer> value of actual array compared, desired behavior. however, not efficient , code can pretty lengthy well. wondering if there best practice kind of memoization in java? thanks. update : many have pointed out in comments: bad idea use mutable objects key of hashmap, totally agree. and going clarify question little bit more: when use type of memoization, not change arraylist<integer> once inserted map. array represents status, , need cache corresponding value status in case visited again. so please not focus on how bad use mutable object key hashmap. suggest better way kind of memoization please. update2 : @ last choose arrays.tostring() app...

Netbeans Executable Linux C -

i building program in c in netbeans @ ubuntu (linux os) , want parse valgrind memory leaks. want locate executable netbeans create , run throught terminal valgrind. far cannot locate netbeans saves executable stuck. know can compile program terminal have lot of files in different folders convinient if take executable netbeans. alternatively way connect netbeans ide valgrind? thanks in advance i found it. looking executable located go to: netbeansprojects->projectname->dist->debug->gnu linux(x86) and there, located output when click debug tool on netbeans. convinience right click on , make link , drag link wherever like/

c# - Automatically saving form data on page unload not completing before page refresh -

i have page variable number of textareas. when unload event triggered, check textareas have been changed, perform ajax post mvc controller, adds/updates entities in database. everything seems work, except when refresh page. database operations take longer takes serve page, requiring refresh twice before see changes. javascript: $textarea.one("change", function () { // changed textareas stored in 'unsaved' here... }); $(window).on("unload", function () { if (unsaved.length > 0) { var assignmentdetails = []; // post data formationg goes here... $.ajax({ type: 'post', url: '/home/upload', data: json.stringify(assignmentdetails), contenttype: 'application/json; charset=utf-8', }); } }); controller: public class homecontroller : controller { public actionresult index() { using (var context = new sandboxcontext())...

vb.net - Substring not sub stringing string, or rather, substring not working as it should -

i'm working on application users can select values presented them, have specific form this: userdata_north , userdata_south . i need part of string after _ , tried doing substring this: dim rightstring = userdatavar.substring(userdatavar.indexof("_"), userdatavar.length) which believe gets whatever after _ , until string ends. returns nothing reason. i've gotten wrong? you've mistaken how substring works. need following: dim rightstring = userdatavar.substring(userdatavar.indexof("_") + 1) the reason it's returning nothing because starting halfway through string , asking go entire length of string , going outside range of it.

html - Two input field in line jquery mobile -

<fieldset data-role="controlgroup" data-type="horizontal" data-mini="true"> <input type="text" id="expiry_month" name="expiry_month" data-native-menu="false"> <input type="text" id="expiry_year" name="expiry_year" data-native-menu="false"> </fieldset> i have html. i'm using jquery mobile building form, can't make 2 input fields on single line. second input field jumps next line. can me out? check demo fiddle you can modify selector .ui-input-text changing display property: .ui-input-text { display:inline-block; } just sure of change inputs inside fieldset assign classname: <fieldset ... class="aside"> and make more specific css rule: .aside .ui-input-text { display:inline-block; }

unix - Apache server correctly showing site on www.domainname.com but not on domainname.com despite using ServerAlias -

i trying site , running on digitalocean. have installed , can site work @ www.domainname.com when navigate domaminname.com (without www. prefix) default page: it works! this default web page server. the web server software running no content has been added, yet. what makes strange (to me @ least, i'm not experienced devops) virtualhost file includes server alias believe should take account. domainname.com.conf file is: <virtualhost *:80> servername domainname.com serveralias *.domainname.com domainname.com serveradmin webmaster@domainname.com documentroot /var/www/domainname.com/public directoryindex index.php </virtualhost> i tried switching domainname.com www.domainname.com servername , updating serveralias accordingly got same issue. ideas should appreciated.

jquery - Ajax timeout just work once -

i coding page makes 2 ajax requests using jquery , each 1 different server. problem when each requests needs call it's own timeout event. seems the timeout event it's fired last ajax request made. if single request on page timeout works, if add second request first script's timeout not work. i spent hours searchig how fix out success. here example of code figure out talking about: $(document).ready(function($) { // goes in fist script not put script tags function getdata() { $.ajax({ url: "urlpath", async: false, datatype: "jsonp", timeout: 4000, // timeout not work when second request present success: function(parsed_json) { console.log("success fist request"); }, error: function(request, status, err) { if (status == "timeout") { console.log("timeout error first request"); } e...

memory - Working with large catalog on Magento 1.8 platform. Indexing and Exporting time out -

i have large catalog i've imported oscommerce, 127,428 products exact. they've come through magento simple products 1 image. have been unsuccessful @ getting indexing work @ command line ssh. times out or never finishes. the second problem having exporting (even enabled products) giving me memory error. there doesn't seem enough memory write export file. need edit products add additional pictures , change descriptions , such. plan use mage edit , import products in. is there can possibly thing export 127,000 products without errors? i using: system->import/export->dataflow-profiles -> export products i had exact same problem exporting google shopping. timed out (probably due having many products in feed). according this exporting magento google shopping guide : should change php.ini settings these values: ini_set(’max_execution_time’,’1800’); ini_set(’memory_limit’,’1024m’);

jQuery fancy fields plugin select list -

i'm using fancy fields plugin found @ http://www.jqfancyfields.com/ style select lists search form. text boxes in form showing in url, select values aren't. there's code on examples on plugin site binding something, don't know jquery , put everything. i'm wanting use custom scrollbar, plugin does, won't activate. jquery <script type="text/javascript"> $(document).ready(function(){ $('#myform').fancyfields({customscrollbar:true}); $('#myform').fancyfields("bind","onselectchange", function (input,text,val){ }); }); </script> html <select id="myform" name="type"> <option value="">-select-</option> <option value="option 1">option 1</option> <option value="option 2">option 2</option> <option value="option 3">option 3</option> </select> ...

opencv - HSV segmentation based on mouse click -

i trying basic image segmentation. thereshold values hsv determined pixel value mouse clicked. cannot work. here wrote far: #include <iostream> #include "opencv2/opencv.hpp" #include <cv.h> #include "opencv/highgui.h" using namespace std; using namespace cv; mat edges,frame,bw,hsv,dst,src_gray,probabilistic_hough, hsv_image; int h=110,s=40,v=140; int border=80; int linethreshold=180,linelengthslider=30,linegapslider=3, ht_threshold=10; int min_threshold = 50; void printhsvvalues(int event, int x, int y, int, void* ); void changeborder( int, void* ); scalar hsvlow(0,0,0),hsvhigh(180,255,255); int c=0; void printhsvvalues(int event, int x, int y, int, void* ); int main ( int argc, char **argv ) { videocapture cap(1); namedwindow("edges",1); namedwindow("segmented",1); setmousecallback( "edges", printhsvvalues, 0 ); while (c != 'q') { cap >> frame; imshow("e...

version control - How to sync multiple perforce workspaces -

i have multiple workspaces in perforce, w1 , w2 , w3 ,... different mappings may or may not point different folders in same depot(s). want write .bat file syncs them automatically , in sequence not put stress on server. optimally, want start off automatically , have first sync w1, after it's done have sync w2, , on. assume don't have environment variables set, if they're necessary, please let me know. how go doing this? if don't want set p4 environment variables, use global options , this: p4 -u <user> -p <password> -p <port> login p4 -u <user> -p <password> -p <port> -c <workspace1> sync //path/to/sync/... p4 -u <user> -p <password> -p <port> -c <workspace2> sync //other/path/... p4 -u <user> -p <password> -p <port> -c <workspace3> sync //yet/another/path/... if set p4user, p4passwd, , p4port p4 environment variables (see p4 set command), clean little this...

Array Element is a Variable in Array of Strings in C -

i'm trying initialize array of strings in c. want set 1 of elements of array variable, i'm getting compiler error. what's wrong this? char * const app_name = "test_app"; char * const array_of_strings[4] = { app_name, "-f", "/path/to/file.txt", null }; the error error: initializer element not constant . the standard distinguishes const -qualified variables , compile time constants. evaluating variable ( app_name ) not considered compile time constant in sense of c standard. this char const app_name[] = "test_app"; char const*const array_of_strings[4] = { &app_name[0], "-f", "/path/to/file.txt", 0, }; would allowed, since not evaluating app_name taking address. also, should treat string literals if had type char const[] . modifying them has undefined behavior, should protect doing so.

Ruby transliteration using hash -

i try make cyrillic => latin transliteration using hash, use # encoding: utf-8 , ruby 1.9.3. want code change value of file_name . why code leave file_name unchanged? abc = hash.new abc = {"a" => "a", "b" => "б", "v" => "в", 'g' => "г", 'd'=> "д", 'jo' => "ё", 'zh' => "ж", 'th' => "з", 'i' => "и", 'l' => "л", 'm' => "м", 'n' => "н",'p' => "п", 'r' => "р", 's' => "с", 't' => "т", 'u' => "у", 'f' => "ф", 'h' => "х", 'c' => "ц", 'ch' => "ч", 'sh' => "ш", 'sch' => "щ", 'y' => "ы...

java - Loop to check a variable -

i want loop through array, want check see if element in arraylist bigger number. for(int = 0; < newuser.getlist().size(); i++){ if(userage < 50){ system.print.out.ln(userage) } } but im not sure on this, because don't know how use every element of arraylist part of if, not userage if it's arraylist can iterate without using counts etc: for( int : mylist ){ if( > 50 ){ } }

Highcharts : Point Formatting not working -

i have highcharts graph similar ( http://jsfiddle.net/gh/get/jquery/1.9.1/highslide-software/highcharts.com/tree/master/samples/highcharts/demo/area-stacked-percent/ ). the part have not been able working formatting percentage values appear on tooltip. if put below code percentage value shows has many decimal places... tooltip: { pointformat: '<span style="color:{series.color}">{series.name}</span>: <b>{point.percentage}%</b><br/>', shared: true } but if have tried format value of point.percentage show less decimal places so... { point.percentage:.1f }% then literal "{point.percentage:.1f}%" shows in graph tooltip. does have suggestions on wrong? there other way format percentage value other above? thanks. you can use tooltip formatter , use highcharts.numberformat()

sockets - Android Development - Why is this application crashing? -

i've made small android application sends udp packet moment open it. the problem is, crashes when open it, instead of sending packet. i mean, i've tried running on eclipse's android virtual device, , crashes there. here's code: package com.example.messagesender; import android.os.bundle; import android.view.menu; import android.view.view; import android.widget.button; import android.widget.edittext; import android.widget.textview; import android.app.activity; import java.io.*; import java.net.*; public class message_sender extends activity { datagramsocket clientsocket; inetaddress ipaddressx; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_message__sender); try { clientsocket = new datagramsocket(); } catch (socketexception e) { // todo auto-generated catch block e.printstacktrace(); ...

sql - Oracle Database Query Design -

Image
i working on program supposed predict outcomes of 1v1 contest. have given each player own elo score , collecting sorts of data in order predict winner be. for each fighter, want collect current average elo of people defeating current average elo of people defeating them. below sample data , explanations in order better understand data structure. the picture above shows basic stats view, v_fight_review simplifies fights table stats collection. fid unique fight id , identifies fight. pid player id , identifies each unique player. winner column represents winner of fight. if pid not equal winner, player did not win fight. this picture represents players table. left recognize pid each player. right see column named elo. to rephrase question, having trouble figuring out how can produce current average elo of each player have defeated , current average elo of each player has defeated them. these average elos should change opponents win/lose fights. output should s...

Regex how to get groups within json expression -

say have following json: {"myperson":{"firstname":"first","lastname":"last","where":{"street":"street","number":15}},"anothercomplexobject":{"another":"yes","me":"true"},"count":1,"start":2} i remove starting { , ending } , get: "myperson":{"firstname":"first","lastname":"last","where":{"street":"street","number":15}},"anothercomplexobject":{"another":"yes","me":"true"},"count":1,"start":2 now, regex use "complex objects" out, example in json want these 2 results: {"firstname":"first","lastname":"last","where":{"street":"street","number":15}} {"another":...

php - sql query not returning correct results -

Image
ive got table containing results sport competition 2009 - present. table contains numerous columns such hometeam, awayteam, homescore, awayscore etc. can see image below: if want display results team (in example team sharks) for both home , away matches so: select * `results` `hometeam` = 'sharks' || `awayteam` = 'sharks' the above code working fine , correct results can see image: the problem the problem im having when want display both home , away match results 2 specific teams, im not getting correct results. (in query below im trying display home , away results when team stormers played against team sharks) query table follows: select * `results` `hometeam` = 'stormers' || `awayteam` = 'stormers' && `hometeam` = 'sharks' || `awayteam` = 'sharks' you can see image below above query returning wrong results. query returning results both team stormers , team sharks home , away matches against opponents ...

sql server - csv output from windows batch + sqlcmd only returns first column -

Image
i have looked on internet , cant seem find solution problem. i trying output query results csv through using combination of sqlcmd , windows batch. here have far: sqlcmd.exe -s %dbserver% -u %dbuser% -p %dbpass% -d %userprefix% -q "select username, userdob, usergender table" -o %userdata%\%userprefix%\fact_bp.csv -h-1 -s"," is there i'm missing here? setting looks @ first column of query results? any advice @ huge - i'm lost. here reference page msdn on sqlcmd. http://technet.microsoft.com/en-us/library/ms162773.aspx i placed command in batch file in c:\temp go.bat. sqlcmd -s(local) -e -dmaster -q"select cast(name varchar(16)), str(database_id,1,0), create_date sys.databases" -oc:\temp\sys.databases.csv -h-1 -s, notice hard coded file name , removed "" around field delimiter. i expected output below. either command not system variables or else wrong. please try code base line test. works sql 2...

eclipse - Tomcat 7 remote debugging on EC2 -

i have tomcat 7 instance running on ec2. port tomcat running on default, 8080. i wanna start tomcat in debug mode, started tomcat following command : sudo service tomcat7 start -xdebug -xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n i have 8000 port opened in security group. when try remote debug using eclipse, gives me connection refused error. clue doing wrong ? thanks.. i don't think can put debug options arguments service command. assuming installed standard tomcat7 package using yum , edit file /etc/tomcat7/tomcat7.conf , add line in it: java_opts="-xdebug -xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n" then restart tomcat service.

PHP - Appending to array within a loop -

how append elements array within loop? example, using library render graph. i wish add values graph so: $data = array(); ($x=0; $x<=50; $x++) { $data["00:".x] = rand(-10, 30); } so in theory should have elements "00:00", "00:01", "00:02" etc. random number value. however, library not render graph. i'm guessing it's because don't understand php enough. how go trying achieve this? you're missing leading zeros values of $x 0 through 9. you're missing dollar sign before variable $x : for ($x=0; $x<=50; $x++) { $data["00:".str_pad($x, 2, "0", str_pad_left)] = rand(-10, 30); }

django - Djagno Grappelli - Autocomplete and french accents -

i have problem django grappelli autocomplete. it works fine reason, if name has french accents (é,è,etc) field shows '?'. here screenshot: http://gyazo.com/64dfb579ccf9e11c0f0d9ee8337edec4 here related label: def related_label(self): return str(self.getfullname)+" - "+ str(self.city) thanks, ara return unicode object instead of str . def related_label(self): return u'{0.getfullname} - {0.city}'.format(self)

objective c - In App Email - MFMailComposeViewController - Error Message -

my code follows: viewcontroller.m: #import "viewcontroller.h" #import "myscene.h" #import "mainmenu.h" #import <messageui/messageui.h> @implementation viewcontroller - (ibaction)showmailpicker:(id)sender { // must check current device can send email messages before // attempt create instance of mfmailcomposeviewcontroller. if // device can not send email messages, // [[mfmailcomposeviewcontroller alloc] init] return nil. app // crash when calls -presentviewcontroller:animated:completion: // nil view controller. if ([mfmailcomposeviewcontroller cansendmail]) // device can send email. { [self displaymailcomposersheet]; } else // device can not send email. { self.feedbackmsg.hidden = no; self.feedbackmsg.text = @"device not configured send mail."; } } - (ibaction)showsmspicker:(id)sender { // must check current device can send sms messages before // attempt create instance of mfmessagec...