Posts

Showing posts from April, 2010

ajax - How to refresh page when clicking on "go back one page" with jQuery? -

well know it's bad practice , don't want hold user on site show him thousands of popup ads. it's have ajax loaded htm contents overwriting index.html. url same page content different. , when user clicks "go 1 page" in browser controls leave site if doesn't want to. increase usability want refresh page when doing , htm-content loaded. possible? try this.. create button id "back" go 1 page . jquery.. $('#back').click(function(){ document.location.href= "index.html"; });

c - Automake error './ltmain.sh' not found -

i've installed mingw , msys using mingw-get-setup.exe . i've installed autotools(autoconf, automake,m4,libtool) c:\/opt/autotools . when run automake, following error occurs: configure.ac:11: error: required file './ltmain.sh' not found if copy ltmain.sh libtool’s installed tree, execution finish normally. how can configuure automake find ltmain.sh without copying? in autoconf / automake / libtool project have invoke: libtoolize : copies/links few support scripts, including ltmain.sh (which main component of libtool). aclocal : looks m4 macros configure script need, , make local copy easier access. autoheader : optional, if want use config.h / ac_config_headers , otherwise test result macros inlined when call compiler. autoconf : expand macros used configure.ac configure script. automake : convert makefile.am makefile.in templates. want invoke --add-missing additional support scripts can linked/copied project (such compile , missing ...

c# - How to draw moving text with GDI+ -

the task draw moving text on black background (for example, moving number) .net gdi+. other elements may present on background, isn't possible fill area black , draw string in new position. my current code follows: graphics g = this.creategraphics(); // drawing string font myfont = new font("fixedsys", 10); g.drawstring("1", myfont, brushes.gray, 100, 100); // erasing string g.drawstring("1", myfont, brushes.black, 100, 100); // repeat code above new position string the problem text isn't erased entirely second drawstring black brush. small border remains visible. please help, how remove trace, , draw moving text correctly. the problem solved adding following: g.textrenderinghint = system.drawing.text.textrenderinghint.singlebitperpixel;

javascript - Deferred Queue in Jquery with Phonegap -

i'm trying access db using phonegap sqlite , want create deferred queue. how i'm trying access db follows for(i=0,max=elem.length;i<max;i++) { functiontoaccessdb(i); } i want make sure 1 call made db every time , others calls deferred till 1st 1 returns response.any insights ? the sqliteplugin uses callback pattern opposed deferreds. need wrap in order use deferreds. something might help: var function functiontoaccessdbforpromise = function(i){ var d = $.deferred(); var successcallback = function(){ d.resolve(args); }; var failcallback = function(){ d.reject(args); }; functiontoaccessdbwithcallbacks(i,successcallback,failcallback) return d.promise(); }; functiontoaccessdbforpromise return promise object can use queuing.

Jboss clustering: mod_cluster mod_cluster_proxy.so causing apache to crash -

i trying create cluster of jboss 7.1.1 (two instances in 1 machine port offset 100) in standalone mode. using apache (ver 2.2.22) mod_cluster(ver 1.2.0) load balancing. when bring both jboss see cluster view updated both nodes. but, getting following error in jboss: error [org.jboss.modcluster.mcmp.impl.defaultmcmphandler] (containerbackgroundprocessor[standardengine[jboss.web]]) error [mem: mem: can't read node: {4}] sending command status proxy 127.0.0.1/127.0.0.1:6666, configuration reset in apache logs, here have: [notice] parent: child process exited status 255 -- restarting. [notice] advertise initialized process 4924 [notice] apache/2.2.22 (win64) php/5.3.13 mod_cluster/1.2.0.final configured -- resuming normal operations [notice] server built: may 13 2012 19:41:17 [notice] parent: created child process 2000 [notice] child 2000: child process running [notice] child 2000: acquired start mutex. [notice] child 2000: starting 64 worker threads. [notice] child 2000:...

Amplitude spectrum of Audio file in iOS -

i new in ios development. part of developing ios app need fetch complete amplitude values of audio file , need process data without playing file (ie power per channel method not enough) . please guide me on audio file datas available in ios audio file duration, size ect.. if need process file on per-sample basis, using extaudiofileservices way go. read documentation details. can build code off of sample code provided apple. the way think in case - converting input file output file, same sample rate, duration, format etc. , processing samples converted - in effect, processing file. can later delete input file if not required. some pointers experience :- check file formats using supported (coreaudio doesn't give great error messages). make sure files using being copied app. can @ mytarget -> build phases -> copy bundle resources. can inspect files using software ifunbox.

Amazon S3 vs Window Azure Blob Storage -

i went through docs of both azure , amazon s3, confused few things - both of these try solve same question i.e, storage on cloud. question here when use what? i.e., when preferred use azure , when amazon s3 preferred. googled hard , couldn't find substantial resource same. appreciate if 1 enlighten me regarding same. edit: i want consider following params base choosing cloud provider - 1) latency 2) scalability 3) size of each file 4) cost & performance 5) files can accessed quite randomly. these few params have considered. great if can provide additional params consider. there many studies on line. should evaluate based on workload , scenario. one of many reports, says azure @ small files: http://www.nasuni.com/resource/the-state-of-cloud-storage-in-2013 under understanding, because azure blob designed unified storage, optimize small block access. conversely, s3 originate web storage. on other hand, s3 @ scale up, since azure has limitation per...

knockout.js - Adding and Updating observables in a part of the ViewModel with Knockout Mapping plugin - Not working -

though might many of similar questions knockout mapping plugin , partial view model updation, did not see issue im facing here reported in searching. i detail example below in short trying do. first create view model javascript object using ko mapping plugin's ko.mapping.fromjs . want update part of view model data receive server. so. i convert viewmodel javascript object using ko.mapping.tojs update part of js object data server use updated js object update view model using ko.mapping.fromjs the problems values of observables when first created js object through mapping remain same after update if new properties present in server data object, show-up values came with, in updated view model - not update new values in consequent updates. here simplified example. the view <div> <label data-bind="text: maintitle"></label> <div data-bind="with: layer0"> <label>name - </label> <label dat...

forms - PHP large file uploads not going through -

what's going on here? have a form works precisely intended smaller files, yet try uploading larger, form fails. don't know size limit is, doesn't work 40mb file. normal files return error of 0, meaning they've uploaded successfully, large files, don't error. it's if nothing in form passed through, , includes values of every other input in form well. there's large files stops in form working. i've gone through php.ini make sure upload_max_filesize , post_max_size values high enough, (200m each). since server local, , files test 'uploaded' instantaneously, i've made sure max_execution_time high enough (1200). the form uses post, enctype multipart/form-data, , i've tried using form has nothing more file input , submit button. this uploading code (ie, code in action page form redirects to): <?php require_once($_server['document_root'] . '/resources/recaptchalib.php'); $privatekey = "abc123"; $resp =...

java - ArrayList declaration and handling -

i use arraylist in java software , insist program has clean possible. i have ambiguity in arraylist variable declaration , usage. so, is, among these 3 arraylist usages, correct way have choose? case 1: list<object> l = some_function(); case 2: list<object> l = new arraylist<object>(); l = some_function(); //staff l.clear() case 3: list<object> l = null; l = some_function(); //staff l.clear() function: list<object> some_function(){ list<object> list = new ayyarlist<object>(); //staff return list; } my question function is: java clear list variable automatically, or have clean using clear() api , how then? } in opinion, case 1 better. 2nd case create unnecessary arraylist object, lost when assign method return value. does java clear list variable automatically, or have clean using clean() api , how then? java won't clear list, have clear it, check api, arraylist#clear() ...

html - How to make ui content fixed while the panel scrolling on jquery mobile -

i've been looking thread on internet 2 months, didn't find anything. here code: <!doctype html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.css"> <script src="http://code.jquery.com/jquery-1.10.2.min.js"></script> <script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script> </head> <body> <div data-role="page" id="pageone"> <div data-role="panel" id="mypaneldefault"> <h2>panel header</h2> <p>you can close panel clicking outside panel, pressing esc key, swiping, or clicking button below:</p> <a href="#pa...

url rewriting - Yii how to redirect to particular URL -

i have used url beautifier remove index.php?r= url. works fine. now want user redirect url if user hits particular url. suppose http://localhost/xm/xmds.php?wsdl http://localhost/xm_demo_menu/webservice/service how achieve this. search lot on google not found material relevant problem any suggestions ? i not see problem should be. see documentation in controller, call: $this->redirect("http://localhost/xm_demo_menu/webservice/service");

Find longevity of contours in opencv -

Image
i want detect small straight lines in noisy image. - find contours in image, - fit ellipse on - , height width ratio. - if ratio exceeds threshold, declare line segment. this method works fine of time. in cases (according documentation, when contours self-intersect), fitellipse gives wrong results. there other method, can determine longevity of contours? not intend use hough lines. one way grow line contour points track pixels on contour while checking line straightness. @ each new pixel estimate longest distance covered contour , line connecting contour's beginning , current contour point. when distance exceeds threshold stop growing line. in picture below, line red, contour black , distance green. in case (since aren't growing line) need connect 2 contour terminals , scan contour distances line , select largest one. compare threshold decide on linearity of segment. here how find distance point x, y line ax+by+c=0 or line defined 2 points in case: li...

javascript - JScript change function on MVC textboxfor event not firing -

so have textbox created in loop , textbox needs autosubmit form on change. had working in different page not created within loop. code follows: using (ajax.beginform("reportinput","reports",new ajaxoptions() { updatetargetid = "refresh", insertionmode = insertionmode.replace }, new { @id = "refresh" })) { .......for loop{ //id of textbox <- 1 of these textboxs created @ moment. var temp = "#inputparameters_" + +"__value"; <script type="text/javascript"> $('@temp').change(function () { $('#refresh').submit(); }); </script> @html.textboxfor(modelitem => model.inputparameters[i].value) .......} } with firebug following error pops on clicking on textbox. referenceerror: reference undefined property jquery.event.triggered return event.result; jquery-1.9.1.js (line 3091) referenceerror: reference u...

c++ - String concatenation inside macro -

to print several fields of struct, have following line repeatedly: cout << "field1=" << ptr->get_field1() so defined following macro, , use this: #define field(s, id) << s"=" << ptr->get_##id() field("field1", field1); field("field2", field2); this works. have mention same name twice in macro - once string, time variable. there better way it? (the title of question not indicate question, not think of more appropriate short combination of words. sorry that!) you should stringify id : #define field(id) << #id "=" << ptr->get_##id() field(field1); // << "field1" "=" << ptr->get_field1() field(field2); // << "field2" "=" << ptr->get_field2() live example for field(field1) , partly results in expression: "field1" "=" which 2 literal strings put side-by-side. these 2 con...

sql - Difference Between Timestamps in Milliseconds in Oracle -

i have table test1 , have 1 column doj timestamp datatype having few records shown below. here need difference im milliseconds between doj , systimestamp. select doj test1; doj ---------------------------- 21-mar-14 09.25.34.514526000 21-mar-14 09.25.34.520345000 22-mar-14 09.25.34.523144000 22-mar-14 09.25.34.527770000 23-mar-14 09.25.34.532482000 23-mar-14 09.25.34.535603000 24-mar-14 09.25.34.538556000 24-mar-14 09.25.34.541729000 select systimestamp dual; systimestamp -------------- 24-mar-14 09.48.10.251556000 +00:00 can 1 please me this. select extract(second systimestamp - doj) * 1000 test1;

Android show custom views on home screen -

Image
edit: there way show/hide textview or imageview on home screen ? in attached image, on top left corner green colored icon on click work. looking this. should use widgets this? after spending time googling, think widgets not ones i'm looking for. might wrong though. appreciated.

eclipse - Android wear sample app -

i'm trying understand how works android wear: installed (after lot of problems) library eclipse, connected android phone cable mac in develop , emulator synchronized real phone. tried send myself mail see if connection work , works well. try this, can find sample code try , understand how android wear works? did found try out this? thank you if signup developer preview on http://developer.android.com/wear/preview/start.html you sample applications wearablenotificationssample, elizachat sample code. then import these projects , create libs/ directory in project root (the same location androidmanifest.xml file). copy v4 support library jar file android sdk directory (e.g., /extras/android/support/v4/android-support-v4.jar) project libs/ directory. save wearable-preview-support.jar file in libs/ directory. right click each jar file , select build path > add build path. then important source code in java folder. run on eclipse, fix right click on java folder , ...

c++ - SSL_CTX_set_tlsext_servername_callback callback function not being called -

i writing https server , need host name client before ssl_accept() using sni. using ssl_ctx_set_tlsext_servername_callback() receive host name callback not @ called. here part of code // server name indication callback openssl static int servernamecallback(ssl *ssl, int *ad, void *arg) { if (ssl == null) return ssl_tlsext_err_noack; const char* servername = ssl_get_servername(ssl, tlsext_nametype_host_name); printf("servername: %s\n", servername); } int main() { //some code const ssl_method *method; ssl_ctx *ctx; method = sslv3_server_method(); ctx = ssl_ctx_new(method); if ( ctx == null ) { printf("ssl_ctx_new() error\n"); } int ret = ssl_ctx_set_tlsext_servername_callback(ctx, servernamecallback); } i writing https server , need host name client before ssl_accept() using sni. you don't call ssl_ctx_set_tlsext_servername_callback . openssl library invoke during hand...

javascript - css property not apply properly [bottom,right] -

Image
i create div , in javascript , after push google map attach css properties div properties applied except 1 property bottom specify value of 15px shows 0px . thoughts how apply that. demo here this how create div var unitcontroldiv = document.createelement('div'); unitcontroldiv.style.margin = '4px'; unitcontroldiv.style.padding = '4px'; unitcontroldiv.style.backgroundcolor = 'buttonshadow'; unitcontroldiv.style.borderradius = '10px'; unitcontroldiv.style.bottom = '15px'; unitcontroldiv.style.right = '10px'; unitcontroldiv.classname = 'unitcontainer'; update 1 following css generated after map load i want change above bottom , right 0 , 320px 15px , 10px respectively the problem line: map.controls[google.maps.controlposition.bottom_right].push(unitcontroldiv); this line resetting bottom css property '0px' because positioning controls bottom. workaround problem can use margin...

javascript - Google Maps JS: Uncaught TypeError: Cannot call method 'addDomListener' of undefined -

i'm getting " cannot call method 'adddomlistener' of undefined " error google.maps.event.adddomlistener(window, 'load', initialize); code line, event 'undefined'. code below copied example on developer.google.com. $(function () { var officemap = $("#map-canvas"); if (officemap.length > 0) { var map; function initialize() { var mapoptions = { center: new google.maps.latlng(-34.397, 150.644), zoom: 8 }; map = new google.maps.map(document.getelementbyid("map-canvas"), mapoptions); } google.maps.event.adddomlistener(window, 'load', initialize); } }); the google maps script (with api key) loaded before @ end of document body (using modernizr), looking this: " https://maps.googleapis.com/maps/api/js?key=myapikey&sensor=false " (i switch "myapikey" generate key ofc :)) does error indicate google maps script didn'...

c# - Open and pass values from DataGrid to Form by CheckBox -

i have datagridview checkbox column in every record. so, want when click on checkbox, information of row go form can make editions in information of record. problem how can pass info dgv form, clicking on checkbox column. can me here? try this private void datagridview1_currentcelldirtystatechanged(object sender, eventargs e) { if (datagridview1.currentcell.gettype()==typeof(datagridviewcheckboxcell) && (bool)(datagridview1.currentcell.value)==true) { form2 x =new form2(); x.label1.text = convert.tostring(datagridview1.currentrow.cells[1].value); x.show (); } }

c# - Make textobject bold based on condition in crystal report -

Image
in crystal report, there 2 columns name , amount . want if amount blank name must bold otherwise in regular font. don't know how write formula condition. appreciated. thanks. you should able to: right-click "name" field select "format object" click formula button next "style" if amount field number (probably is, used phrase "is blank"), compare 0 instead of empty string.

c# - Secure Web Api called by PhoneGap application -

i'm implementing webapi upload/convert/return videos. another developer implement phonegap application call webapi upload/convert/show videos users. the phonegap application uses openid allow users login using google , facebook. my problem want make sure client calling webapi has been logged in on phonegap app using google or facebook. i know need client send me token in request header can "extract" on web api validate user. question how can webapi know token has been generated openid (google/fb) on phonegap app? well searching , have got far share in following steps:- 1) whenever user call login page create token in response header make sure request coming legitimate user. antiforgery token in mvc. 2) upon successful login create authentication cookie , set current user context value authorize user , generate token mentioned above. 3)then after use normal authorise, roles attribute provided webapi. let me know think? more happy contribute. ...

How to remove example(label) for map backgroud mapbox in android? -

Image
i made sample project map mapbox done when terrain map type set show issue example(label) shown. how can remove issue? me in advance. i show issue image. this library open source. go in , remove label editing source code. there not public api this.

c# - not able to access functions of a different class in different namespace -

i have 2 different namespaces namespace 1 namespace project.constants { public class educationalinstitutes { public string test() { return "value"; } } } namespace 2 using project.constants; //namespace 1 namespace project.dal { public class educationalinstitute { educationalinstitutes obj = new educationalinstitutes(); obj. } } the problem functions have defined in class educationalinstitutes not available in place have created object you need place code in bottom snippet inside method. you can't call methods on obj location in class. public class educationalinstitute { educationalinstitutes obj = new educationalinstitutes(); public void dosomething() { obj.test(); } }

javascript - Angular grid reverse columns -

we using angular-grid display grid of dynamic columns. ie: col1 col2 col3 col4 col5 col6 col7 col8 col9 colx the columns being returned in correct order, however, angular grid displaying them front. colx col9 col8 col7 col6 col5 col4 col3 col2 col1 is there way reverse these columns. cant use column destinations, have no idea how many columns returned. you should list them in columndefs in correct order. the related documentation: http://angular-ui.github.io/ng-grid/ if don't know columns before getting them, can set property after received data, based on example first row.

javascript - Google Marker Drop Animation with Timeout -

i trying create drop animation large quantity of google markers. don't want 300 (or so) markers falling @ once did searching , found 'settimeout' feature. i have been following instructions question: animation of google markers on map load timeout i following same steps in post above can't seem code working in example. here thought work... var map = new google.maps.map(document.getelementbyid('map'), { zoom: 6, center: new google.maps.latlng(54.059170, -4.797820), maptypeid: google.maps.maptypeid.roadmap }); var infowindow = new google.maps.infowindow(); var marker, i; (i = 0; < locations.length; i++) { marker = new google.maps.marker({ animation: google.maps.animation.drop, position: new google.maps.latlng(locations[i][1], locations[i][2]), map: map, icon: europcmarker, }); (function (i, marker) { google.maps.event.addlistener(marker, 'click', (function(marker, i) { return function() { i...

java - Deleting from an Array using object -

if have array ( cannot arraylist ) used store specific things such "dog type", "dog name" , "dog age". create object input these elements. however, if user wants remove whole object ( inputs name, age , age ) can deleting age of dog removed. possible without using arraylist ? you can in way. no java approach, works , can refactor it. here have got dog class: public class dog { private string name; private int age; public string getname() { return name; } public void setname(string name) { this.name = name; } public int getage() { return age; } public void setage(int age) { this.age = age; } public static dog[] removebyname(dog[] list, string name) { int counter = 0; dog[] result = new dog[3]; (int = 0; < list.length; i++) { if (!list[i].getname().equals(name)) { result[counter] = list[i]; ...

javascript - How to remove unwanted space in flot chart -

Image
i using flot.js creating chart , getting unwanted space.how can remove that. var dataset1 = [ [new date("2013/01/02").gettime(), 30], [new date("2013/02/03").gettime(), 16 ], [new date("2013/03/04").gettime(), 32 ], [new date("2013/04/05").gettime(), 189], [new date("2013/05/06").gettime(), 192], [new date("2013/06/06").gettime(), 154], [new date("2013/07/06").gettime(), 336], [new date("2013/08/06").gettime(), 203], [new date("2013/09/06").gettime(), 366], ]; var chartcolor = $(this).parent().parent().css("color"); $.plot($("#chart-revenue1"),[ { data: dataset1} ] ,{ xaxis: { mode: "time", min: (new date("2013/01/01...

c# - handle leaks with .net 4.0 system -

i using windows 2003 r2 , windows 2008 r2 .net framework 4.0 (64bit). i have oltp windows service listens messages on socket , create threads processing each message. application expected process 200 transactions per second load varies time time(average of around 80 tps per day). problem facing reason, application creating handles , not getting rid of them. have used processexplorer tool see handles increasing event handles , other types of handles being released regularly. when happens, after day or 2 of execution handle count increases , application getting crashed outofmemory exception. i have verified using processexplorer event handles not getting released have @ least 1 reference. problem have no control on them program not create handles explicitly. natural doubt on clr , upon investigation found https://connect.microsoft.com/visualstudio/feedback/details/430646/thread-handle-leak#tabs quote:” posted microsoft on 4/8/2009 @ 12:39 pm thank feedback. threading develop...

nopcommerce - NopCommerece => Moving Mapping folder of Data Access Layer in Seperate Project -

in nopcommerece mvc version, trying move mapping folder out of dal project seperate class library project, trying make dal more generic, can used in other projects well. but when run application, every entity says "the entity type [entityname] not part of model current context." i think happening because autofac not finding irepository injection, tips or ideas , doing wrong? thanks in advance ok! found solution issue, in objectcontext file, there overridden method named onmodelcreating, creating instances of mapping type objects in assembly through reflection. i have asked method specific dll mapping entries , started working.

ruby on rails - Remove "www" from all links to my website - nginx -

i created rails app , when put link pointing website, "www" removed. for example when enters http://www.mydomain.com/users browser address, changed http://mydomain.com/users when page loads up. so if working apache add lines .htaccess file: rewriteengine on rewritebase / rewritecond %{http_host} ^www\.(.*)$ [nc] rewriterule ^(.*)$ http://%1/$1 [r=301,l] however working nginx , unicorn (i not sure if unicorn has this). do place in nginx configuration? any resource / point right direction helpful. as @ricoxor answered, could use rewrite correct functionality; however, listed examplary pitfall in nginx pitfalls documentation. the correct way write multiple server directives shown documentation: server { server_name www.domain.com; return 301 $scheme://domain.com$request_uri; } server { server_name domain.com; [...] } the reason more 'correct' described @ page linked: there 3 problems here. first being if directives. that...

c# - Scrollbar ItemsControl fill vertically and then scroll horizontal -

Image
i have itemscontrol items. want items ordered in picture. if there more elements, space, there should horizontal scrollbar. how archive this? relevant code: <itemscontrol.template> <controltemplate targettype="itemscontrol"> <scrollviewer panningmode="both" > <itemspresenter /> </scrollviewer> </controltemplate> </itemscontrol.template> <itemscontrol.itemspanel> <itemspaneltemplate> <wrappanel /> </itemspaneltemplate> </itemscontrol.itemspanel> edit: i'm sorry reported suggested solutions did not work, turns out height of items changing dynamically on runtime, resulting in space 1 item vertically. would work ? <itemscontrol.template> <controltemplate targettype="itemscontrol"> <scrollviewer horizontalscrollbarvisibility="auto" verticalscrollbarvisibility="...

javascript - Using Global Variables Dalek JS -

firstly great testing tool alternative here guys heavily use selenium. might basic kind of new javascript , node.js in paticular. i able use global variables in scripts having trouble doing so i have file called variables on same level test.js script example, , in example assigning google variable url, when running test fails load. require('variables.js'); module.exports = { 'log traceiq': function (test) { test .open(url) .done(); } }; i tried , test starts run hangs @ opening stage require('./variables'); module.exports = { 'open google': function (test) { test .open(url) .done(); } }; this output in console running tests running browser: google chrome os: linux 3.5.0-45-generic x86_64 browser version: 31.0.1650.63 >> warning: done not called! running test - "open google" ✔ 0 assertions run ✔ test - "open google" succeeded is there blindly obvious doing wrong here ? any appreciated tha...

php - How to send a multiple variables using ListBox by GET method -

i make listbox can send 2 variables (called category , order) shopping.php method single click on listbox. so shopping.php can use variables $_get['category'] , $_get['order'] how can that? <form method="get"> <select name="xxx" onchange="javascript: submit()"> <option value="" selected="">please select here</option> <option value="shopping.php?category=dictionary&order=booktitle">order book title</option> <option value="shopping.php?category=dictionary&order=price">order price</option> </select> </form> change code to <form method="get"> <input type="hidden" name="category" value="dictionary"> <select name="order" onchange="javascript: submit()"> <option value="" selected="">please select here</opti...

php - how to adapt one to many in my controller? -

i have 2 models (user , services). want display services of user. action show me services : public function index() { $services = service::all(); // load view , pass nerds return view::make('services.index')->with('services', $services); } and in user model add function : public function service() { return $this->hasmany('service'); } then in service model : public function user() { return $this->hasone('user'); } so please if has idea, appreciative :) the relationships looking for 1-to-many relationship hasmany() , belongsto() . with in mind, in service model, define relationship so... public function user() { return $this->belongsto('user'); } it doesn't matter in scenario because aren't using it, might save confusion later. now users's services, can use user model. $services = user::find(1)->services; or if want logged in users's services... $s...

mathematical optimization - Optimize a function several times R code -

i have function. can estimate parameters easily. sex <- c("f","m","f","m","f") age <- rnorm(5,28,1.2) dat <- data.frame(sex,age) myfun <- function(par, x1,x2){ -sum(log(exp(par[1]*x1+par[2]*x2))) } myf <- optim(myfun, par=c(0.1,0.4), x1=dat$age,x2=as.numeric(dat$sex))$par i want optimize function 10 times. if use replicate(10,myf) gives same values 10 times. guess give different parameter estimates every time due age <- rnorm(5,28,1.2) . want using loop, how can proceed? i'm not sure need, work you? myfun <- function(par, x1,x2){ -sum(log(exp(par[1]*x1+par[2]*x2))) } sex <- c("f","m","f","m","f") (i in 1:10){ age <- rnorm(5,28,1.2) dat <- data.frame(sex,age) print(optim(myfun, par=c(0.1,0.4), x1=dat$age,x2=as.numeric(dat$sex))$par) }

xml - Read a wsdl file and get tags referring to a particular namespace in java -

i have huge wsdl file,i need parse , check if valid wsdl. found can validate xml against xsd using validator object follows: javax.xml.validation.schema schema2 = factory.newschema(new file("d:\\test3\\admin.xsd")); validator validator = ((javax.xml.validation.schema) schema2).newvalidator(); validator.validate(new streamsource(new file("abc.xml"))); but since need same wsdl, thinking maybe find tags in wsdl refer particular namespace(hence schema) , write them xml file. use validator object. issue is, how should extract elements/tags refer particular xsd form wsdl? or if there wiser/simpler solution please thanks

elasticsearch search with/without spaces -

good day, created searchable index based on phonetics (in example 2 fields: indexing on metaphone , ngram). how configure index not take account gaps in sentences this: "4gb" , "4 gb"? put product_name { "settings": { "index": { "number_of_shards": 1, "number_of_replicas": 0, "analysis": { "analyzer": { "ngram_index": { "tokenizer": "standard", "filter": [ "standard", "lowercase", "index_ngram", "stopwords", "synonym" ] }, "meta_index": { "filter":["standard","lowercase","my_metaphone","sto...

Parsing Json in iOS without keys common -

my json string : [ {'local':'webaddress'}, {'qa':'webaddress1'} ] my code : nsmutabledictionary *datadictonary = [nsjsonserialization jsonobjectwithdata:responsedata options:0 error:nil]; nsarray *keys = [datadictonary allkeys]; nsarray *values = [datadictonary allvalues]; int i=0; nslog(@"",[keys count]); nslog(@"",[values count]); int i=0; ( nsstring *items in keys ) { nslog(@"----"); nslog(@"name: %@", items); nslog(@"address: %@", values[i++]); nslog(@"----"); } here size nothing blank in nslog , can't parse value don't don't why. please help.. your json array objects inside need convert nsarray: nsstring *json_str...

javac and java are in wrong encoding and locale -

Image
i'm on windows 7. system locale zh_cn , there's no way change os's locale. when install java, detected system locale , therefore java , javac will, supposedly print output in localized language (chinese in case). don't want behaviour there's no way change it. however, doesn't work. tried cygwin, git bash , win cmd, print question marks. see below sample output (from cygwin): anyone has idea how make output english? appreciated! i believe can this command: java -duser.language=en -duser.country=us ...

c# - KeyNotFoundException when iterating through Dictionary -

i have seemingly simple piece of code consistently throwing error wouldn't expect possible: // private member private dictionary<inputfield, bool> m_completed; // later on, during method foreach (inputfield filter in this.m_completed.keys) if (this.m_completed[filter]) completedcount += 1; and error i'm getting: keynotfoundexception: given key not present in dictionary this coming "if" statement in loop. to me, implies iterator has become desynchronised actual keys of dict. possible? there no threading going on. is workflow wrong? can think of few other ways count, i'd still know why code throwing error. either inputfield or 1 of base classes implements gethashcode in way such won't return same value lifetime of instance. this breaks functionality of dictionary or hashset , rely on consistent hash code. as such, possible solution make inputfield override gethashcode , equals . if overrides these, you'll ...

c# - Most effective way to redraw image -

i'm making simple 2d game. unfortunately ran issue refresh rate when add images. use invalidate on timer tick works fine until change drawrectangle drawimage . 27 objects on screen paint refresh rate drops stable 64 39 on average. images use 2-3kb shouldn't cause issue. please me understand this. why , how happen? causes , issues , how fix it? perfectly fine: foreach (ground _en in game.blocks) { e.graphics.fillrectangle(brushes.green,_en.rec); } causes frame drop: foreach (ground _en in game.blocks) { e.graphics.drawimage(image.fromfile(_en.background), _en.rec); } you're loading file memory hard disk each time call .fromfile(). store image in ground class on instantiation (or whenever, not when calling in draw()) , should fixed.

javascript - Cannot pass values into a php function -

i having trouble passing in value or array of values php script. when submit button on page clicked, following function executes: $('#rangesubmit').click( function (e) { e.preventdefault(); $.ajax({ type: 'post', url: 'http://.../test.php', data: {test1:"done"}, success: function(data) { $("#mydiv").html(data); } }); }); the php script looks this: <?php echo $argv[1]; //should return first item in array of values passed php function? var_dump($_server['argv']); ?> and script returns "null" instead of value sent script. ideas? $argv[1] reference parameter passed command line, like: php page.php argument this call page.php "argument" parameter can acessible $argv[1]. to post variables use $_post[$name]. in case use: echo $_post['test1'];

java - Hadoop Mapreduce: Reducer never called -

i have simple map/reduce task. mapper called , executed reducer never called. configuration: conf.setjobname("index builder"); conf.setspeculativeexecution(false); fileinputformat.setinputpaths(conf, new path(args[0].tostring())); fileoutputformat.setoutputpath(conf, new path(args[1].tostring())); conf.setinputformat(textinputformat.class); conf.setoutputformat(nulloutputformat.class); conf.setmapperclass(indexmapper.class); conf.setreducerclass(indexreducer.class); conf.setmapoutputkeyclass(nullwritable.class); conf.setmapoutputvalueclass(nullwritable.class); conf.setoutputvalueclass(nullwritable.class); conf.setoutputkeyclass(nullwritable.class); mapper signature: public class indexmapper extends mapreducebase implements mapper<longwritable, text, nullwritable, nullwritable> { @override public void map(longwritable key, text val, outputcollector<nullwritable, nullwritable> output, reporter reporter) throws ioexception { ...

extjs4 - extjs 4- Radiogroup value -

i don't know how set value of radiobutton group. value 'gp ' or 'p' taken in table 'listsites' . here's code: for (i = 0; < me.datasite.length; i++) { sitename = me.datasite[i].name;// data site table of object site id , name. idsite = me.datasite[i].id; type = me.listsites['site' + idsite]; // listsite table contains type of site takes value 'p' or 'gp' itemsarray.push( { xtype: 'radiogroup', fieldlabel: sitename, labelwidth: me.defaultlabelwidth, width: '100%', border: false, defaults: { padding: '0 20 0 0', xtype: 'radio', name: 'listsite' + idsite, value: type // here's problem ...

sorting - How to check if a list is sorted in Racket? -

i trying define function takes list argument , returns boolean (#t or #f) indicating if list sorted in ascending order. output of function should this: (sorted? '(1 2 3 4 5)) ; => #t (sorted? '(1 2 5 6 4)) ; => #f (sorted? '("frank" "adam" "eve")) ; => #f (sorted? '("adam" "eve" "frank")) ; => #t here's attempt @ solution: (define (sorted? lst) (cond [(< (length lst) 2] [(<= (car lst) (cadr lst)) (sorted? (cdr lst))] [(string? lst) (string<=? (car lst) (cadr lst)) (sorted? (cdr lst))] [else #f])) i keep getting errors string part, , can't seem figure out i'm doing wrong. getting errors because have 2 different types in same definiton? i'm assuming since it's conditional statement if arguments in list don't fit condition, should ignored. i'm new @ , need help. please share knowledge if know i'm doing wr...

php - Please specify the quantity of product(s) not working in Magento? -

in product page after click on add cart button without specifying quantity number redirect same page,but not display "please specify quantity of product(s)" message.after entered quantity 1or2 , click on submit button goes cart page , there shows both messages follows: please specify quantity of product(s). and product1 added shopping cart. how fix issue?please me one.

libusb - Register accessory to android phone, but when communication is established I receive “No installed aps work with this USB accessory” -

i'm trying register custom accessory android phone (4.4.2, slimkat , cyanogen). use beagleboneblack in revision a5b running ubuntu kernel version 3.8.13 usb host. accesory recognized android device phone says "connected media device" , udev rules set in ubuntu. want register accessory via libusb-1.0 api. followed guide step 11: http://electronicdesign.com/embedded/develop-aoa-usb-accessories-android-based-systems . in detail, can open host device on ubuntu , file handle claim interface send device info (manufacturer, model, description, version, uri , serialnumber) send request switch accessory mode reassign device handle reclaim device now host device should ready communicate android device. @ time on phone message "no installed aps work usb accessory. ..." pops up. my accessory-filter.xml android application looks like: <?xml version="1.0" encoding="utf-8"?> <resources> <usb-accessory man...

What is a simple version control solution for two team members that integrates with SSIS? -

team background: work part of 2 man team, our primary duty perform etl operations using ssis. part, our ssis packages don't change, on time, our algorithms derived columns, etc do. we're looking simple version control solution manage these changes. specifically, we'd ability commit changes on time. if decide isn't right, want ability go version 20 or w/e , make our current primary version. won't ever working on 1 project @ same time , other features not necessary. environment background: of our ssis projects, along associated data, stored on r: drive, accessible local drive on both of our primary work machines. make changes , load data directly folder. with background, can recommend solution meets criteria? i've done quite bit of research far , found solutions total overkill our scenario , not worth effort in setup , maintenance. software leading way visualsvn + visualsvn server + tortoisesvn, i'm finding difficult use our simple use case. are th...

Joomla Backend Login Error "500 - An error has occurred." -

i've inherited joomla site didn't create , no 1 can login backend. whenever try login in this... 500 - error has occurred. i tried suggested fix in this question

oop - errors when trying to pass an ofstream to an object (C++) -

i'm writing branch predictor simulator architecture class , i'm having trouble getting output working between multiple classes. i'm trying open 1 main ofstream in main.cpp , pass constructor of each class use objects. i'm getting whole bunch of errors in header file such as: in file included main.cpp:4:0: predictors.h: in constructor â?~atpred::atpred(std::ofstream&)â?t: predictors.h:14:18: error: use of deleted function â?~std::basic_ofstream<char>& std::basic_ofstream<char>::operator=( const std::basic_ofstream<char>&)â?t so errors seem in header file: #ifndef predictors_h #define predictors_h #include <string> // taken class atpred{ private: std::ofstream outputfile; public: // constructor atpred(std::ofstream& file) { outputfile = file; } // deconstructor ~atpred() {} // member functions void par...

ssl - Tomcat does not prompt certificate for web application (OpenAM) -

i have been trouble shooting set of openam while, still not make work wanted. wanted openam able to ocsp validate authenticating user through own copy of ejbca. therefore, need tomcat prompt user certificate , pass openam. visiting openam https fine, , user can login using password (root realm in openam). however, tomcat not prompt user certificate when visiting realm designed certificate login (a sub-realm in openam require certificate). has thought on it? here fragment of server.xml of tomcat configuration related ssl: <connector port="8181" protocol="http/1.1" connectiontimeout="20000" redirectport="8445" /> <connector port="8445" protocol="http/1.1" sslenabled="true" maxthreads="150" scheme="https" secure="true" keystorefile="/opt/sso/apache-tomcat-7.0.52/conf/keystore" keystorepass="passwor...

Add new lines using vertical select VIM -

suppose have following file content opened in vim: function a1 {} function a2 {} function a3 {} function a4 {} function a5 {} function a6 {} function a7 {} i want expand functions in style: function { } for that, tried use vertical select (using ctrl + v ): function a1 {█ function a2 {█ function a3 {█ function a4 {█ function a5 {█ function a6 {█ function a7 {█ then pressed i . enter (in insert mode): function a1 { } function a2 {} function a3 {} function a4 {} function a5 {} function a6 {} function a7 {} then pressed esc . expected expand blocks. nothing happened. why? i know simple replace or macro save me. know there alternatives, want know why new line not added when using vertical select. ctrl + v not "vertical select", "blockwise-visual". it's name implies, selecting "block" (rectangle) of text. if insert line break inside selected block, disrupts comes below it. result there no longer meaningful way vim apply...

PHP force download, download without naming the file the full path name -

so our system works storing user images in in user folders, user folders stored in master user folders stored in 1 folder called client_folders. everytime try build our download script (using php force download) files downloaded name of entire file path example: client_folder/user_30/client_130/image.jpg i want file image.jpg i have tried several things, explode array pop, basename() everytime try 1 of these options variable readfile() function reads empty. now in mysql storing entire file path (file name included) in 1 column, right way this? , how download files without entire path if helps code downloads....just full path name :( ob_clean(); if(isset($_post['file_name'])){ $file = $_post['file_name']; header("content-type: application/octet-stream"); header('content-disposition: attachment; filename="'.$file.'"'); readfile($file); exit(); } in readfile have pass full path, in header in filename file name ...

html - iOS7 Mobile Web input/select elements freezes OS -

in site i've encountered os freeze when interacting input elements. happens select elements. freeze 20-30 seconds. after that, keyboard appears , freeze 5-10 seconds , it's ok. point on, runs ok. also happens on ios7.1 thoughts?

python - xlrd, xlwt with sagemath -

i want use xlrd, xlwt, xlutils sagemath. have installed them in system's python(2.7.3) sage environment not recognizing them. getting following error when try import sage importerror: no module named xlrd` but without sage working fine. idea how can make them work inside sage?? using ubuntu 12(quantal),32 bits , sage version 5.8 python 2.7.5(sage's python). faced same problem tkinter solved using sudo apt-get install tk8.5-dev got solution form http://www.sagemath.org/doc/faq/faq-usage.html#how-to-get-sage-s-python-to-recognize-my-system-s-tcl-tk-install but other libraries? i tried install them manually inside /usr/lib/sagemath/local/lib/python2.7/site-packages/ folder putting tar files extract them , sudo python setup.py install still not working. sage not use python installed in system. uses own copy of python while working sage programs have run programs terminal using command $ sage --python <python_file> similarly sage not uses modules ...

Java Bound Mismatch Error - LinkedList -

ok interface i'm using. /* instance of classes realize interface can compared */ public interface comparable<e> { /* method compare object argument object * @param obj - argument object * @return - returns negative integer if object < obj */ int compareto(e obj); } then ordered list class. import java.util.*; /* class represent ordered list. data stored * in linked list data field */ public class orderedlist<e extends comparable<e>> implements iterable<e> { /* linked list contain data */ private linkedlist<e> thelist = new linkedlist<e>(); /* insert obj list preserving lists order * @param pre - items in list ordered * @param post - obj has been inserted list such * items still in order */ public void add(e obj) { listiterator<e> iter = thelist.listiterator(); // find insertion position , insert while(iter.hasnext()) { if(obj.compareto(iter.next()) < 0) { ...