Posts

Showing posts from March, 2012

javascript - XML request in jQuery gets ignored -

i have build webpage focuses lot on xml file populate it. generated second 1 additional tasks. unfortunatly, everytime try parse it, dows not succeed. i using simple code demonstrate problem. stripped function, writing strings browser console. once excecute code, "pos1, pos3, pos4" success function not excecuted. know sounds dumb question, hard me, find mistake right now. function insertfirstbeginnerquestion(){ console.log('pos1'); $.ajax({ url: 'xml/questions.xml', type: 'get', datatype: 'xml', success: function(data) {console.log('pos2');}, error: function(){console.log('pos3');}, }); console.log('pos4'); }; are trying in server? code works me , loads xml properly. http method, have deploy in server , access using http protocol. otherwise give 404 error while trying load xml file.

java - Extrating data from jsp form to controller and saving them to database -

hello trying save data form database have no idea how continue now. have following code. i tried using request.getparameter("id") in controller gave me compiler error. so how data jsp form controller , save them mysql database ? jsp file <%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <!doctype html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title>insert title here</title> </head> <body> <form action="productcontroller" method="post"> <p>enter product name :</p> <input id="productname" type="text" name="username"> <br> <p>enter product serial number :</p> <input id="serialnumber" type="p...

gulp-notify - get file name, not whole path, with error -

i'm using gulp-notify , gulp-plumber catch errors gulp-sass , notify me before throws error in gulp , stops whole build process. however, error shown gulp-notify isn't particularly helpful...it contains whole path file error; know path file is, need know file name , line number (and column number added not necessary bonus), , actual error message. here code: gulp.task('styles', function () { var onerror = function(err) { notify.onerror({ title: "gulp", subtitle: "build error!", message: "<%= error.message %>", sound: "beep" })(err); this.emit('end'); }; gulp.src('assets/styles/source/style.scss') .pipe(plumber({errorhandler: onerror})) .pipe(sass({ style: 'compressed', errlogtoconsole: false })) .pipe(gulp.dest('assets/styles/build')) .pipe(autoprefixe...

sql - How to handle errors in a select statement when attempting an insert or fail? -

is there way handle errors in select statement when attempting insert or fail? specifically, want insert elements table, select statement used generate these elements failing. have elements select statement succeeded inserted, overall statement fail. thought insert or fail this, not. more specifically, imagine if defined new sqlite function "log" #include <string> #include <sqlite3ext.h> #include <cmath> sqlite_extension_init1 extern "c" { int sqlite3_log_init( sqlite3 * db, char ** err, sqlite3_api_routines const * const api ); } // compute log of input void mylog( sqlite3_context *context, int argc, sqlite3_value **argv ){ // grab number auto num = sqlite3_value_double(argv[0]); // if positive, take log if(num > 0.) sqlite3_result_double(context, log(num)); // otherwise, throw error else { auto msg = std::string("can't take log of nonpo...

android - Can I determine my app's buildType in my build.gradle at run time? -

i need able bump versioncode particular buildtype called " release_beta ". have function bumps fine. i've discovered buildtypes doesn't let override versioncode. also, i'm running lot of different flavors. not want handle versioncode in more flavor variants. this not allowed. buildtypes { release_beta { minifyenabled false testcoverageenabled false signingconfig signingconfigs.release_beta versioncode buildversioncode() } the options see left are can determine build type @ runtime in build.gradle , , conditionally set versioncode depending on buildtype . i.e debug vs release_beta. something like... defaultconfig{ if(buildtypes.name == "release_beta"){ versioncode buildversioncode() }else{ versioncode 99999999999 } } can have config besides defaultconfig , , apply build type, can set different versioncode release_beta buildtype. something like... ...

sql - MySQL getting data + recursive query -

i have got 3 tables: +-----+----------+ +-----+----------+-------+ +-----+----------+-------+ | id | a_id | | a_id| b_id | value | | b_id| b_id_ | value | +-----+----------+ +-----+----------+-------+ +-----+----------+-------+ | 1| 5| | 5| 1| aa| | 1| 2| zzxx| +-----+----------+ +-----+----------+-------+ +-----+----------+-------+ | 2| 3| | 3| 3| bb| | 2| | vvyy| +-----+----------+ +-----+----------+-------+ +-----+----------+-------+ | 3| 4| bbll| +-----+----------+-------+ | 5| | oopp| +-----+----------+-------+ | 4| 5| mmnn| +-----+-----...

javascript - Which files should provided with node application to prod -

i've create nodejs application , i'll need ship ,my question if need following: node modules test folder should put both in gitigonre file , if in addition should additional actions on application you should .gitignore node_modules , npm install in every environment separately. need folder run. you don't need test folder run app though. might want test app in production environment though, depends on needs.

Zetcode.com Java: Spaceinvaders Player don't move anymore after I shot a bullet -

i tried programm spaceinvaders tutorial: spaceinvaders everything okay far, could'nt find out how set focus again on player after did shot. player not move anymore. tried allready couple of hours , know keyevents working - until shoot. ( system.out.println - testing events ok) i can move player fast befor shot, afterwards no chance. can shots again, vk_left` nor vk_right react anymore. i work eclipse luna , java build 1.8.0_40, , use original code, made me little pngs. specified iterator<alien> = aliens.iterator(); , changed: // imageicon ii = new imageicon(this.getclass().getresource(shot)); to: imageicon ii = new imageicon(shot); because otherwise nullpointer exception. this tried in board.class: workes litte better, player still want move time want. bothers me is, works times , without can find reason, player stop , want move anymore. private class tadapter extends keyadapter { @override public void keyreleased(keyevent e) { ...

android - Check if asynctask with Progress Dialog is finished in non activity class -

i have created non activity java class doing same calculation different activities. class has asynctask progress dialog in it. in cases calculation not last operation of activity , goes fine, when progress dialog goes lost. example: myjavaclass docalculations= new myjavaclass (someactivity.this); docalculations.do(); //<------ method has asysctask progress dialog finish(); result: java.lang.illegalargumentexception: view=com.android.internal.policy.impl.phonewindow$decorview{2bbf820e v.e..... r......d 0,0-1026,483} not attached window manager how can wait asynctask finish , finish activity? additional question: using asynctask in non activity class bad practice ? if want keep activity active until asynctask has finished job, can define callback method in activity gets called when task has finished , can react appropriately: in activity : private boolean finishaftercurrenttask = false; public void ontaskfinished() { if (finishaftercurrenttask) {...

Container similar to Android's ArrayMap in C++ -

android provides associative container named arraymap , implemented 2 simple arrays. this container supposed slower other data structures, when inserting data, memory-efficient. is there such thing implemented in c++? boost's flat_map , eastl's vector_map seem analogues of arraymap .

java - Detect invalid date on Calendar.set() -

i have method returns me date() changed 1 of it's "fields" (day, month, year). public static date getdatechanged(date date, int field, int value) { calendar cal = calendar.getinstance(); cal.settime(date); cal.set(field, value); return cal.gettime(); } however, cal.set() unable give exception when field trying set not compatible date in question. so, in case: date date = new date(); date = getdatechanged(date, calendar.day_of_month, 29); date = getdatechanged(date, calendar.month, 1); // feb date is, in end, 01/03/15, because calendar.set() detects february can't set day 29, automatically set's date next possible day (i thinks how routine works). this not bad, however, in case, i want detect date i'm trying build impossible , then start decrementing day, in case i'm trying achieve 28/02/15, how can this? example: 29/02/15 ===> 28/02/15 you can use cal.getactualmaximum(calendar.day_of_month) find maxim...

powershell - Sending complex, multi-line command via plink to Cisco Router =Unexplained behavior -

i'm trying below part of code done in relatively condensed fashion (to plug in bigger script). don't have problems sending multiple commands way. however, there's that's causing multi-line command choke. syntax cisco comnmands appear correct. i'm not sure if i'm running kind of character limit or if need escape specific characters in $showintstatuscommands , nothing tried seems work. this code: $bgpinterface = "gigabitethernet0/2" $showintstatuscommands = "`nterminal length 0`nsho int $bgpinterface | include reliability|errors`nsho log | include $date.*link-3-updown.*$bgpinterface`nexit" ($response = $showintstatuscommands | c:\windows\plink.exe -ssh -2 -l $credential.getnetworkcredential().username -pw $($credential.getnetworkcredential().password) $devicename -batch) 2>$null | out-null produces below when reveal contents of variables. $showintstatuscommands appears correct when echoes locally. notice, end of 3rd line cut...

automation - How to execute certain command after new kernel is installed -

every time new kernel downloaded , installed unattended upgrades virtual box service gets broken. so, when try start vm box after reboot error: virtualbox complaining installation incomplete. please run `vboxmanage --version` see error message should contain instructions on how fix error. to fix issue sudo dpkg-reconfigure --priority low virtualbox-dkms how can automate that?

ios - Scale a circle at same center position -

i working on scaling circle , keep same center position, looks pulsing circle on map. animationview.m @property (nonatomic, strong) uibezierpath *ovalpath; - (void)drawcircle { uigraphicsbeginimagecontext(self.frame.size); cgrect rect = cgrectmake(25.45, 49.25, 5.8, 5.8); self.ovalpath = [uibezierpath bezierpathwithovalinrect: rect]; [self.ovalpath fill]; uigraphicsendimagecontext(); } - (void)bumpupcircle { cashapelayer *pathlayer = [cashapelayer layer]; pathlayer.frame = self.bounds; pathlayer.path = self.ovalpath.cgpath; pathlayer.fillcolor = [uicolor blackcolor].cgcolor; pathlayer.linewidth = 2.0f; pathlayer.linejoin = kcalinejoinbevel; [self.layer addsublayer:pathlayer]; cabasicanimation *animation = [cabasicanimation animationwithkeypath:@"transform.scale"]; animation.fromvalue = [nsvalue valuewithcatransform3d:catransform3dmakescale(0.0, 0.0, 0)]; animation.tovalue = [nsvalue valuewithcat...

Git error remote origin already exists: trying to make initial commit -

i'm trying push first commit new github repository , running issues remote origin. when try commit , push readme.txt file, fine until instructions indicate need run in command line: git remote add origin https://github.com/afreymiller/personal_website.git i "fatal: remote origin exists." fair enough, git push -u origin master as instructions indicate, , receive error fatal: 'git@github.com/afreymiller/personal_website.git' not appear git repository fatal: not read remote repository. please make sure have correct access rights , repository exists. what should next? it looks you're trying change repo url ssh https. have remote origin url, instead of adding new one, change existing 1 using following command: git remote set-url origin https://github.com/afreymiller/personal_website.git after execute command, git install interacting github using https, want. using https instead of ssh, prompt password every time push github, less c...

ninject - Accessing CurrentUser on NancyContext outside Modules -

i've implemented restful service using nancyfx uses tokenauthentication keep track of logged in users. various activities need know user has sent request, added iusercontext interface solution , in nancy project implement interface in class takes nancycontext , returns username/claims/authentication status. said iusercontext passed services through constructor injection using ninject. in ninjectmodule on application level bind interface so: bind<iusercontext>().to<usercontext>(); this required seems iusercontext won't bound when nancy instantiates modules route discovery on first run , connecting server result in ninject error. in bootstrapper i've overridden both requeststartup , configurerequestcontainer methods in order rebind iusercontext constant, so: protected override void requeststartup(ikernel container, ipipelines pipelines, nancycontext context) { base.requeststartup(container, pipelines, context); tokenaut...

Android display progress dialog in front of alert dialog -

i have problem progress dialog asynctask. here's scenario. have app has alert dialog, checks db. if result true call asynctask displays progress dialog. progress dialog displaying behind alert dialog. how can display progress dialog in front of alert dialog? asynctask: protected void onpreexecute() { super.onpreexecute(); pdialog = new progressdialog(readbibleactivity.this); pdialog.setmessage(getresources().getstring(r.string.translating_bible_version)); pdialog.setindeterminate(true); pdialog.setprogressstyle(progressdialog.style_spinner); pdialog.setcancelable(false); pdialog.show(); } alert dialog: private void displaydialog() { customdialog = new dialog(this); customdialog.settitle(getresources().getstring(r.string.share)); customdialog.setcontentview(r.layout.dialog); ettitle = (edittext) customdialog.findviewbyid(r.id.ettitle); etdescription = (edittext) customdialog.findviewbyid(r.i...

oracle - How do I create a conditional SQL query -

i trying create oracle sql query using if/else statements if exists ( select * baninst1.an_employee_position baninst1.an_employee_position.person_uid = 593791 , baninst1.an_employee_position.position_end_date null) select * baninst1.an_employee_position baninst1.an_employee_position.person_uid = 593791 , ( baninst1.an_employee_position.position_end_date null or baninst1.an_employee_position.position_end_date > sysdate) , baninst1.an_employee_position.effective_start_date <= sysdate;else select * ( select * baninst1.an_employee_position baninst1.an_employee_position.person_uid = 593791 ) rownum = 1;end if; however receive "unknown command" error when run it. no more error information this may provide looking for: select a.* employee_position person_uid = 593791 , ( (a.position_...

php - Displaying other webpage using cURL request -

i want display other webpages on website using curl. not working iframes because not work in lot of cases. i can make pages display using curl using following code. $result=query("select url links l_id='$linkid'"); $url =$result[0]["url"]; $ch = curl_init(); // set single option... // ... or array of options curl_setopt_array( $ch, array( curlopt_url => $url, curlopt_returntransfer => true )); // execute $output = curl_exec($ch); but in of url's sometime css file or other images not load. i 403 forbidden error. can make these errors go away in of cases. i opening host of url's. again don't want open in iframe. or there method use. they have used related path css , images. add domain url image url. example, <img src="http://backlinko.com/img1.jpg"/> this. <img src="<?php echo $url;?>/img1.jpg">

Spring Security Custom login using Java Config Based -

i using spring security java based config. unable call process action when user submits login form. here config , java file. please let me know doing wrong. in advance. 1) spring security java config class @configuration @enablewebmvcsecurity public class securityconfig extends websecurityconfigureradapter { @autowired userservice userservice; @bean public authenticationmanager authenticationmanager() throws exception{ authenticationmanager authenticationmanager = new providermanager( arrays.aslist(authenticationprovider())); return authenticationmanager; } @bean public authenticationprovider authenticationprovider() throws exception { daoauthenticationprovider authenticationprovider = new daoauthenticationprovider(); authenticationprovider.setuserdetailsservice(userservice); authenticationprovider.afterpropertiesset(); return authenticationprovider; } @o...

c# - No overload for matches delegate 'System.Timers.ElapsedEventHandler' -

i reading article: http://www.c-sharpcorner.com/uploadfile/naresh.avari/develop-and-install-a-windows-service-in-c-sharp/ playing windows services encountered little problem due lack of knowledge. in part of code: protected override void onstart(string[] args) { timer1 = new timer(); this.timer1.interval = 10800; this.timer1.elapsed += new system.timers.elapsedeventhandler(this.timer1_tick); timer1.enabled = true; } private void timer1_tick() { //some code here } protected override void onstop() { timer1.enabled = false; //some code here } the this.timer1.elapsed += new system.timers.elapsedeventhandler(this.timer1_tick); gives: error 1 no overload 'timer1_tick' matches delegate 'system.timers.elapsedeventhandler' i wonder why since many people don't have problem example? an event nothing else multicast delegate. , method signature not...

c# - Nuget package for image rotating feature -

i tried searching did not get.i came across imageresizer not sure how use it. there other nuget package provides image rotation feature? in imageresizer the command listed on http://imageresizing.net/docs/v4/reference srotate=0|90|180|270 rotates source image prior processing (only 90 degree intervals) (new in v3.1).

azure sql database - Resource Stats is empty after upgrading to V12 -

we've completed upgrading of our sql azure v11 v12 few hours ago, running smoothly except our sys.resource_stats not returning records @ all. viewing monitoring in azure portal, i'm getting error server not retrieve metrics. how fix this? thanks we have defect in service side , fix being rolled out soon. in mean time please create ticket against microsoft , 1 of our engineers fix it.

javascript - Simple jQuery Tooltip (position distorted on iPad) -

i've used simple jquery ui tooltip on form-fields of webpage(viz responsive), working on desktop on every browser, on ipad distorted when tap on form-fields keypad swipe-up. header section of webpage gets fixed on scroll. i've used below code custom jquery tooltip. $(function () { $('.form-control').tooltip({ disabled: true, position: { my: "left top", at: "left top-50", using: function( position, feedback ) { $( ).css( position ); $( "<div>" ) .addclass( "arrow" ) .addclass( feedback.vertical ) .addclass( feedback.horizontal ) .appendto( ); } } }).on("focusin", function () { $(this) .tooltip("enable") .tooltip("open"); }).on("focusout", function () { $(this) .tooltip("close") .tooltip("disable...

html - Floats and Spacing? -

so, placed in many different ways "logo" , text next it. Ä° leave breathing room 10 pixels, doesn't seem work. Ä° know of past questions not received sorry if 1 well. here code, can me find out why wouldn't leave space? css: img { width: 110px; height: 110px; float: left; } body { font-family: sans-serif; background-color: #f7de86 } h3, h1 { font-family: sans-serif; padding-left: 125px; } h1 { position: relative; top: 55px; left: 125px; } h3 { color: #b79104; } .wrap { width: 750px; margin: auto; height: 130px; } img { width: 110px; height: 110px; float: left; padding-right: 10px; } use padding-right add space. read page more information http://www.w3schools.com/css/css_boxmodel.asp i hope solves problem.

android - How to execute a query that gets only one value from the column? -

i trying retrieve unique _id table have created in sqlite. not seem , im not sure im doing wrong here, advice appreciated /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ method returns exercise id, corresponds exercise passed , bodypart passed ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ public int getexerciseid(string exercise, string bodypart) { sqlitedatabase db = mydbhelper.getwritabledatabase(); string query = "select " + mydbhelper.column_id + " " + mydbhelper.table_exercises + " " + mydbhelper.column_bodypartname + "= \"" + bodypart + " \"" + " , " + mydbhelper.column_exercisename + "= \"" + exercise + " \";"; cursor c = db.rawquery(query, null); /*return exerciseid= c.getint(c.getcolumnindex(mydbhelper.column_id));*/ int exerciseid = -1; c.movetofirst(); while (!c.isa...

capistrano3 - How to set the server variable on the fly using capistrano 3 -

we're trying make our deployment scripts generic possible. possible have capistrano 3 prompt server address rather setting in config files. so far have capistrao task does namespace :config task :setup ask(:db_user, 'db_user') ask(:db_pass, 'db_pass') ask(:db_name, 'db_name') ask(:db_host, 'db_host') ask(:application, 'application') ask(:web_server, 'server') setup_config = <<-eof #{fetch(:rails_env)}: adapter: postgresql database: #{fetch(:db_name)} username: #{fetch(:db_user)} password: #{fetch(:db_pass)} host: #{fetch(:db_host)} eof on roles(:app) execute "mkdir -p #{shared_path}/config" upload! stringio.new(setup_config), "# {shared_path}/config/database.yml" end end end and in production.rb file have set :application, "#{fetch(:application)}" set :server_name, "#{fetch(:application)}.#{fetc...

Will Azure SQL database automatic upgrade to new service tiers? -

currently using free 20 mb azure sql database web edition. microsoft going retire azure web , business edition after 12 september 2015. microsoft had announced new service tiers. if not upgrade new service tiers, upgrade automatically? service tiers upgraded to? if not upgrade automatically, database deleted or remains usual? yes if don't upgrade, automatically upgraded post web , business retirement. destination service tier defined based on billable size of dbs. can details of pricing tier here: http://azure.microsoft.com/blog/2014/04/24/azure-sql-database-introduces-new-service-tiers/ for free dbs specifically, working on replacement sku available retirement date. free db mapped in new free db sku. thanks silvia

r - How to create a lag variable within each group? -

i have data.table: set.seed(1) data <- data.table(time = c(1:3, 1:4), groups = c(rep(c("b", "a"), c(3, 4))), value = rnorm(7)) data # groups time value # 1: b 1 -0.6264538 # 2: b 2 0.1836433 # 3: b 3 -0.8356286 # 4: 1 1.5952808 # 5: 2 0.3295078 # 6: 3 -0.8204684 # 7: 4 0.4874291 i want compute lagged version of "value" column, within each level of "groups". the result should like # groups time value lag.value # 1 1 1.5952808 na # 2 2 0.3295078 1.5952808 # 3 3 -0.8204684 0.3295078 # 4 4 0.4874291 -0.8204684 # 5 b 1 -0.6264538 na # 6 b 2 0.1836433 -0.6264538 # 7 b 3 -0.8356286 0.1836433 i have tried use lag directly: data$lag.value <- lag(data$value) ...which wouldn't work. i have tried: unlist(tapply(data$value, data$group...

python - Add matrix in X-axis using matplotlib -

Image
i try add matrices in x-axis using matplotlib. code wrote is: #!/bin/python import sys import numpy np import math import decimal import matplotlib.pyplot plt import matplotlib.mlab mlab matplotlib import rcparams def plot(): n = 6 ind = np.arange(n) ind_label = ['1x', '2x' , '3x' , '4x', '5x', '6x'] y = [1.60, 1.65, 1.70, 1.75, 1.80] m1 = [1.62, 1.64, 1.64, 1.71, 1.7, 1.68] m2 = [1.61 , 1.7, 1.7, 1.8, 1.75, 1.75] m3 = [1.63 , 1.69, 1.7, 1.67, 1.64, 1.61] width = 0.2 fig = plt.figure() ax = fig.add_subplot(111) rec_m1 = ax.bar(ind, m1, width, color='r', align='center') rec_m2 = ax.bar(ind+width, m2, width, color='g', align='center') rec_m3 = ax.bar(ind+width*2, m3, width, color='b', align='center') ax.set_ylabel('value',fontsize=20) ax.set_xlabel('matrix', fontsize=20) ax.tick_params(ax...

swift - How to implement different contextual-menus in a NSOutlineView -

Image
i have view-based nsoutlineview , want show different contextual menus if user right-clicks header or 1 of expanded items. i dropped 2 nsmenu's storyboard file. when connect menu outlet of headercell 1 of menus got "unsupported configuration" warning , menu never shown. (the same warning table view cell) i using swift. can guide me right direction? 1.add nsmenu on scene 2.add outlets setting nsoutlineview make relationship between nsoutlineview nsmenu 3.add custom class overriding nsmenudelegate

Java String best practices -

i have 4 string parameter's in java (from request object) string dd = req.getparameter(dd); string mm = req.getparameter(mm); string yyyy = req.getparameter(yyyy); after validating dd,mm,yyyy building date object in 4th string variable building string date = dd+"/"+mm+"/"+yyyy; again in places need replace date format following, date = yyyy+mm+dd; date =mm+"/"+dd+"/"+yyyy; // storing in db need format how memory consume since 4 objects need pass till persist in table? costlier memory call? there best practice? @ last howmany string objects in stringpool? my suggestion should not worry micro improvement other suggested. may create wrapper object e.g. mydate , construct date object once. after can use different formatter format date. package com.dd; import java.text.simpledateformat; import java.util.date; import org.joda.time.localdate; public class mydate { private date date; public mydate(request req)...

android - Adapter returning same item twice -

i have listview holding items. shows result of search in database, 2 items meets criteria of select sentence. when search first time, returns twice same item. but, when click search button again, time done ok, showing both items. items first time? adapter: public class listaexpedientesadapter extends baseadapter { private arraylist<beanlistaexpedientes> listaexpedientes; private layoutinflater inflater=null; private context c; public listaexpedientesadapter(context c, arraylist<beanlistaexpedientes> lista){ this.listaexpedientes=lista; inflater=layoutinflater.from(c); this.c=c; } @override public int getcount() { return listaexpedientes.size(); } @override public object getitem(int position) { return listaexpedientes.get(position); } @override public long getitemid(int position) { return position; } @override public view getview(int position, view convertview, viewgroup parent) { viewholder holder; if(convertview==null){ ...

Error in C#(windows 8.1 phojne development) -

i new program language ,i can't locate problem ,i looked through of pages provided in community,but can't find solution.. here question? i trying parse jsonarray getting webserver.. parsing code this,but gives me error mentioned below private async void navigatebtn_click1(object sender, routede..ventargs e) { long phone = system.convert.toint64(phonenumber.text); string pwd = system.convert.tostring(password.text); uri url = new uri("http://www.example.com&phnum=" + phone + "&pass=" + pwd); system.net.http.httpclient httpclient = new system.net.http.httpclient(); var response = await httpclient.getasync(url); var result = await response.content.readasstringasync(); debug.writeline(result); login deserializeduser = readtoobject(result); frame.navigate(typeof(maps)); } } private static login readtoobject(string resul) { ...

java - How to get path of a file in local machine from webapplication -

i'm trying upload excel file application , trying store data in db , working in system. when im trying other machine i'm getting error path not found. the reason error known. it's because file path belongs other system , server(tomcat) in system. when passed path parameter server searching in system. so here question how access file system.? you need take path network related in : file filetoread = new file(new uri("file://myserver/myfolder/myfolder/mypicture.jpg"));

handlers - Applescript: Getting a list of numbered folders from a shell script and identifying the highest value -

i have 2 different handlers, 1 gets names (which numbers "1.0" , "1.1") of folders within folder, converts applescript list. passes list handler, evaluates list , supposedly identifies highest number (i got http://www.macosxautomation.com/applescript/sbrt/sbrt-03.html ). on set_values(project_path) shell script "ls " & project_path words of result set allvalues (result) return allvalues end set_values then turn result variable next handler: set values_list result and handler highest number list, courtesy of macosxautomation: on highnum(values_list) set high_amount "" repeat 1 count of values_list set this_item item of values_list set item_class class of this_item if item_class in {integer, real} if high_amount "" set high_amount this_item else if this_item greater high_amount set high_amount item of values_list end if else if item_class list set h...

java - What‘s the difference between volatile and UNSAFE.putIntVolatile() -

private static final long segshift_offset; segshift_offset = unsafe.objectfieldoffset( concurrenthashmap.class.getdeclaredfield("segmentshift")); unsafe.putintvolatile(this, segshift_offset, 32); the code adove can replaced code follows? private static volatile long segshift_offset = 0l; segshift_offset = 32; or can replaced follows? private static synchronized long sefshift_offset = 0l; segshift_offset = 32; i assume code have in class subclasses concurrenthashmap class. no, cannot replaced suggest. code dangerous thing: updates package-private final field segmentshift of concurrenthashmap new value. segshift_offset used determine offset of segmentshift field within class (number of bytes between field location , beginning of object) in memory. offset assumed constant during jvm lifecycle, it's stored in final field. your suggested replacements different thing: declare field , change value. way cannot change value of inaccessibl...

.net - Consume WCF service in winform, how to dynamically set Endpoint element and contract -

Image
i have build test wcf service service1.svc have added service reference of service winform. working , can consume wcf service in winform. got major problem : when rename or delete 'myproject.exe.config' file. showing error ' not find endpoint element name basichttpbinding_iservice1 , contract servicereferenct1.iservice1 since 'myproject.exe.config' file contains binding , endpoint address don't want share client or anyone. there way dynamically set endpoint element , contract without using 'myproject.exe.config' file ? app.config : <?xml version="1.0" encoding="utf-8" ?> <configuration> <startup> <supportedruntime version="v4.0" sku=".netframework,version=v4.0,profile=client" /> </startup> <system.servicemodel> <bindings> <basichttpbinding> <binding name="basichttpbinding_iservice1" /...

inheritance - C++: Field has incomplete type -

i trying implement strategy design pattern exercise. classes pretty simple: 1) fly.cpp class fly { public: fly(); bool fly(); }; class canfly : public fly { public: bool fly() { return true; } }; class cantfly : public fly { public: bool fly() { return false; } }; 2) animal.cpp class fly; class animal { fly myfly; public: animal(fly f); void setfly(fly f); fly getfly(); }; animal::animal(fly f) { myfly = f; } void animal::setfly(fly f) { myfly = f; } fly animal::getfly() { return myfly; } 3) dog.cpp #include <iostream> using namespace std; class animal; class dog : public animal { public: dog(fly f); }; dog::dog(fly f) { setfly(f); cout << "dog : " << getfly().fly() << endl; } 4) bird.cpp #include <iostream> using namespace std; class animal; class bird : public animal ...

c# - Entity Framework generate update script for dev/production -

Image
i have been made few changes database locally , have been adding migrations , updating database via package manager console. now i've checked in , deployed out dev server getting error: the model backing 'myprojectcontext' context has changed since database created. consider using code first migrations update database ( http://go.microsoft.com/fwlink/?linkid=238269 ). i know telling me version of database out of date don't want drop database time im trying generate script manually run on database don't understand how can tell last migration dev db aware of , current, date one, ive tried below not working: so if "added isimportant exceptions" last migration updated on dev server, , "set importantid identity specification" last update manually run locally, how generate right script dev? turns out doing right needed full configuration name double quotes. update-database -script -sourcemigration:"201507091527309_...

HTTP Error when trying to upload images to WordPress -

i'm trying upload simple images in wordpress - photos taken dslr camera. every once in awhile i'll little red box saying "http error" no other explanation. at first, thought it's file size images larger 10mb although did notice work images not others. got stuck small collection of images not upload @ used photoshop batch converter , reduced size 1-2mbs. however, still not upload properly. tried open , resave them paint, changed extension .jpg .png nothing works! it frustrating simple image upload in wordpress not work (always). suggestion how fix problem or @ least narrow down , find out what's causing it? if try every solution out there htaccess , wont work , may have imagick installed default lib php in server fix use in functions.php file. add_filter( 'wp_image_editors', 'change_graphic_lib' ); function change_graphic_lib($array) { return array( 'wp_image_editor_gd', 'wp_image_editor_imagick' ); } ...

rust - Who owns a value without a let binding? -

consider following code: struct mystruct { not_copyable: notcopyable } struct notcopyable; fn main() { let foo = mystruct { not_copyable: notcopyable }; foo.not_copyable; foo.not_copyable; // found out simpler "foo; foo;" create same problem } this fails compile with src/main.rs:17:5: 17:21 error: use of moved value: `foo.not_copyable` [e0382] src/main.rs:17 foo.not_copyable; ^~~~~~~~~~~~~~~~ src/main.rs:16:5: 16:21 note: `foo.not_copyable` moved here because has type `notcopyable`, non-copyable src/main.rs:16 foo.not_copyable; ^~~~~~~~~~~~~~~~ error: aborting due previous error while i'm still not versed in ownership system, think why couldn't create 2 let bindings foo.not_copyable . in case there no binding. owns not_copyable here; did move? so owns `not_copyable here; did move? no one. expression foo.not_copyable has pull value out of structure, because value result ...

java - [Solved]Android Studio JDK, JAVA_HOME does not effect the path -

Image
no matter path use java_home variable not effect android studio path finding jdk, tried restarting computer after changing path , still doesnt work, image attached. thanks thanks replaying solved setting new variable named path , set jdk bin folder

python - Threaded, non-blocking websocket client -

i wanting run program in python sends message every second via web sockets tornado server. have been using example on websocket-client; this example not work, because ws.run_forever() stop execution of while loop. can give me example of how correctly implement threaded class can both call send method of, receive messages? import websocket import thread import time def on_message(ws, message): print message def on_error(ws, error): print error def on_close(ws): print "### closed ###" def on_open(ws): pass if __name__ == "__main__": websocket.enabletrace(true) ws = websocket.websocketapp("ws://echo.websocket.org/", on_message = on_message, on_error = on_error, on_close = on_close) ws.on_open = on_open ws.run_forever() while true: #do other actions here... collect data etc. in range(100): time.sleep(1) ws.send("hello %d" % i) time.sleep(1) t...

angularjs - how to render the options inside angular select box -

how render values inside dropdown(selectbox options). need show ' header ' , ' footer ' names inside selectbox. $scope.sections = [ { "header":{ "background-color":"#fff", "color":"#fff" }, "footer":{ "background-color":"#fff", "color":"#fff" } } ]; i tried in following way not working, <select name="section" class="form-control" ng-model ="section"> <option ng:repeat="options[0] in sections"> {{options[0]}} </option> </select> you need iterate on keys instead of values. <option ng-repeat="(option, val) in sections[0]"> {{option}} </option> or ng-options ng-options="option (option, val) in sections[0]" see plunker http://plnkr.co/edit/fqeool5wnh8xl8gprt99?p=preview ...

Conditional join in r -

i conditionally join 2 data tables together: library(data.table) set.seed(1) key.table <- data.table( out = (0:10)/10, keyz = sort(runif(11)) ) large.tbl <- data.table( ab = rnorm(1e6), cd = runif(1e6) ) according following rule: match smallest value of out in key.table keyz value larger cd . have following: library(dplyr) large.tbl %>% rowwise %>% mutate(out = min(key.table$out[key.table$keyz > cd])) which provides correct output. problem have rowwise operation seems expensive large.tbl using, crashing unless on particular computer. there less memory-expensive operations? following seems faster, not enough problem have. large.tbl %>% group_by(cd) %>% mutate(out = min(key.table$out[key.table$keyz > cd])) this smells problem data.table answer, answer not have use package. what want is: setkey(large.tbl, cd) setkey(key.table, keyz) key.table[large.tbl, roll = -inf] see ?data.table > roll...

c# - LINQ optimization using single query on collection of integers -

i have list of integers below list<int> mycollection = new list<int> { 2625 }; i checking below condition if(mycollection.count() == 1 && mycollection.any(number=> number == 2625)) { // } how can optimize query can include both conditions single query? note: mycollection may contain multiple elements hence have used any(). one obvious optimization use list instance properties: if(mycollection.count == 1 && mycollection[0] == 2625)) { // }

sails.js - Effectively using association population in SailsJS -

association auto population sexy during stages of app development. related models result in high number of associated records api calls drastic performance hit. sailsjs provides way toggle globally. module.exports.blueprints.populate = true / false; ideal application disable option globally , load related models on demand , possible ( base use case how laravel things eager loading http://laravel.com/docs/5.0/eloquent#eager-loading ). you should able override blueprint configuration per controller #/disabling-blueprints-on-a-per-controller-basis you may override of settings config/blueprints.js on per-controller basis defining '_config' key in controller defintion, , assigning configuration object overrides settings in file. try in controller want activate populate: module.exports = { _config: { populate: true } }

html - Flex Layout with fixed position (no scrolling) sidebar -

i have layout left , right canvas sidebars, enclosing main content area in middle. the sidebars , main content flex items, positioned in flex layout left right. the sidebars contain menus , meta links. my question is: when scrolling content area, possible leave sidebars in fixed position, such stay in top position , not scroll down? js fiddle: http://jsfiddle.net/windwalker/gfozfpa6/2/ html: <div class="flexcontainer"> <div class="flexitem" id="canvas-left"> <p>this content should not scroll</p> </div> <div class="flexitem" id="content"> <div> <p>scrolling content</p> </div> </div> <div class="flexitem" id="canvas-right"> <p>this content should not scroll</p> </div> </div> css: .flexcontainer { display: flex; flex-direction: row...