Posts

Showing posts from February, 2011

javascript - How to select Default folder location in File Upload Control? -

i want set default path folder location has opened, once press "browse" button in file control. please me. this forum says can't done. you wanting control directory location browse starts in , not save path file uploaded to, correct? i wrong since server never knows file structure of client machine, developers of control did not provide functionality.

backbone.js - Reload the page to get source for: http://localhost:8080/PSWebServices/services/EmpDetails -

hi facing issue while accessing response restful ws using backbone. i have created ws on local machine returning json array jsonarray empdatajsonarray = new jsonarray(); jsonobject empdata = new jsonobject(); try { empdata.put("id", emp.getempid()); empdata.put("firstname", emp.getfname()); empdata.put("lastname", emp.getlname()); empdata.put("age", emp.getrcount()); empdata.put("city", emp.getcity()); empdata.put("country", emp.getcountry()); } catch(jsonexception jsonex) { throw jsonex; } return empdatajsonarray.put(empdata); when access ws browse. http://localhost:8080/pswebservices/services/empdetails i result [{"id":"033451","firstname":"naveen","lastname":"kapoor","age":10,"city":"bangalore","country":"...

qt - How to add an event handler for dynamically created QML elements? -

i dynamically added qml components gui according this blog post . how can add event handlers newly created components? i'll explain example. 1)create custom button component follows //button.qml ... component's objects dynamically // created import qtquick 2.1 rectangle { width: 100 height: 50 color:"blue" //since buttons created on fly, //we need identify button on user // has clicked. id must unique property string buttonid; signal clicked(string buttonid); mousearea { anchors.fill: parent onclicked:parent.clicked(parent.buttonid) } } this simple button emits clicked signal on clicking on it.. lets create buttons on fly. //main.qml ... creates buttons on fly import qtquick 2.1 rectangle{ id:root width:500 height:500 function buttonclicked(buttonid) { console.debug(buttonid); } function createsomebuttons() { //function creates 4 buttons ...

ios - how to save the image in system which is captured from UIGraphicsGetImageFromCurrentImageContext() in iPhone? -

hi want capture current uiview image , store in local hard disc how can achieve: example : uigraphicsbeginimagecontext(self.superview.frame.size); [self.layer renderincontext:uigraphicsgetcurrentcontext()]; uiimage *backgroundimage = uigraphicsgetimagefromcurrentimagecontext(); i want store uiimage in local drive in of png, jpeg format. how can one. kindly me out. in advance. the following code may achieve. uigraphicsbeginimagecontext(self.superview.frame.size); [self.layer renderincontext:uigraphicsgetcurrentcontext()]; uiimage *image = uigraphicsgetimagefromcurrentimagecontext(); nsstring *stringpath = [[nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes)objectatindex:0]stringbyappendingpathcomponent:@"new folder"]; // new folder folder name nserror *error = nil; if (![[nsfilemanager defaultmanager] fileexistsatpath:stringpath]) [[nsfilemanager defaultmanager] createdirectoryatpath:stringpath withintermediatedirectori...

sql server - Convert a given datetime to UTC time based on time zone description in SQL -

i have data following. first column of type datetime , , second column corresponding time zone info, , of type nvarchar . 07/04/2012 14:20:45 eastern standard time 07/04/2012 13:55:10 indian standard time 07/04/2012 10:55:00 central standard time how can convert datetime column value of rows utc time? try this update dbo.yourtable set datetimecolumn=case timeshift when n'eastern standard time' dateadd(hour,easterntimeshift,datetimecolumn) when n'indian standard time' dateadd(hour,indiantimeshift,datetimecolumn) ... else datetimecolumn end

lubridate - How to extract Month from date in R -

i using lubridate package , applying month function extract month date. ran str command on date field , got factor w/ 9498 levels "01/01/1979","01/01/1980",..: 5305 1 1 1 1 1 1 1 1 1 ... > v1$date<-month(v1$date) error in as.posixlt.character(as.character(x), ...) : character string not in standard unambiguous format here example of data frame https://drive.google.com/file/d/0b6cqwmwsek20q2dhblhxzi14wk0/edit?usp=sharing i don't know doing wrong. ?month states: date-time must posixct, posixlt, date, period, chron, yearmon, yearqtr, zoo, zooreg, timedate, xts, its, ti, jul, timeseries, , fts objects. your object factor, not character vector (presumably because of stringsasfactors = true ). have convert vector datetime class, instance posixlt : library(lubridate) some_date <- c("01/02/1979", "03/04/1980") month(as.posixlt(some_date, format="%d/%m/%y")) [1] 2 4 there's convenience f...

c# - Serialization in Entities -

hi have following entity employee --------- emp_id report_id last_name first_name ----------navigation properties employee1 employee2 it has foreign key relation same table emp_id , report_id when run webapi created keep getting error <message>an error has occurred.</message> <exceptionmessage> 'objectcontent`1' type failed serialize response body content type 'application/xml; charset=utf-8'. </exceptionmessage> <exceptiontype>system.invalidoperationexception</exceptiontype> <stacktrace/> <innerexception> <message>an error has occurred.</message> <exceptionmessage> object graph type 'cm.entities.employee' contains cycles , cannot serialized if reference tracking disabled. </exceptionmessage> <exceptiontype> system.runtime.serialization.serializationexception </exceptiontype> spent alot of time on cant seem figure out how shake off error. please help. you n...

cordova - phonegap ajax user authentication with nodejs-expresss-mongo-passportjs -

i have built basic node.js user authentication system based on node.js, express.js, passport-local. i store username , passwords in mysql database , use mongo persistent storage sessions. want move user registration , login phonegap. from tutorials have found online, way seems work is ajax user authentication. have 2 questions: how rewrite express routes respond json since passport.js relies on redirects? // process signup form app.post('/register', passport.authenticate('local-signup', { successredirect : '/home', failureredirect : '/register', failureflash : true // allow flash messages })); // process login form app.post('/login', passport.authenticate('local', { successredirect : '/home', failureredirect : '/login', failureflash : true // allow flash messages })); and in strategies have : passport.use('local-signup', new localstrategy({ usern...

objective c - Edit titles of `NSOutlineView` inline -

i have nsoutlineview , want able edit title of entries in list. the list seems support default error thrown hit enter: exception detected while handling key input. -[nsproxy doesnotrecognizeselector:controltextdidendediting:] called! i tried implement method in delegate did not called. i having this problem pxsourcelist think general nsoutlineview issue. this bug in pxsourcelist , fixed in version 2.0.3: https://github.com/perspx/pxsourcelist/releases/tag/2.0.3

java - How do I call C++/CLI source from JavaProject -

a java programm relies on functionality needs implemented c++/cli project too. since don't implement , maintain functionality both programming languages, i'm searching way write source once. i wrote examples yesterday evening covering implementation , c++. http://csharphardcoreprogramming.wordpress.com/2014/03/25/java-to-c-day-15-professional-call-c-from-java-call-java-from-c/ . need java native interface (jni).

How to send data to the controller from the Kendo UI TreeView -

i have 2 treeviews, 1 has list of countries, , other empty, want drag , drop selected countries second tree-view. don't know how send data controller treeview , there text field on page in form. so, how can send both form data , treeview's data controller. here code second tree-view empty , want add selected nodes to: @(html.kendo().treeview() .name("treeview-right") .draganddrop(true) .events(events => events .drag("ondrag") .drop("ondrop") ) ) please try below code snippet. html/view <div style="border: 1px solid green;"> <div id="treeview-left"></div> </div> <div style="border: 1px solid red;"> <div id="treeview-right"></div> </div> <div id="mydiv" onclick="savedata()">click me save data</div> <script> $("#treeview-left").kendotreeview({ ...

visual studio - VSIX how to order my classifier provider in respect to other installed extension -

i developed toy vsix extension. implements classifier f# source files. in meantime guys fsharp power tools upgraded extension offer syntax highlighting f# files. now in vs 2013 classifier run before theirs, , consequently overriding coloring. is there way order classifier on respect another? did not find info googling. thanks unfortunately there no way this. classification form of tagging , tagging unordered in visual studio. editor runs import tagging implementations , defaults mef import ordering. many hooks in visual studio can ordered using [order] attribute. typically listed part of documentation on msdn. not classification / tagging , checked implementation make sure wasn't oversight (it wasn't).

concurrency - Avoid inserting duplicate records in Entity Framework -

i have typical scenario users enter data inserted sql database using entity framework 6.0. however, rows part of entity need unique (already enforced unique key constraints in database). to avoid possible concurrency or performance issues favour these checks left done sql server. when attempting save new entity holds duplicate row, dbupdateexception thrown entity framework. inner exception sqlexception number equal 2627, , message reads: "violation of unique key constraint 'uk_mytable_myrule'. cannot insert duplicate key in object 'dbo.mytable'". considering there several tables involved, may each have own unique constraints defined, there no better way conclude friendlier message user reads: "a myentity name 'myentity1' exists." ...without having infer through number , message properties sqlexception? for example: try { ... context.savechanges(); } catch (dbupdateexception exception) { var sqlexception = exc...

java - my andengine gles2 game keeps on crashing -

my andengine game keep on crashing.may know correct way achieve objective? got here source https://github.com/sm4/flyingdandelion 03-24 05:14:55.817: e/androidruntime(1207): fatal exception: glthread 88 03-24 05:14:55.817: e/androidruntime(1207): process: is.kul.flappydandelion, pid: 1207 03-24 05:14:55.817: e/androidruntime(1207): java.lang.illegalargumentexception: no eglconfig found! 03-24 05:14:55.817: e/androidruntime(1207): @ org.andengine.opengl.view.configchooser.chooseconfig(configchooser.java:229) 03-24 05:14:55.817: e/androidruntime(1207): @ org.andengine.opengl.view.configchooser.chooseconfig(configchooser.java:203) 03-24 05:14:55.817: e/androidruntime(1207): @ android.opengl.glsurfaceview$eglhelper.start(glsurfaceview.java:1024) 03-24 05:14:55.817: e/androidruntime(1207): @ android.opengl.glsurfaceview$glthread.guardedrun(glsurfaceview.java:1401) 03-24 05:14:55.817: e/androidruntime(1207): @ android.opengl.glsurfaceview$glthread.run(glsurfacevie...

using matlab to solve plotting function -

i've been asked plot function f( x ) = ( x ^2 - 3x + 7) / (sqrt(2x +5)) for -1< x <5 how go starting this? thanks all matlab works arrays (matrices actually). first, need create array x values: x = -1: 0.01: 5 where 0.01 interval between consecutive values. then need calculate y values. y = (x.^2 - 3*x + 7) ./ (sqrt(2*x + 5)); this quite straightforward. thing need notice dots. .* , ./ operators work element-wise (which need, since want calculate square of values). if instead typed x^2 , mean matrix multiplication of x itself, produce wrong values in case. finally, plot it: plot(x, y, '.b'); x , y obvious. last part refers color , style of line. in case mean blue dots. other styles see matlab line styles .

Excel Performance Form control vs Event / Call -

i have script like: sub pivpaint() clearclipboard dim amaxrows long dim long amaxrows = 192 = 2 amaxrows starttime = timer cells(i, "a").interior.color = rgb(255, 255, 0) cells(i, "ac").value = 1 endtime = timer debug.print "loop " & & "/" & j & ": " & (endtime - starttime) next end sub i dont have performance issues until open workbook or include script in workbook filled graphs , ranges linked images. know when script gets slower. funny thing if start script via control button, runs in no time. running button_click() of activex control or calling in event workbook_newsheet() or own module in debug mode makes slower 179-192 form , 2-8 activex button loop 179/: 0,015625 loop 180/: 0 loop 181/: 0 loop 182/: 0,015625 loop 183/: 0 loop 184/: 0 loop 185/: 0,015625 loop 186/: 0 loop 187/: 0 loop 188/: 0 loop 189/: 0 loop 190/: 0 loop 191/: 0 loop 192/: 0 loop 2/: 0,1875 loop 3/: 0,171...

mysql - Group by the date part of a timestamp field -

i have users table. generate report of user joined day. problem is, datejoined field timestamp field, as query following as: select count(userid) tot users group datejoined does not work, how group by date part , not time of datejoined field? your code: select count(userid) tot users group datejoined you should chage as: select date(datejoined), count(userid) tot users group date(datejoined) the sqlfiddle

java - Comparing Boolean Value -

i have checkbox named testcheck. when user check value becomes true. able implement compare of true/false following ways 1. if (testcheck.getvalue() == boolean.true) { // respective code } 2. if (testcheck.getvalue().equals(boolean.true)) { //respective code } 3. if (testcheck.getvalue()) { //respective code } my questions: is there difference ? if yes, 1 best way of implementation ? it depends.... if return type of testcheck.getvalue() boolean , 3rd 1 ok. but if boolean (big b), do: boolean.true.equals(testcheck.getvalue()) to avoid npe during autoboxing.

pointers - c with the wrong answer -

write program dispense change. user enters amount paid , amount due. program determines how many dollars, quarters, dimes, nickels, , pennies should given change. ask user 2 inputs (amount due , amount paid) in main() , send these along pointers 5 parameters (dollars, quarters, dimes, nickels, pennies) function called change(), calculate number of each give out. print results main(). so program compiling getting wrong answer. doing wrong. #include <stdio.h> #include <conio.h> //function prototype void change( int *d, int *q, int *di, int *n, int *p, int paid, int due ); int main() { //variables int paid; int due; int dollars; int quarters; int dimes; int nickels; int pennies; //reference variables int *d; int *q; int *di; int *n; int *p; printf( "enter amount due: \n" ); scanf( "%d", &due ); printf( "enter amount paid: \n" ); scanf( "%d", &pa...

sql - Import specific row from access database -

at current have 5 textboxes wish populate first 5 rows of column in access database. i have attempted several different sql queries, no success. here's working code first box: try dim con new oledbconnection("provider=microsoft.jet.oledb.4.0;data source=c:\test\response.mdb;") dim cmd new oledbcommand con.open() cmd.connection = con cmd.commandtext = "select * question" cmd.prepare() dim trace = cmd.executereader trace .read() q1txt.text = .item("questiontext") .close() end catch end try that code works fine, when try expand on include next 4, can't work or find information can me. i've tried writing diffrent query populate each box using select * question limit n-1, 1 and select top 1 field question amongst dozens of others throw 1 exception or another. does know of way alter code can tell it: select top 5 question q1txt.text = .item("row1") q2txt.t...

javascript - Unselect an option using jQuery on a Bootstrap selectpicker -

i using bootstrap ui elements: selectpicker allows user select multiple options , have rendered screen in paragraph tags. should able remove selected option. this code render selected options onto screen, each option appears 'x' next it, when it's clicked selected item removed screen: //render selected item screen $('#datacombo').change(function(){ $('#dataoutput').html(''); var values = $('#datacombo').val(); for(var = 0; < values.length; += 1) { $('#dataoutput').append("<p class='removeable'>" + values[i] + " x </p>") }}); //when 'x' clicked, remove item $("#dataoutput").on('click','.removeable',function(){ $(this).remove(); //this removes item screen //next need unselect datacombo selectpicker var foo = $(this); $('#datacombo').find('[value=foo]').remove(); console.log(foo); $('datacombo').selectpicker('refresh')...

Extract frame from video - PHP-FFMpeg -

i using php ffmpeg in laravel project, multiple things probe, extract frame , encode. having issue when creating frame uploaded video file. how frame created: $video = $ffmpeg->open($destinationpath.'/'.$filename); $video ->frame(ffmpeg\coordinate\timecode::fromseconds(10)) ->save(public_path().$frame_path); this working , creates frame other times not. noticed bug comes when trying open .mov file. it's possible version of ffmpeg not support codec used in source video file, , hence not able decompress video , extract image. you try processing file command line see if can extract image way, , ffmpeg may give more information on problem. an example command line extract png frame video file ffmpeg -y -ss 30 -i [source_file] -vframes 1 [target_file] add -f image2 output option if output name variable.

Reference to array of objects in java -

before onto question, i'd give me specific advice because i've been searching long time can't seem find out correct answer. know it's basics having issues. have in code: private interface classname; //initializing class implements interface public interface methodname () { /*this need make arraylist of objects of class , return whole class reference, maybe this:*/ list<interface> listname = new arraylist<>(perhaps needs number of objects added?); listname.add(classname); return classname; //or should done and guess once call method use listname.get(number of object); problem is, return list reference, method requires me return class said interface , not sure how reference class specific arraylist of objects , return in method. thank time. i'll try explaining in plain english. first of all, it's assigement can't change ways methods given. way, not actual variable names, names clarify reffering to. explanation: /** * * gets {@l...

jquery - Many partial javascript sections -

does many javascript sections on different places affect page loading time? like <html><script></script><body><script></script></body><script></script></html> also there affects while using referces or writing small script parts on html? , last, bad or write many codes on document load in page, affect page laod time while compiling scripts on load obviously loading many different external javascript files increase final load time. you can place <script> tags @ end of document, right before </body> website loads before scripts. if possible minify , combine js files, decrease number of http requests well. page rendering start css loaded , dom has been parsed, make seem loads faster. try following recommendations, best practices speeding web site , if concerned page speed. having javascript snippets inline html not idea. try keep html clean, , use javascript appropriate selectors if want alt...

c# - How to make the UI responsive in Winforms -

instead of of guys first learned winforms moved wpf , i'm opposite! reasons regarding graphic performance have use winforms. i'm stuck @ first step. how can make ui responsive wpf. equivalent of grids in winforms. highly appreciated. if responsive mean working on screen resolutions, can use panels, , dock controls inside. correct mix of controls docked in panels, docked in main form, can nice design automatically fit on screens. can use anchor property make control "stick" example top right corner(by default it's top-left). @ least that's understood question.

Comparing strings in java android -

how compare string http://192.168.74.1/sp/info.php?prodnum=0000000001 with http://192.168.74.1 i need http://192.168.74.1 part of first string. you don't need extract first string. can use string.startswith : if (string1.startswith(string2)) { // }

java - Sharing Website URL and Content with Facebook -

i want share url & text facebook.right sharing link ok how add text or content? have using below mention code facebook sharing. <div> <div id="fb-root"></div> <script> (function (d, s, id) { var js, fjs = d.getelementsbytagname(s)[0]; if (d.getelementbyid(ienter code hered)) return; js = d.createelement(s); js.id = id; js.src = "//connect.facebook.net/en_us/all.js#xfbml=1&appid=*********"; fjs.parentnode.insertbefore(js, fjs); } (document, 'script', 'facebook-jssdk')); </script> </div> <div class="fb-share-button" data-href="http://localhost:1493/fbshare.aspx" data-type="button_count"></div>

android - Create directory programaticly? -

how can create folder on sdcard on android device? want when click set ringtone-create folder , copy file if folder exists copy file. far i've en using this private final file rpath = environment.getexternalstoragepublicdirectory(environment.directory_ringtones); private void s1ring() { boolean success = false; rsound = new file(rpath, "summer melody.mp3"); if (!rsound.exists()) { try { inputstream in = getresources().openrawresource(r.raw.s1beautiful); fileoutputstream out = new fileoutputstream(rsound.getpath()); byte[] buff = new byte[1024]; int read = 0; try { while ((read = in.read(buff)) > 0) { out.write(buff, 0, read); } } { in.close(); ...

regex - Convert first letters of the first 2 words to Upper using sed -

i know can awk, want know how sed. know how convert first letter of each line upper: sed 's/^\(.\)/\u\1/' input > output but want convert first letters of first 2 words upper. input file: this file output file: this file i think must doable sed, can't figure out. you can maybe use -e 2 blocks: $ echo "this file" | sed -e 's/^\(.\)/\u\1/' -e 's/ \(.\)/ \u\1/' file ^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ first word second word note can make lines more clear -r parameter allows catching simple (xxx) instead of \(xxx\) : $ echo "this file" | sed -re 's/^(.)/\u\1/' -e 's/ (.)/ \u\1/' file

c++ - Decrypted exe wont run -

i'm writing c++ program takes in input exe file, encrypts (just xoring) , adds encrypted exe resource exe (stub). the stub decrypts exe , saves it. problem decrypted exe won't run. bytes same, can open decrypted exe in pe editor, won't run. any suggestions? if original .exe , decrypted .exe really same, , assuming decrypted executable windows .exe file .exe extension (as referring .exe , pe format seems indicate), might mean you've stumbled security feature of kind. the behaviour of program of single-stage malware dropper . doesn't matter if decrypted file not malicious: system cannot know it; sees executable creates executable , attempts execute it, , marks "do not execute this, ever" (for example via disallowrun . there other ways). it possible (and, not take wrong, more likely ) you're doing wrong: extension not .exe, file not exactly same ( have checked md5/sha checksums of original , decrypted file? ), attempt run file whil...

android - Use notifications and alarm -

i use notifications , alarm in android app not understand why if set alarm, see notification every time launch app. mainactivity: public void setrepeatingalarm() { intent intent = new intent(this, myalarmservice.class); pendingintent pendingintent = pendingintent.getbroadcast(this, 0, intent, pendingintent.flag_cancel_current); long startat; long period; sharedpreferences mpref = context.getsharedpreferences("pref_name", context.mode_private); long dif = system.currenttimemillis() - mpref.getlong("update_time", 0); if (dif >= update_period) { startat = 0; period = update_period; } else { startat = dif; period = dif; } am.setrepeating(alarmmanager.rtc_wakeup, startat, period,pendingintent); } this myalarmservice: public class myalarmservice extends broadcastreceiver { notificationmanager nm; @override ...

PHP pagination if empty do nothing and formatting -

i have built search function site, pagination.firstly, have error show if user has not entered or has entered 1 character. want error work once 'go' /submit has been pressed. secondly, page count displaying want few lines gap between results , page count, visually clear users. i have tried: <br> <br />``echo "\n" etc. way establish break if put echo "hello ", isnt want obviously, trial , error. i have included code: <?php session_start(); include "includes/header.php"; include "includes/connect.php"; ?> <link rel="stylesheet" type="text/css" href="css/generalstyle.css"> <div id = "searchbar"> <form action="search.php" method="get"> search : <input type="text" size="30" name="search" /> <input type="submit" name = "submit" value ="go"/> ...

How to convert a more than 1 doc file in a folder into text file using java.can u modify this code -

code 1 separate file: import java.io.*; import org.apache.poi.xwpf.extractor.xwpfwordextractor; import org.apache.poi.xwpf.usermodel.xwpfdocument; public class readdocfile { public static void main(string[] args) { file file = null; try { // read doc/docx file file = new file("document"); fileinputstream fis = new fileinputstream(file.getabsolutepath()); xwpfdocument doc = new xwpfdocument(fis); xwpfwordextractor ex = new xwpfwordextractor(doc); string text = ex.gettext(); //write text in text file file fil = new file("d:\\wordtotextoutput\\java1new.txt"); writer output = new bufferedwriter(new filewriter(fil)); output.write(text); output.close(); } catch (exception exep) { } } } ...

ios - With a storyboard do i have to use Segues? -

might stupid question want confirm it: lets i'm using tableview present viewcontroller, while i'm having storyboard segue pushes viewcontroller navigationcontroller stack. i know need use prepareforsegue method. mean if ill use methods didselectrowatindexpath wont same results? tried , view controller presented view seems messed up. so wanted confirm it.. ? cheers. you don't need use segues. can still create view controllers in code completely, or nib files, or storyboard without segue ( instantiateviewcontrollerwithidentifier: ). also, segue have connected view controller isn't automatically triggered , execute in code ( performseguewithidentifier:sender: ). none of should have effect on layout of view contents.

c# - Add selected elements to list using for loop -

i'm trying add integers 6 30, except 22 , 26, list using loop. 22 , 26 still being added. did wrong? list<int> linenumbers = new list<int>(); (int x = 6; x < 30; x++) { if ((x != 22) || (x != 26)) { linenumbers.add(x); } } the 2 integers not added if code below: for (int x = 6; x < 30; x++) { if (x == 22 ) { } else if (x == 26) { } else { linenumbers.add(x); } } you need replace || && : for (int x = 6; x < 30; x++) { if ((x != 22) && (x != 26)) { linenumbers.add(x); } } or perhaps, more clear: for (int x = 6; x < 30; x++) { if ((x == 22) || (x == 26)) continue; linenumbers.add(x); } alternatively, perform one-liner using linq. isn't faster or anything, if for loop clearer you, keep as-is. linenumbers.addrange(enumerable.range(6, 24).except(new[] { 22, 26 }));

java - Apache Commons Math: restricting optimization domain -

i fit quadratic function y = + bx + cx^2 data, in such way c greater or equal 0 in final result. is, restrict search domain on c particular range ([0, double.max_value]). currently, have following code snippet: final curvefitter<parametric> fitter = new curvefitter<parametric>(new levenbergmarquardtoptimizer()); fitter.addobservedpoint(0, 0); fitter.addobservedpoint(1, -1); fitter.addobservedpoint(-1, -1); fitter.addobservedpoint(2, -4); fitter.addobservedpoint(-2, -4); final double[] init = { 1, 2, 3 }; final double[] best = fitter.fit(new positivepolynomialfunctionparametric(), init); final polynomialfunction fitted = new polynomialfunction(best); system.out.println(arrays.tostring(fitted.getcoefficients())); where: private static class positivepolynomialfunctionparametric extends polynomialfunction.parametric { @override public double value(double x, double... parameters) { parameters[parameters.length - 1] = math.abs(parameters[parameters.le...

xpages dojo filteringselect partial update onChange -

Image
i'm trying partial update on edit box ("room") on server onchange event of dojo filteringselect control ("from_name") on xpage. so, use simple modify field action computed value: nm = getcomponent("from_name").value; @dblookup("names.nsf", "full name", nm, 10); the onchange event partial update "room" element. the problem there couple of more filteringselect controls on form, , try partial update lookup address book person's room number, gives me yellow exclamation point error other filteringselects on xpage. if other filteringselect controls on page filled out first, partial update works. how around , update room field when, from_name changed? the code control: <xe:djfilteringselect id="from_name" value="#{document1.from_name}" readonly="# {javascript:!document1.isnewnote()}"> <xe:this.defaultvalue><![cdata[#{javascript: @name("[cn]",...

javascript - CSS3 Opening Book effect -

i have created opening book 4 pages. uses css3 (at moment). have added animation book opens after 2 seconds, subsequently few pages flip over. here example: http://codepen.io/doolz77/full/amkgr/ what trying create is when clicks on page no. take them relative page. after have selected , read page, can navigate next or previous page or can click on 'contents' , take them front page. how go doing this? need javascript? appreciated! thanks!!

xml - Custom rounded button in Android -

Image
can tell me how can create custom rounded button in android (like 1 see in middle of picture)? every view on android rectangle. considering picture, let's take @ views (the lines represent view bounds): the trick big round button in middle overlaps other 2 in particular layout . i've tested assumption , able achieve pretty same result, here's screenshot illustrating how can done quite easily:

java - Run Hadoop MapReduce Job from Dynamic Web Project on WildFly Servlet -

i have installed hadoop 2.2.0 on ubuntu 13.10 in pseudo-distributed mode in pc starts , runs correctly (only 1 datanode). i'm using eclipse kepler v4.3 maven plugin develop hadoop program , dynamic web project (web project without maven). i have hadoop project called "hadwork" created hadwork.jar (right click on project, export, runnable jar file, option "extract required libraries generated jar"). works correctly when run job command line with: "hadoop jar hadwork.jar parameter1 parameter2 parameter3" , see correctly work progress on terminal. now want run job dynamic web application deployed on wildfly 8.0 application server (eclipse configured run project on correct server wildfly in standalone mode). i'm writing servlet " servlethadooptest.java " don't understand how run job web application, libraries (hadoop libraries jar? hadwork jar?) need load , load it. can't use command " hadoop jar hadwork.jar paramet...

Django: admin chained filtering -

i want chained filtering not work def queryset(self, request): qs = super(materialadmin, self).queryset(request) if request.user.is_superuser: self.exclude = [] return qs else: self.exclude = ['droits_acces', 'groupe'] ff = qs.filter(groupe= request.user) gg = qs.filter(user=request.user) jj = qs.filter(user=request.user).filter(groupe= request.user) return jj how ? ff = [cc409, st54] gg = [al2o3, bb79, cc409] i have jj = [cc409, st54, al2o3, bb79] you can use the q object complex queries. from django.db.models import q ... def queryset(self, request): ... return qs.filter(q(groupe=request.user)|q(user=request.user))

jBPM 6.0 ksession clustering -

my application based on jbpm 5 , because of clustering problems testing jbpm 6 replace old version. used example from: https://github.com/jsvitak/jbpm-6-examples/tree/master/rewards-basic unfortunately, far have tested it, still has issues sharing same ksession multiple nodes. the runtimemanager set use singleton strategy. runtimeenvironment environment = runtimeenvironmentbuilder.factory.get() .newdefaultbuilder() .entitymanagerfactory(emf) .addasset(resourcefactory.newclasspathresource("rewards-basic.bpmn"), resourcetype.bpmn2) .get(); environment.getenvironment().set(environmentname.use_pessimistic_locking, true); singletonmanager = runtimemanagerfactory.factory.get().newsingletonruntimemanager(environment); runtimeengine runtime = singletonmanager.getruntimeengine(new context() { @override public object getcontextid() { return singletonmanager.getidentifier(); ...

set width for text field in add record jtable -

how can set width in textfield in add record pop menu in jtable ? width narrow , want make more wider. code update in php code : //updating record (updateaction) else if($_get["action"] == "update") { //update record in database $result = mysql_query("update datapelanggan set pelanggan = '" . $_post["pelanggan"] . "', cabang = " . $_post["cabang"] . " id = " . $_post["id"] . ";"); //return result jtable $jtableresult = array(); $jtableresult['result'] = "ok"; print json_encode($jtableresult); many thanks if want increase width of textfield add width in style in jtable javascript code fname:{ title: 'first name', width: '8%', input: function(data) { if(data.record) return '<input type="text" value="' + data.record.fname + '" id="edit-fname" name="fname...

Loading properties as Map in a Mule Flow -

i using mule esb 3.4. in-order configure properties , load .properties file in runtime, use mule property-placeholder component. have requirement extract property values when key dynamic. eg; have store urls multiple applications in properties file (like look-up table). here key app id , value url. need retrieve urls based on app id provided mule-flow part of request. there way achieve this? number of apps may of range 10-15. not want store in data-base , retrieve it. there way achieve using mule via configuration? you can load them directly map using spring so: <spring:beans> <spring:bean id="appprops" class="org.springframework.beans.factory.config.propertiesfactorybean"> <spring:property name="singleton" value="true"/> <spring:property name="location" value="classpath:application.properties"/> </spring:bean> </spring:beans> and...

java - No new server Runtime Environment found" -

i not able install apache tomcat 7.0 in eclipse kepler.i have installed apache tomcat 7.0, java ee perspective , done path sets.but when try add server using windows preference tab,then not find apache tomcat,even tried go tomcat installation directory using search button,it showing "no new server runtime environment found"

multithreading - Java Thread inter process communication working in boolean variable condition but not in int? -

i have code communicating 2 threads in jre6. when run following program expected output come like, a: hi b: hi a: how r u? b: im fine wat u? a: i'm fine b: me too class chat { boolean flag = false; public synchronized void gettalk1(string msg) throws interruptedexception { if (flag) { wait(); } system.out.println(msg); flag = true; notify(); } public synchronized void gettalk2(string msg) throws interruptedexception { if (!flag) { wait(); } system.out.println(msg); flag = false; notify(); } } class thread1 extends thread { chat chat; public thread1(chat chat) { this.chat = chat; } string[] talk = { "hi", "how r u?", "i'm fine" }; @override public void run() { (int = 0; < talk.length; i++) { try { chat.gettalk1("a: " + talk[i]); ...

html - Bootstrap 3 float layout -

i have problem creating relative simple layout. use bootstrap 3 not must. so, html: <div class="container"> <div class="row"> <div class="col-md-4"> <p>a</p> <p>a</p> </div> <div class="col-md-8"> <p>b</p> </div> <div class="col-md-4"> <p>c</p> </div> <div class="col-md-8"> <p>d</p> <p>d</p> <p>d</p> </div> </div> </div> and visual purpose, css: div.col-md-4, div.col-md-8 { border: 1px solid red; } i want on medium screens (md) layout (no matter of height , without white spaces between them): a b c d on small screens (sm) kind of layout: a b c d jsfiddle link: http://jsfiddle.net/hxz35/2/ thank yo...

java - Difference between writing a==2 and 2==a -

this question has answer here: what difference between if (null == pointer) vs if (pointer == null)? 5 answers i have question in mind. in many places saw int a=2; if(2==a){ //some operation } can tell me advantage on comparing 2==a in place of a==2 . some people force error, rather incorrect behaviour, if accidentally typed = instead of == . however: it helps in circumstances (when 1 of values compared modifiable , other isn't) any decent compiler give warning if make mistake (add parentheses and/or explicit comparison if want assignment) so real purpose make code confusing read. a better habit might declare variables const , unless want them mutable. prevent accidental assignment, while making code easier rather harder reason about.

Jquery mobile choice from json -

i getting json data , show in html, in fieldset radio choices when show html code puts "undefined". here code, thank you: var str_html; var str_html; str_title = item.title || null; str_title = item.title || null; str_subtitle = item.quest || null; str_image = item.image || null; a_paragraph = item.paragraph || null; str_html = '<fieldset data-role="controlgroup" data-type="horizontal" data-mini="true">'; str_html += '<legend>' + item.subtitle + '</legend>'; str_html += '<input name="radio-choice-h-' + item.id + '" id="radio-choice-h-' + item.id + '" value="on" checked="checked" type="radio" >'; str_html += '<label for="radio-choice-h-' + item.name + '>si</label>' str_html += '<input name="radio-choice-h-' + item.id + 'b" id="radio-choice-h-' + item.id +...

c# - WCF Exception Logging -

is possible log exception throwmaxreceivedmessagesizeexceeded wcf service. know message size can increased in config logging on side. have log4net running catch unhandled exceptions seems not getting logged, handled. by default, wcf uses system.diagnostics tracing log exceptions. see here , here , here you can redirect system traces log4net explained in this question.

javascript - JQuery-ui, auto hide dialog -

i have dynamic element converted dialog widget. want disappear automatically. this code not working. $("<div>...</div>").dialog({ open : function(eve, ui) { var item = this; window.settimeout(function(item) { item.dialog('close') }, 6000); } }); couple problems - selector looked wrong.. also, trying pass "item" settimeout overwriting item = this.. $(this) meant setting item=this; $("div").dialog({ open : function(eve, ui) { var item = $(this); window.settimeout(function() { item.dialog('close'); }, 6000); } }); heres quick fiddle: http://jsfiddle.net/jfit/qzggc/

python - parsing space delimited, named fields -

i have specific format of data (exported splunk >) mixture of csv , named fields. understand if possible in python parse such data via template (or simplified, average-human understandable regex) "harry potter", "book", "12 mar 2014 note=""good"" language=""english""" "forrest gump", "movie", "14 march 2015 note=""good"" language=""aztec""" as can see first fields comma separated, comes 1 long string starts date , have few named fields ( note , language ). i build list of dicts solely named fields: [ {'note': 'good', 'language'='english'}, {'note': 'good', 'language'='aztec'} ] after parsing csv end last field (e.g. "12 mar 2014 note=""good"" language=""english""" first line) , stuck, solution can think of try ...

sql - How to pass the data to OracleCommand Class c# -

i trying pass variable sql script , run in using c#. i error saying "missing expression". fromdate , todate passed 'dd//mm//yy format. not passing parametres coorectly using oraclecommand ? public void transactionreport(string fromdate, string todate) { string query = "select s.store_code,count(i.invc_sid) count invoice_v left join store_v s on i.sbs_no = s.sbs_no , i.store_no = s.store_no where(i.created_date between to_date(@fromdate,'mm//dd//yy') , to_date(@todate,'mm//dd//yy')) , i.proc_status not in ('131072','65536','147456', '81920') , i.invc_type = 0 , i.sbs_no = 6 group s.store_code"; conn.open(); using (oraclecommand cmd = new oraclecommand(query, conn)) { cmd.parameters.add(new oracleparameter("fromdate", fromdate)); cmd.parameters.add(new oracleparameter("todate", todate)); ...

A directory structure for Django on Linux -

i've got linux machine use solely (multiple) django projects. i'm looking best place put everything. i'm using following directories - /home/code/my_project put django project (ie code created start_project ) /home/code/virtualenvs/my_project_env virtualenv /home/www/my_project apache logs on top of i've been keeping static root , media root directories within main project code - /home/code/my_project/static_root /home/code/my_project/media the big issue i've hit setup i'm running out of disk space on /home . feel should @ least keeping static files in /var somewhere. should apps go in /opt ? how should set next time? can disk space issues current apps? (is sys admin question?)

javascript - Create rotated rectangle out of an image -

Image
is there way slice image pieces (45deg rotated rectangles). here's code found on internet has animation , creates rectangles of image. (version:5) http://plnkr.co/edit/8tcvpyweskirfengntd6?p=preview i tried create rotated rectangles prob when use transform:rotate(45deg) out of piece first applies background rotates it. edit1: trying sth creating div rotated contains div who's rotated other way <div style="overflow:hidden;transform:rotate(45deg)"> <div class="tilepiece" style="transform:rotate(-45deg);background-image:url('img.jpg');background-position:xx xx"></div> ... </div> (version:6) http://plnkr.co/edit/8tcvpyweskirfengntd6?p=preview maybe hint css using background image , tiles on . http://codepen.io/gc-nomade/pen/fahme/ idea set white background rotated tiles giving each different delay in transition. in codepen , used sass generate associate css in loop $n : 24 ; div:hover spa...

hibernate - HQL impossible to read attribute which is an instance of subclass -

first, want have read dozens of articles inheritance mapping or polymorphic fetch hibernate without finding solution problem. though case simple. when executing code below: list meals = sessionfactory.getcurrentsession() .createquery("select m meal m").list(); error below: org.hibernate.wrongclassexception: object id: 1 not of specified subclass: com.mypack.fruit (discriminator: orange) actually, can't read abstract class fruit subclassed in orange or apple a meal contains of fruit can orange or apple @entity @inheritance(strategy = inheritancetype.single_table) @table(name = "fruit") public abstract class fruit { @id @generatedvalue @column(name = "id", unique = true) private integer id; } @entity(name = "orange") //this discriminatorvalue stored in dtype column public class orange extends fruit { } @entity(name = "apple") //this discriminatorvalue stored in dtype column public...

r - How to overlay multiple layers of data in same plot in ggplot? -

Image
data: data code: ## load data ifpricc = read.csv(file = "ifpri_ccagg2050.csv", heade=true) #----------------------------------------------------------------------- # plotting kernel density distribution final yield impact data #----------------------------------------------------------------------- ifpricc.df = as.data.frame(ifpricc) ifpricc_mlt.df = melt(ifpricc.df, id.vars=c("crop","codereg","reg","sres","gcm","scen")) kernel = ggplot(data=subset(ifpricc_mlt.df, reg %in% c("canada","united states","oceania","oecd europe","eastern europe","former ussr") & gcm %in% c("csiro","miroc","nocc")), aes(x = value, y = ..density..)) kernel = kernel + geom_density(aes(fill = gcm), alpha=.4, subset = .(crop %in% c("whet")), position="identity", stat="density...