Posts

Showing posts from March, 2014

scala - NoClassDefFoundError running tests in SBT with scoverage plugin -

i have sbt project structure here: https://orrsella.com/2014/09/24/integration-and-end-to-end-test-configurations-in-sbt-for-scala-java-projects/ . includes standard main , test directories , additionally it , e2e . there task " test-all" runs tests. works correctly unless run e2e or test-all coverage plugin. i'm getting: java.lang.noclassdeffounderror: scoverage/invoker$ using show it:dependencyclasspath , show e2e:dependencyclasspath , can see e2e classpath missing scoverage plugin jars. idea what's wrong , how solve it? build.sbt import org.scalatra.sbt._ import sbt.keys._ import sbt._ object maappbuild extends build { val organization = "com.my-org" val name = "my app" val version = "0.1.0-snapshot" val scalaversion = "2.11.6" val akkaversion = "2.3.4" val scalatraversion = "2.3.0" lazy val project = project( "my-app", file("."), configuratio

sql - Join two tables, not joined with any foreign keys and different unrelated ids -

i have 2 tables. companynames: company_name text (unique) companyname_id bigint homenicknames: home_nickname text (unique) nickname_id bigint so, rows like: companynames ============== company_name || companyname_id |:--------------------------------------:| robert | 123 mr.robert | 123 mr.robertgrant | 123 homenicenames ============== home_nickname || nickname_id |:-------------------------------------:| robert | 431 robb | 431 dearrobb | 431 assume every company name , nickname can joined because of 1 same company name , nickname. i need query can generate following result: name_id || home_nickname |:-----------------------------------:| 123 | robb 123 | robert 123 | dearrobb find robert first , nicks id: select c.companyname_id ,n2.home_nickname companynames c join homenice

apache - .htaccess scope of RewriteCond -

i'm creating .htaccess file need in server: <ifmodule mod_rewrite.c> #enable rewrite engine rewriteengine on #rewrite base / if not local host rewritebase / #set base in case of local development rewritecond %{http_host} ^(.*)localhost(.*)$ rewritebase /~asafnevo/api #redirect every request index.php rewriterule ^(.*)$ api/index.php?request=$1 [qsa,nc] # prevent direct access access index.php rewritecond %{the_request} index\.php rewriterule ^(.*)index\.php$ - [f] </ifmodule> i added the: #set base in case of local development rewritecond %{http_host} ^(.*)localhost(.*)$ rewritebase /~asafnevo/api in order have different base in localhost development environment, question when rewritecond ends? i tried rewritebase /~asafnevo/api [l] but receive 500 error. can please expend of scopes in matters of rewritecond ? you using rewritebase incorrectly. can't use [l] flag because it's no

javascript - How to get the rows value in php as all rows name is same? -

please find below code add new rows delete row button. using script can enable 5 rows after "add more" button automatically disable. problem is, if click on submit button php page should print rows values. not able print rows values rows name same (input_box_one[] , input_box_two[] ). hence not able rows. <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <script type="text/javascript" src="./jquery-1.7.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $('.del').live('click',function(){

java - Creating commit with Jgit and plumbing commands -

i trying construct commit plumbing commands in jgit. besides fetching information, use these commands: treeformatter.append(foldername, filemode.tree, treeobjectid); treeformatter.append(filename, filemode.regular_file, blobobjectid); eventually objectinserter.insert( treeformatter ); and @ end setting final tree commit. works commits others although files there can't push repo. bash says: error: unpack failed: error invalid tree (tree number): incorrectly sorted i found out here tree entries sorted byte sequence comprises entry name. however, purposes of sort comparison, entries tree objects compared if entry name byte sequence has trailing ascii ‘/’ (0x2f). so tried add files particular order based in conversion bytes of object name (not file name), comparing actual commits bash, can't figure out order git need add files. so: knows how use plumbing methods in jgit construct commit several files? pretty sure need correct way of sorting objects can&

html - bxslider adds a width of 1366px to slided element even if setup smaller with css -

i trying implement bxslider make content slide! even if content div written <div id="content"> bxslida convert some <div id="content" style="width: 715%; position: relative; transition-duration: 0s; transform: translate3d(-1366px, 0px, 0px);"> and add more <div class="bx-clone" style="float: left; list-style: outside none none; position: relative; width: 1366px;"> ...and sucks because provides new width of 1366px, if content div correctly setup @ 960px css. any idea of do? thanks

Bug in Turn Based Multiplayer Game Center In iOS 8.3 -

i want make turn based mutiplayer puzzle type game.it's works fine functionality inlcuding notification of player' turn end.but in ios 8.3 can't delegate method calld while player turn end .any solution? i registered listener.but it's not called.here code.. - (void)authenticatelocaluser { if (!gamecenteravailable) return; nslog(@"authenticating local user..."); if ([gklocalplayer localplayer].authenticated == no) { __weak typeof(self) weakself = self; __weak gklocalplayer *weakplayer = [gklocalplayer localplayer]; weakplayer.authenticatehandler = ^(uiviewcontroller *viewcontroller, nserror *error) { if (viewcontroller != nil) { [weakself showauthenticationdialogwhenreasonable:viewcontroller]; } else if (weakplayer.isauthenticated) { // player has been authenticated! [weakplayer unregisteralllisteners]; [weakplayer registerlis

php - Multiple select option selected will be view in another html element using javascript or jquery -

i have multiple select option on html : <div class="control-group"> <label class="control-label" for="selecterror1">ditujukan untuk :</label> <div class="controls"> <select id="email" multiple data-rel="chosen" class="input-xlarge" name="email[]"> <?php foreach ($atasan $data) { echo "<option value='" . $data['email'] . "'>" . $data['email'] . "</option>"; } ?> </select> </div> </div> my goal is, when user selected or option, option selected view in html element <p id='emailsend'>this email : email1, email2... on</p . i newbie in jquery. guess 'on change' or change can this. this jquery's code: $(document).ready(function() {

javascript - How to remove the content from a "div" element using a button "onclick" function? -

i have div element contains number of images. when user clicks button, want contents of div removed (not div itself, want reuse div potentially add new content). in html, div , button defined as: <body> ... <div class="mydiv"></div> ... <button id="removediv" onclick="removedivfunction()">remove div function</button> ... </body> how write function removes elements div ? you have call removechild : function removedivfunction() { mydiv.parentnode.removechild(mydiv); }

node.js - nodejs - express how it is possible to make the global variables on all routes? -

how possible make lang global on routes ? ex: app.post('/set/lang',function(req,res){ req.lang = 'en'; res.json({lang:'en'}); }); app.get('/get/lang',function(){ res.json({lang:req.lang}); }); but return // {lang:undefined} ?? how can this? > /get/lang => return {lang:en} req.lang undefined becasue request /get/lang stateless , not know state of request done on /set/lang . what need here session service such https://github.com/expressjs/session you may want read more here http://expressjs-book.com/forums/topic/express-js-sessions-a-detailed-tutorial/ my understanding being want save user language foreach user , let them set via sort of language selector in client app. note also, question confusing may refer global named parameters in expressjs implement https://github.com/expressjs/express-params . or, may refer input content validation, see more @ http://expressjs.com/4x/api.html#app.param finally version no

scala - Handle services returning Try values in Spray -

i working on codebase calling spray api need synchronously call service returns try spray need format , return on http. my initial attempt looked : // assume myservice has run method returns try[unit] lazy val myservice = new service() val routes = path("api") { { trytocomplete { myservice.run() } } } ~ path("api" / longnumber) { (num: long) => { trytocomplete { myservice.run(num) } } } def trytocomplete(result: => try[unit]): routing.route = result match { case failure(t) => complete(statuscodes.badrequest, t.getmessage) case success(_) => complete("success") } however caused myservice.run() called when application started. not sure why method called there no http call made. so have 2 questions : why service being called part of initialising routes? what cleanest way handle case? imagine there few other end points following similar pattern. need able ha

postgresql - Converting time datatype to xxhxxmxxs -

i wonder if there function in postgres can convert values stored 00:00:00 more human friendly format: 3h 5m ? you can use to_char function: select to_char(cast('05:03:00' time), 'hh24h mim sss'); this produce 05h 03m 00s

c# - Using ViewData to pass data from Controller to View -

i'm trying passing data controller view, , display these datas. after many tries can't. controller code : public actionresult validsearch(productsearchparam gp) { if (gp.iscandidate) { viewbag.abc="bob"; list<productcandidate> prodclist = new list<productcandidate>(); prodclist = pcs.searchparam(gp,0,100); viewbag.total = prodclist.count; return view("validsearchcandidate", prodclist); } else { list<product> prodlist = new list<product>(); prodlist = ps.searchparam(gp,0,100); viewbag.total = prodlist.count; return view("validsearch", prodlist); } //return view(); } view code : <body> <div> <p>bonjour @viewbag.abc</p> i've try tempdata or viewbag, unsuccessfully. i not understand why value not getting passed view correctly can me solve ? since have set pro

javascript - PHP query execute without error but return count 0 -

i creating login in angularjs, in login.phppage verify whether user exist or not number of rows exist or not means using rowcount() in php pdo return 0 result. here php file: <?php /* * collect details angular http request. */ $postdata = file_get_contents("php://input"); $request = json_decode($postdata); $email = $request->email; $pass = $request->password; $user ="root"; $pass ="m2n1shlko"; $dbh = new pdo('mysql:host=localhost;dbname=blog_db', $user, $pass); $query = $dbh->prepare("select * `signup_tbl` `email`='$email' , `password`='$pass'"); $query->execute(); $count = $query->rowcount(); if($count>0){ echo "you have sucessfully login email: ".$count; //this go under "data" of angular call. }else{ echo "error while authentication email: " .$count; } /* * can use $email , $pass further work. such database call

Jquery table to Excel is not working in Firefox and IE -

i using below code export table excel. it working fine in chrome, it's not working in firefox , ie. $("#exportbutton").click(function(e) { var table_div = document.getelementbyid('availablepeopletable'); var table_html = table_div.outerhtml.replace(/ /g, '%20'); a.href = data_type + ', ' + table_html; a.download = 'availability_report_' + postfix + '.xls'; //triggering function a.click(); //just in case, prevent default behaviour e.preventdefault(); }); can me this?

python - Subtract datetime in Django - no output -

i want "age" of user account in django app. did: class userdata(models.model): user = models.foreignkey(user,unique=true) birth = models.integerfield(default=1900) gender = models.charfield(max_length=1) @property def isnew(self): if (datetime.datetime.now()-self.user.date_joined) < datetime.timedelta(days=40): return true; else: return false; in template there different view depending on output of function. there no output. when "printing" output there nothing returned. when returning "datetime" , "date_joined" date shown. when returning str(type()) of both "datetime.datetime" returned. when returning difference (or type of difference) there absolutely nothing returned. when doing same in python console there timedelta returned - expect. any idea search next? can't figure out what's happening prevent function giving output without crashing app.

java - form.submit not working while file upload in ExtJS -

i using extjs 4.2.0 uploading file functionality. when try upload using form.submit(), gives me extjs error , service not called. below code form panel: ext.define('modelname.view.attachdocumentpanel', { extend: 'ext.form.panel', alias: 'widget.attachdocumentpanel', id: 'attachdocumentpanel', itemid: 'attachdocumentpanel', name: 'attachdocumentpanel', height:25, layout:'column', requires: [ 'modelname.common.util' ], initcomponent: function() { var me = this; ext.applyif(me, { items: [ { xtype: 'filefield', itemid: 'fileuploadfield', id: 'fileuploadfield', name: 'fileuploadfield', emptytext : 'select file upload', msgtarget: 'side',

unique constraint violated even if there is no primary key oracle -

getting error ora-00001 on oracle database while trying insert new record. there no primary key in table error description : unique constraint violated if there no primary key oracle. there unique index causing error

c# - Wpf Tooltip Object reference error -

i trying set tooltip textbox progamatically,but keep getting error: an exception of type 'system.nullreferenceexception' occurred in e-learning.exe not handled in user code error :object reference not set instance of object. the code: tooltip tt = new tooltip(); tt.content="introduceti adresa url videocipului"; loca.tooltip = tt; any ideas how can set tooltip ? sorry if wasn't enough. p.s "loca" name of textbox

How to call Outlook's Desktop Alert from VBA Code -

i have outlook 2003 running on win xp. desktop alert turned on , running smoothly. but created vba macro sorts incoming emails several different folders (via item_add event in thisoutlooksession). somehow stopped desktop alert showing. is there way call desktop alert vba code manually? maybe function of sorts. p.s: can't sort emails through rules, that's not option basically i'm looking regex 6 digit code in email code (sorry, it's bit of patchwork other pieces of code found on internet option explicit private withevents olinboxitems items private sub application_startup() dim objns namespace set objns = application.session set olinboxitems = objns.getdefaultfolder(olfolderinbox).items set objns = nothing end sub private sub olinboxitems_itemadd(byval item object) on error resume next dim targetfolder outlook.mapifolder dim myname string dim reg1 regexp dim m1 matchcollection dim m match set reg1 = new regexp myname = "[myname]" ' \s*

Mercurial - how to find first commit on specific branch -

i wan't determine age of "foo" branch. understand impossible info straight. trying write command find information first commit on "foo" branch. hg log -r "parents(min(branch(foo)))" this 1 returns not want. can me? does give need? hg log -r "branch(default) , 0:" -l 1 --template "{date|isodate}\n" i think gives date of first changeset on named branch. so, first changeset on branch "testbranch" % hg log -r "branch(testbranch) , 0:" -l 1 changeset: 107:bd91c8e6fa5f branch: testbranch user: nick pierpoint date: fri may 15 15:16:44 2015 +0100 summary: test 1 ... adding template date: % hg log -r "branch(testbranch) , 0:" -l 1 --template "{date|isodate}\n" 2015-05-15 15:16 +0100 your min works if want return single changeset: % hg log -r "min(branch(testbranch))" changeset: 107:bd91c8e6fa5f branch: testbranch user:

osx - Right way to define NSManagedObjectContext? -

earlier in apps coredata used define nsmanagedobjectcontext way: class myviewcontroller: nsviewcontroller { lazy var moc: nsmanagedobjectcontext? = { let app = nsapplication.sharedapplication().delegate as! appdelegate if let moc = app.managedobjectcontext { return moc } else { return nil } }() // .... } but downloaded apple's sample app called eartquakes , there nsmanagedobjectcontext that: import cocoa class coredatastackmanager { class var sharedmanager: coredatastackmanager { struct singleton { static let coredatastackmanager = coredatastackmanager() } return singleton.coredatastackmanager } // persistenstorecoordinator etc... and in viewcontroller: class applesviewcontroller: nsviewcontroller { private lazy var managedobjectcontext: nsmanagedobjectcontext = { let moc = nsmanagedobjectcontext(concurrencytype: .mainqueueconcurren

MATLAB vision.TextInserter does not insert text -

Image
i trying insert text message image. not display , no error. close clear clc hvideoplayer = vision.videoplayer; hvideofilereader = vision.videofilereader; hvideofilereader.filename = 'img1.jpg'; frame = step(hvideofilereader); hcsc = vision.colorspaceconverter; hcsc.conversion = 'rgb intensity'; frame = step(hcsc, frame); @ = vision.autothresholder; frame = step(at, frame); ccl = vision.connectedcomponentlabeler; [l num] = step(ccl, frame); holeobjcount = 0; i=1:num framei = changem(l==i, 1, i); framei = imcomplement(framei); [li numi] = step(ccl, framei); if numi > 1 holeobjcount = holeobjcount + 1; end end message = sprintf('%d of %d objects have holes.', holeobjcount, num); disp(message); osdmsg = vision.textinserter('%d of %d objects have holes.',... 'color', uint8([255, 255, 255]), ... 'location', [10 10],...

g++ - How can I find wich part of my code is associated with an entry in the symbol table? -

i working on project needs executed in linux machine has turned out not have glibcxx_3.4.20 version of library, code needs it. there anyway find part of code (c++) asks version? i read elf file using objdump , realdef , found symbol needs it: _zst24__throw_out_of_rang@glibcxx_3.4.20 (4) don't know part of code can related. your question duplicate of this question . except in case, it's not libc.so.6 , libstdc++.so that's giving trouble. your problem compiling new gcc, running on machine old libstdc++.so . you have few options: you can update target machine have new enough libstdc++.so you can build using older version of gcc you use -static-libstdc++ flag link required version of libstdc++ directly application. make larger binary, not using libstdc++.so @ all. note if link against other shared libraries do link against libstdc++.so , binary may not run correctly on target machine, solution should used caution.

html - Responsive menu not working when jquery.mobile is active -

i'm going through jquery mobile docs , , i'm not sure how handle page loading. i have web page, , i'd have swipeable menu when i'm on mobile view (<767px). loaded jquery.mobile.js, , simple $(window).on('swiperight', function(){ $menu_toggle.addclass('mobile_open'); $navigation.fadein().animate({width: '80%'},250); }); $(window).on('swipeleft', function(){ $menu_toggle.removeclass('mobile_open'); $navigation.animate({width: '0' },250).fadeout(); }); i displaying menu. menu toggle classic 'hamburger' menu works if click on it. the swipe works, when wipe right, menu opens, , when swipe left menu closes. however problem when click on link in menu, won't take me page. option, , where, should set enable behavior? or there other way of using swipe motion open menu, without jquery.mobile.js? edit: added fiddle, alth

git - Squash commits into one commit -

i want squash commiets 1 commit. here example. git log --pretty=oneline c4101e... removed conflict 04830f... t2345 - [bug fix1] 16d19f... t2272 - [bug fix2] my requirement is, code changes done in c4101e (latest commit) , 16d19f (3rd commit) treated one. this c4101e... removed conflict , t2272 - [bug fix2] 04830f... t2345 - [bug fix1] thanks in advance. you can use git rebase that. git rebase -i head~3 , ignore commit in middle. check http://git-scm.com/docs/git-rebase , git rebase -i

excel - Python script to convert xls to csv with non-ascii -

i have script see below works fine when xls contains ascii data. i've tried adding utf-8 @ various points script still falls on when xls contain non-ascii. #!/usr/bin/env python import xlrd import csv book = xlrd.open_workbook('/users/admin/documents/pythonscripts/an_excel_file.xls') # assuming fist sheet of interest sheet = book.sheet_by_index(0) # many options here control how quotes handled, etc. csvwriter = csv.writer(open('/users/admin/documents/pythonscripts/a_csv_file.csv', 'w'), delimiter=',') in range(sheet.nrows): csvwriter.writerow(sheet.row_values(i)) any ideas how add in? this how solve problem utf-8 data. hope helps your_csv_file = open('myfile.csv'), 'wb') wr = csv.writer(your_csv_file, quoting=csv.quote_all) rownum in xrange(worksheet.nrows): wr.writerow([unicode(entry).encode("utf-8") entry in worksheet.row_values(rownum)]) your_csv_file.close() you can prefer source code

Transpiling Javascript to Javascript replacing objects and methods -

is possible convert js file containing object myobject method mymethod1() : myobject.mymethod1(): to js file object yourobject method yourmethod() this: yourobject.yourmethod2(); one of possible ways writing file manipulation program 1 replace occurrences using regex or simple text search referring sample file, naive , eager know if there other possibilities. writing generic javascript library produces same interface different libraries each library having different methods internally implement same functionality. eg, if library has object a1 method foo , library b has object b1 method bar , foo , bar internally implement same functionality, trying create solution wherein calling method meh on object s1 call either a1.foo() or b1.bar() based on simple configuration. this very difficult achieve myobject.mymethod1() is equivalent myobject['mymethod1']() where string 'mymethod1' result of arbitrary expressions , variables, impossible trace i

angularjs - Angular ui-calendar => How to use gotoDate? -

what want is, when open scheduling page, calendar must show date based on date supplied , view must in month view. came solution using fullcalendar's gotodate function. problem doesn't seem work. here code: controller if($stateparams.displayeddate != '') { $('#calendar').fullcalendar('gotodate', $stateparams.displayeddate); } view <div id="calendar" ui-calendar="calendarconfig" ng-model="eventsources"></div> well, code above didn't work tried approach. changed codes in controller if($stateparams.displayeddate != '') { $scope.calendar.fullcalendar('gotodate', $stateparams.displayeddate); } but error occured saying "calling function undefined object ...... etc ..." i'm using, angularjs 1.2, angular ui-calendar 1.0, fullcalendar 2.3.1 note: supply $stateparams date in format "yyyy-mm-dd" eg. 2015-02-15 edit update it seems can't ac

php - Rewrite Rule not catching strings -

this rewrite rule works fine number variables, not work strings rewriterule ^\d+$ user.php?user=$0 [l,qsa] who make rule accepts example: www.mydomain.com/user/ andremendes right accepts if user/12334 or number. how make accepts strings , numbers? try : rewriterule ^([a-za-z0-9_-]+)/?$ user.php?user=$1 [l,qsa] to match alphanumbric characters in uri need following regex pattern. [a-za-z0-9_-]

javascript - how to return animation to it's original size and position on a click -

i relatively new if see doing wrong, or anyways simplify code please not hesitate say. i have following code enlarge div element: var profilepostsclick = function () { $('.largebox, .smallbox, .longbox').click(function () { $(this).animate({ width: '100%', height: '40%' }, 200); $('.closepost', this).removeclass('closeposthide'); }); }; $(document).ready(profilepostsclick); https://jsfiddle.net/jvkhmpbt/ i wanting close each div when cross clicked, returning it's original size , positioning (with height: auto if feasible). aslo there way make each div opens above smaller ones? (like top left div does, aware because of it's positioning) thanks you save animation properties/values in cache-object , restore them after animation. http://jsfiddle.net/jvkhmpbt/4/ var animationresetcache = []; var savevalues = function (node) { animationresetcache.push({

python 2.7 - How exactly do the hashlib hashers treat input? -

the python 2.7 documentation has hashlib hashers: hash.update(arg) update hash object string arg. [...] but have seen people feed objects not strings, e.g. buffers , numpy ndarrays . given python's duck typing, i'm not surprised possible specify non-string arguments. the question is: how know hasher doing right thing argument? i can't imagine hasher naïvely doing shallow iteration on argument because fail miserably ndarrays more 1 dimension - if shallow iteration, ndarray n-1 dimensions. update unpacks arguments using s# format spec . means can either string, unicode or buffer interface . you can't define a buffer interface in pure python, c libraries numpy can , - allows them passed hash.update . things multiple dimension arrays work fine - on c level they're stored contiguous series of bytes.

Android WebView error when showing bold text -

i calling http://www.createtrips.com/legal/about-us in app browser on android devices, shows bolder, not show text bolder. i using: //show info mwebviewsettings.setwebviewclient(new webviewclient() mwebviewsettings.getsettings().setjavascriptenabled(true); mwebviewsettings.getsettings().setloadsimagesautomatically(true); mwebviewsettings.setscrollbarstyle(view.scrollbars_inside_overlay); mwebviewsettings.loadurl(linkpage); follow google webfonts not working using web view in android 4.0 , 4.2.2 . the answers above valid , give insight subject, moallemi , vaiden those. cannot use web fonts on android 4.0 shame. the solution our problem webfonts on android 4.2 related fact in css google uses include actual font files specify format. means in google's css have code like: src: url(" http://some.google.server/some/path/fontname.ttf ") format('ttf'); turns out fonts don't render in webview on an

php - Mysqli SUM(row count *20) -

i've searched high , low answer 1 , have managed confuse myself further. what need quite simple: $row2 row count of 'agent_name' , 'office' belongs particular group defined in table, functions expected, need $paygtotal display sum of count *20 i managed create complex join establish true count , i'm stuck on simple sum() if simple $paygtyotal = [$row2[0] *20] $paygcount = "select count(*) enabled_boards agent_name='$paygagent' , office='$paygoffice' "; $query = mysqli_query($conn, $paygcount) or die (mysqli_error()); $row2 = mysqli_fetch_row($query); mysqli_free_result($query); **$paygtotal = ???** $payglist.='<div id="payga" class="fluid">' . $paygagent . '</div> <div id="paygo" class="fluid">' . $paygoffice . ' </div> <div id="paygc" class="fluid center">' . $row2[0] . '</div&

java - FilesAlreadyExistsException when using Files.copy() on File.createTempFile() -

i'm using jsf <h:inputfile> upload images server. <h:form enctype="multipart/form-data"> <h:inputfile value="#{filehandlerbean.file}"/> <h:commandbutton action="#{filehandlerbean.uploadimage()}"/> </h:form> i created virtual host /projectname/webapp/images . can create files folder. private part file; public string uploadimage(){ inputstream = null; try { string extension = filenameutils.getextension(file.getsubmittedfilename()); file tempfile = file.createtempfile("picture-", "."+extension, new file("/projectname/webapp/images")); logger.getlogger("file size").warning(string.valueof(file.getsize())); logger.getlogger("file extension").warning(extension); = file.getinputstream(); logger.getlogger("stream available size").warning(string.valueof(is.available())); files.copy(is, tempf

c# - Unexpected results for floating point equals -

question not why 0.1 + 0.9 not equals 1.0 . different behaviour of equals. can explain why examples below works differently. float q = 0.1f; float w = 0.9f; float summ = q + w; q + w == 1.0f; // false summ == 1.0f; // true why operator == works differently? the problem due fact intermediate calculations being performed in higher precision, , rules when round float precision different in each case. according the docs by default, in code x86 architectures compiler uses coprocessor's 80-bit registers hold intermediate results of floating-point calculations. ... compiler performs rounding on variables of type float correct precision assignments , casts , when parameters passed function" float summ = q + w assignment, , hence rounded nearest float , in case 1. q + w == 1.0f neither cast, assignment or function call, result of addition still extended precision float, close, not equal, 1.

php - Getting currently active menu title in wordpress -

i need active menu item (menu title home, us, etc..) on each page in wordpress. using wordpress codes display menu & displayed correctly. code shown below, $menu_name = 'primary'; if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $menu_name ] ) ) { $menu = wp_get_nav_menu_object( $locations[ $menu_name ] ); $menu_items = wp_get_nav_menu_items($menu->term_id); $menu_list = '<ul id="menu-' . $menu_name . '" class="nav navbar-nav" style="width:100%;">'; foreach ( (array) $menu_items $key => $menu_item ) { $title = $menu_item->title; $url = $menu_item->url; $menu_list .= '<li class="menu-line"><a href="' . $url . '">' . $title . '</a></li>'; } $menu_list .= '</ul>'; } else { $menu_list = 

google chrome - Only Cookie JSESSIONID set from first Login request is not sent in subsequent requests? -

i not able understand what's going on. on 1 of env. of webapp (written using extjs 4.0) - see login request completes subsequent request fails 401. when digged bit more found in browser(f12) 1st request's response header has jsessionid, set cookie, 2nd request doesn't send in request headers. that's why 2nd request creates new session , returns new jsessionid. in client code request sent, ext.ajax.request({url:'', callback..}) - there no explicit setting of jsessionid or cookie. strange part not cookie keys missing, jsessionid, means cookies not disabled , set browser. why browser not sending jsessionid? tried in firefox/chrome both. also happening in local env., qa env. of webapp working fine. i figured out myself.. issue http://tomcat.apache.org/migration-7.html#session_cookie_configuration thanks people spent time reading question.

stub - Convert java version 1.8 to 1.7 compatible -

just clear not java developer. i have java code written version 1.8. however, java.util.function not available in version 1.7 hence not able compile code. how can compile\convert code make compatible version 1.7 compiler? below code import java.util.*; import java.util.function.predicate; public list<personsearchresult> searchpersonlistasperson( person bean, short minscore, int maxresults, string cvwname, person.personsource[] sources, person.personattribute[] attributes) throws masterdataserviceexception { logservicebegin(log, "searchpersonlistasperson"); personmapper mapper = new personmapper(); list<personsearchresult> searchresults = searchforrecordlist( mapper, bean, personentityid.getstaticenttype(), minscore, maxresults, cvwname, sources, attributes); if(searchresults != null && searchresults.size() > 1) { personpredicate ppredicate = new personpredicate();

arrays - Trying to make a world mesh that I can change at will c++ OpenGL -

so, have project trying build. goal have list of gl_quads hold level structure. want able add , remove cubes list , have opengl render it. my problem arrays dont seem expandable. have allready written code allows me press space , create cube, need someway create make array of points creates cube longer @ will. if there way expand arrays needed ears. here of code... might not need @ answer question. have sudo coded out irrelivant sections. #include <gltools.h> #include <glmatrixstack.h> #include <glframe.h> #include <glfrustum.h> #include <glbatch.h> #include <glgeometrytransform.h> #include <math.h> #ifdef __apple__ #include <glut/glut.h> #else #define freeglut_static #include <gl/glut.h> #endif // assortment of needed classes glshadermanager shadermanager; glmatrixstack modelviewmatrix; glmatrixstack projectionmatrix; glframe cameraframe; glframe objectframe; glfrustum

rest - Why do i get HttpMediaTypeNotAcceptableException? -

i have springboot rest controller: @restcontroller public class usercontroller { @autowired userrepository userrepository; @requestmapping(value = "/account/{userid:.+}", method = requestmethod.get) public httpentity<account> getaccountbyuserid(@pathvariable string userid) { if(userid == null) { return new responseentity<>(httpstatus.bad_request); } account user = userrepository.findonebyuserid(userid.tolowercase()); if(user == null) { return new responseentity<>(httpstatus.not_found); } return new responseentity<>(user, httpstatus.ok); } } note @pathvariable definition weird because spring mvc @pathvariable dot (.) getting truncated . this call works , receive 200 status code lovely json: http://.../account/scarlett.j@myplace.com however call http://.../account/scarlett.j@myplace.com.au returns status code 406 , debug logs show message "org.sprin

python - how to get the user entered input -

iam beginner python started trying simple programs , below code 1 in .getting user entered input , printing it.and running code in local host http://localhost/cgi-bin/ex3.py given below code simple python code #!"c:\python34\python.exe" import cgi, cgitb cgitb.enable() print("content-type: text/html;charset=utf-8") print() print ("enter file name:") = int(input("enter input")) print (a) but it's giving error as d:\xampp\cgi-bin\ex3.py in () 6 print() 7 8 print ("enter file name:") => 9 = int(input("enter input")) 10 print (a) undefined, builtin int = <class 'int'>, builtin input = <built-in function input> eoferror: eof when reading line args = ('eof when reading line',) with_traceback = <built-in method with_traceback of eoferror object> if program expects file name (string) don't need cast integer. print ("e

ios - How to stop a UIScrollView from scrolling when it reaches the bottom -

Image
i have following code in place grab event when uiscrollview reaches end of content view: - (void) scrollviewdidenddecelerating:(uiscrollview *) scrollview { float currentendpoint = scrollview.contentoffset.y + scrollview.frame.size.height; // cgpoint bottomoffset = cgpointmake(0, scrollview.contentsize.height - scrollview.bounds.size.height); // [scrollview setcontentoffset:bottomoffset animated:no]; if (currentendpoint >= scrollview.contentsize.height) { // @ bottom i notice when scroll bottom hits , bounces up. if add this: cgpoint bottomoffset = cgpointmake(0, scrollview.contentsize.height - scrollview.bounds.size.height); [scrollview setcontentoffset:bottomoffset animated:no]; then scroll goes bottom. is there way stay @ bottom without "bounce up" in once hits bottom, stop moving. thanks. you should uncheck bounce property of scrollview. check screenshot!

xml - About servlet Exception -

web.xml <?xml version="1.0" encoding="utf-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> <display-name>servletexceptionhandling</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> <error-page> <error-code>404</error-code> <location>/appexceptionhandler</location> </error-page> <error-page> <exception-type>javax.servlet.servletexception</exception-type> <location>/appexceptionhandler</location> </error-page> <error-page> <exception-type>java.lang.throwable</exception-type> <location>/appexceptionhandler</location>

javascript - Cannot call AJAX when using layout -

in view, define js function function gettime() { $.ajax({ url: '/diseases/tellmedate', success: function (data) { //alert("abc"); $('#rdata').html(data) }, complete: function () { settimeout(gettime, 1000); } }) } after that, call gettime fuction <div class="meta"> <p id="rdata"></p> <script> gettime(); </script> </div> it works when don’t call layout. if call layout, not work. @{ viewbag.title = "chuẩn Ä‘oán bệnh"; //layout = "~/views/shared/_pagelayout.cshtml"; } can give me solution?

javascript - Facebook share button not showing the thumbnail image? -

Image
i'm confused. have og tags: <!doctype html> <html class="no-js" lang="en-us"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta property="og:image" content="http://www.chineselearnonline.com/wp-content/themes/clo/assets/img/images/clo-fb-white.png"> <meta property="og:title" content="chinese learn online | progressive mandarin course"> <meta property="og:description" content="see why thousands of students raving unique, progressive immersion method learn mandarin chinese."> it shows fine on facebook debugger: but don't see thumbnail preview: what problem? facebook button code: <div id="fb-root"></div> <script>(function(d,

vb.net - Accessing a namespace declared in a page code behind from another page ASP.net -

i have page default.aspx in code behind file default.aspx.vb contains partial class , namespace called mynamesspace. default.aspx.vb file this imports mynamespace partial class default2 inherits system.web.ui.page end class namespace mynamespace public class status public id, score integer public names string public function checkscore() integer return 1 end function end class end namespace but how can access same namespace in page code behind mypage.aspx? or not permitted? absolutely can that. since code behind file nothing class, mypage.aspx code behind file can create instance of class , use it:- dim cust new customer() dim result1 integer = cust.checkscore() but suggest create separate class instead of mixing code behind class. or not permitted? as have explained this, here can remember code behind file well. since class can have number of classes in code behind file either in same namspace or

c - Why socklent_t * is used in accept() in socket programming? -

in c socket programming accept() declaration looks like: int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen); i can understand uses of sockfd , struct sockaddr *addr . but why have pass address of length of socket, have been socklen_t . because if accept() function needs length can socklen_t . why protype of function declared in such way? so reason behind using socklen_t * type? in code that's agnostic address/protocol family of socket it's accepting from, may using generic sockaddr_storage structure hold result. initial value of pointed-to socklen_t size of storage; value after accept returns actual size of resulting peer address. also, address/protocol families af_unix have variable length addresses, if know type may not know size.

php - Video working in Chrome but not Firefox -

i can videos play in chrome embed tags towards bottom of page, have them commented out. anyway, doesn't work firefox , can't find way display , play video database. within div tag, myelement , if type location of video on computer, it'll load right up, i'm wanting video off db $url , every time try, says 'a plugin needed display content or no video found.' i've tried using <video> , didn't seem work either. <!doctype html> <html lang="en"> <head> <meta content="text/html; charset=utf-8" http-equiv="content-type" /> <title>watch</title> <script src="http://jwpsrv.com/library/6qvxzpkveeskjwp+lcgdiw.js"></script> <script src="jwplayer/jwplayer.js" ></script> <script>jwplayer.key="7sydcohxpeaicfiaz4rxdkkgf+fcssszrydb2q==";</script> </head> <body> <div id="myelement">loading player.

java - Why class/object name must be explicitly specified for method references? -

when want refer method in current scope still need specify class name (for static methods) or this before :: operator. example, need write: import java.util.stream.stream; public class streamtest { public static int trimmedlength(string s) { return s.trim().length(); } public static void main(string[] args) { system.out.println(stream.of(" aaa ", " bb ", " c ") .maptoint(streamtest::trimmedlength).sum()); } } it's not big problem this , overcrowded static methods class name can quite long. nice if compiler allowed me write ::trimmedlength instead: public static void main(string[] args) { system.out.println(stream.of(" aaa ", " bb ", " c ") .maptoint(::trimmedlength).sum()); } however java-8 compiler doesn't allow this. me seems quite consistent if class/object name resolved in same manner it's done normal method call. support sta