Posts

Showing posts from January, 2010

java - Why have we used double quotes in return i+""; -

when run program after removing +"" return statement of tostring() compile time error comes. no idea why.. please tell why that. class test { int i; test(int i) { this.i = i; } public int hashcode() { return i; } public string tostring() { return i+""; } public static void main(string []args) { test t1 = new test(100); test t2 = new test(110); system.out.println(t1); system.out.println(t2); } } the tostring method's return type string , can't return i; because returning int ; needs converted string , & that's return i+""; does. can use return string.valueof(i); // if wanted more "explicit"

mysql - Does UPDATE overwrite values if they are identical? -

i want update vale in database if different. reading through oracle docs on update, says... ...the update statement updates columns of existing rows in named table new values. since doesn't won't overwrite identical values, should take statement literally? mean mysql sort of boolean matching check me? no, mysql won't overwrite identical values. lets insert data: insert foo(id,val1,val2,val3) values (0,1,2,3); query ok, 1 row affected (0.00 sec) if update same values: update foo set id=0, val1=1, val2=2, val3=3 id=0; query ok, 0 rows affected (0.00 sec) rows matched: 1 changed: 0 warnings: 0 take on servers response 0 rows affected

python - Relating a canvas to a figure wxPython -

i know how perform following pseudocode in python when embedding matplotlib figure inside of wxpython figurecanvaswxagg instance: the following items need used: - - - - imports can used - - - - import wx from matplotlib.figure import figure from matplotlib.backends.backend_wxagg import figurecanvaswxagg figurecanvas - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - main_canvas; shadow_canvas; big_plot [a matplotlib figure instance 1 big plot in -- 1 make figure.add_subplots(1,1,1)]; small_subplots [a matplotlib figure instance with, say, 2 subplots in -- make figure.add_subplots(2,1,i), 1<=i<=2] a function called swapview(main_canvas,shadow_canvas,big_plot,small_subplots) swaps figure in shadow_canvas 1 in main_canvas (so keep switching between 1 big plot , 1 many small plots) a function updatedisplay() dynamically updates display every time call swapview() ******* pseudocode ******* main_canva...

Using Z3Py With Python 3.3 -

my situation i've installed microsoft z3 ( z3 [version 4.3.0 - 64 bit]. (c) 2006 ) , it's pyc binaries python2. i've written python3 package needs access z3 functionality. in order able use pyc binaries python3 package, decompyle z3 binaries , applied 2to3 . my problem int('string') doesn't work because z3py isn't able handle new <class 'str'> used 'string' argument: >>> import z3; z3.int('abc') traceback (most recent call last): file "<stdin>", line 1, in <module> file ".\bin\z3.py", line 2931, in int return arithref(z3_mk_const(ctx.ref(), to_symbol(name, ctx), intsort(ctx).ast), ctx) file ".\bin\z3.py", line 72, in to_symbol return z3_mk_string_symbol(_get_ctx(ctx).ref(), s) file ".\bin\z3core.py", line 1430, in z3_mk_string_symbol r = lib().z3_mk_string_symbol(a0, a1) ctypes.argumenterror: argument 2: <class 'typee...

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

Image
recently have uploaded wordpress site onto server. have uploaded wordpress site in sub-folder under root folder ../root(domain root folder)/wordpress (where host wordpress folder). now problem content data in page or post in dashboard of wordpress admin panel not showing - see image. but data showing in front view - see image. if not browser cache issue , not issue happened tinymce editor during upgrade; try add config file: define('concatenate_scripts', false);

java - How to make GlassFish partially stopped -

i using glassfish (glassfish 4) application server java enterprise application. sometimes,i need restart it, when fames error appeared: could not find sub module [myapp_webapp.war] defined in application.xml to resolve error, try delete cache of ear folder application located in domaine folder of glassfish. delete folder,i need stop server before. of course, stopping of server not let other application running! , not when application in use! i tried create 2 different domain: domain1 , domain2 following properties: domain1: glassfish admin console url= localhost:4848 , <network-listeners> <network-listener port="8080" protocol="http-listener-1" transport="tcp" name="http-listener-1" thread-pool="http-thread-pool"></network-listener> <network-listener port="8181" protocol="http-listener-2" transport="tcp" name="http-listener-2...

php - Setting default Wordpress in https:// and redirecting it to http:// and forwarding http:// to https:// in Cloudflare -

earlier have set default wordpress install http:// , redirected in cloudflare use https ssl, got several mixed content errors on browsers[stating requests https http]. so, fresh installed whole wordpress use https:// i'm on shared server no ssl certificate installed, whole site redirects https:// , displays [server not found error]. i need keep wordpress in https:// only, in order work sitemaps , other plugins access https:// without conflicting. - so, need re-direct https:// http:// in .htaccess file , later redirect http:// cloudflare use https://, being default wordpress installed https:// have used several rules in .htaccess no avail, let me know exact rule redirect http:// https:// rewritecond %{server_port} ^443$ rewriterule ^(.*)$ http://% {http_host}/$1 [r=301,l] rewritecond %{https} on rewriterule (.*) http://%{http_host}%{request_uri} [r=301,l] #rewriteengine on rewritecond %{server_port} 443 rewriterule (.*) http://%{http_host}%{request_uri} [r=30...

sql - Regex / Parse PostgreSQL names -

going through postgersql names , identifiers , i'm trying figure out following... is possible implement regular expression (or parse otherwise) check whether postgresql name / identifier needs wrapped in double-quotes or not? , if possible, check if unicode-style name or not. i need inject identifier name sql query, , i'd wrap double quotes if name needs it, because read adding quotes not needed in fact changes name format (see updates below). update-1: ultimately, need implement following function: function preparesqlname(name) { if (/* regular name*/) { return name; } if (/* unicode name */) { return 'u&"' + name + '"'; } else { /* needs double quotes */ return '"' + name + '"'; } } one of major points of concern - processing non-english names. example, following valid postgresql (in russian) doesn't require wrapping double quotes: create table ж...

java - Update Jtable values to MySql table -

Image
i want update mysql using jtable data. have 6 columns(periods,mon,tue,wed,thu,fri) in mysql. in jtable have same table in mysql. in mysql have given periods values(1,2,3,4). connection con = driver.connect(); (int = 0; < 4; i++) { for(int j=1;j<=4;j++){ handler.setdata(con, "update sem1 set mon='"+jtable1.getvalueat(i, 1)+"' periods='"+j+"'" ); handler.setdata(con, "update sem1 set tue='"+jtable1.getvalueat(i, 2)+"' periods='"+j+"'" ); handler.setdata(con, "update sem1 set wed='"+jtable1.getvalueat(i, 3)+"' periods='"+j+"'" ); handler.setdata(con, "update sem1 set thu='"+jtable1.getvalueat(i, 4)+"' periods='"+j+"'" ); handler.setdata(con, "update sem1 set fri='"+jtable1.getvalueat(i, 5)+"' periods='"+j+"...

React router : child routers not working -

i have tried define child routs react router ( below code ) child route not working , doesn't returning error message. <router> <route path="/" component={main} > <indexroute component={dashboard} /> <route path="create" component={userlist} /> <route path="user/create" component={createuser} /> <route path="creategroup" component={creategroup} /> <route path="groups" component={grouplist} /> <route path="premission" component={premissionlist}> <route path="create" component={createpremission} /> </route> </route> </router> i need route premission/create create premission component. to multiple types of deep level/ nested routing need follow following approach: <router> <route path="/" component={main} > <indexr...

MySQL Prune old rows to one per day -

i have huge mysql table, , grows around 90 rows per second, every 4 hours 1.3 million rows gets dumped in there timestamp user(varchar) | created_at(timestamp) ---------------------------- user 1 | 2016-01-27 08:00:00 user 2 | 2016-01-27 08:00:00 user 3 | 2016-01-27 08:00:00 ... user 1 | 2016-01-27 12:00:00 user 2 | 2016-01-27 12:00:00 etc... best approach pruning data older month have 1 row per day? there rows @ 00:00 thinking along lines of created_at >= date + 00:00 , created_at < date + 19:59 or select user, max(created_at) table created_at = date group username for such large amount of data, may want use partitions manage data, running delete statements filter on large tables can take long time. when create partitions month, removing partition super fast. delete data in month, may need store user summary in table before removing partition.

javascript - select previous element and apply effect using css -

i have 3 <div> s in 1 horizontal line. each width = 33.33% , want change width of 1 div on hover 50% , other 2 25%. <div id="a"></div> <div id="b"></div> <div id="c"></div> i can apply as #a:hover{width:50%} #a:hover+#b {width:25%} #a:hover~#c {width:25%} and work fine. when hover b #b:hover{width:50%} #b:hover+#a {width:25%} #b:hover~#c {width:25%} b expand 50% , c shrink 25%. #a remain 33.33%. how can fix this. flexbox can without parent selctor: * { box-sizing: border-box; } .parent { width: 80%; margin: 1em auto; display: flex; } .child { height: 150px; border: 1px solid grey; flex: 1; transition: flex 1s ease; } .child:hover { flex: 0 0 50%; } <div class="parent"> <div class="child"></div> <div class="child"></div> <div class="child"></div> </div...

c# 4.0 - How to get filepath value from the Json -

i have json file given below var json={ "attachmentinfo":[ { "filename":"sign_encrypted_.pdf", "filepath":"b89ddfa7-af16-4e4d-b16b-b6d49db9b91f", "filesize":104504.0, "fileextention":".pdf", "filetype":2 } ] } i need filepath above json. i tried var filepath=(string)json["attachmentinfo"].selecttoken("filepath"); but null value return. thanks in advance help. first, try deserialize json , can access dynamic object, here snipe code: string json = ...; var serializer = new javascriptserializer(); serializer.registerconverters(new[] { new dynamicjsonconverter() }); dynamic obj = serializer.deserialize(json, typeof(object)); var filepath = obj.attachmentinfo[0].filepath;

javascript - USe JSON to store and output radio buttons -

i have page user logs in , able see list of static tasks must accomplish , added radio button each task this: <div data-role="collapsible-set"> <div data-role="collapsible"> <h3>12 months</h3> <div id="task_1" data-role="fieldcontain"> <fieldset data-role="controlgroup" data-type="vertical" data-mini="true"> <legend></legend> <input id="radio3" name="" value="" type="radio"> <label for="radio3">begin research</label> </fieldset> </div> this same code repeats tasks. using ajax, how can value each radio button , save database when log in can see radio buttons clicked?

What is the right way to implement java webstart on a server? -

i want start application webstart, program needs 3 external jars work. tried compiling netbeans uploading on "dist" folder server , accesing server , trying run html. didnt worked because there error paths of external jars if indicated right paths in jnlp. error: exitexception[ 3]com.sun.deploy.net.faileddownloadexception: unable load resource: http://www.abaxomol.com/dist/lib\commons-io-2.4.jar so, external jars go in client computer , retrieve them there? jnlp: <?xml version="1.0" encoding="utf-8"?> <jnlp spec="1.0" xmlns:jfx="http://javafx.com" href="contenedores.jnlp"> <information> <title>contenedores</title> <vendor>diego</vendor> <description>null</description> <offline-allowed/> </information> <resources> <j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"/> ...

How to remove participant profile link from participant name in moodle chat? -

i using moodle version 2.8, have added chat activity in course. wants remove participants profile link on participants name display right side of chat window. so how can display name of participants without link on name? thanks in advance..! the file you're looking /mod/chat/lib.php i've not tested think line you're looking line 1037 (by github count). can find , change from $item['url'] = $cfg->wwwroot.'/user/view.php?id='.$user->id.'&amp;course='.$course->id; to $item['url'] = '#'; and if want remove url list of users well, go line 1257 , change from $userlink = new moodle_url('/user/view.php', array('id' => $chatuser->id, 'course' => $course->id)); to $userlink = '#'; there more references profile page peppered around file (seven reference in total). there's reference @ bottom of view.php module. please note modifying files mea...

ajax - How to send a javascript array to Java servlet -

hello people i'm doing web application orthodox, method ajax using java , javascript. and asking me if possible set array javascript servlet. yes possible! var test = []; $.ajax({ type: 'get', url: 'someurl', datatype: 'json', data: { test: json.stringify(test) }, success: function(data) { }, error: function(data) { alert('fail'); } }); and in servlet: string json = request.getparameter("test");

ios - Retweet using STTwitter API -

i have tried add retweet concept in application using sttwitter api following method after user authentication: [twitter poststatusretweetwithid:[nsstring stringwithformat:@"691544087921606656"] successblock:^(nsdictionary *status) { nslog(@"status..%@",status); } errorblock:^(nserror *error) { nslog(@"error..%@",error); }]; but showing following error: error domain= sttwittertwittererrordomain code=220 "your credentials not allow access resource." userinfo={nsunderlyingerror=0x7b170ca0 {error domain=sthttprequest code=403 "http status 403: forbidden" userinfo={nslocalizeddescription=http status 403: forbidden}}, nslocalizeddescription= your credentials not allow access resource. } if has experienced sttwitter api. suggest me idea rid error. thanks in advance.

java - RotaryKnob using get progress value in text view -

i refereed website can't understand how can value rotary knob. given below tried sample code. need means when rotate right side knob want increase value in text view @ same time left side rotate means decrease value in text view. minimum value 0 , maximum value 25. rotaryknobview class here public class rotaryknobview extends imageview { private float angle = 0f; private float theta_old=0f; private rotaryknoblistener listener; public interface rotaryknoblistener { public void onknobchanged(int arg); } public void setknoblistener(rotaryknoblistener l ) { listener = l; } public rotaryknobview(context context) { super(context); initialize(); } public rotaryknobview(context context, attributeset attrs) { super(context, attrs); initialize(); } public rotaryknobview(context context, attributeset attrs, int defstyle) { super(context, attrs, defstyle); initialize(); } private float gettheta(float x, float y) { float sx = x - (getwid...

javascript - application-wide jquery script -

i use facebook js scripts user authentification, etc. want place them in unobtrusive way application-wide scripts. currently have script partial , call application header: <%# render 'layouts/facebook_app_scripts' %> the script works extremely obtrusive. want make unobtrusive. important since tap sorts of apis , it's getting messy. you don't need see in entirety (if need see script answer question, don't think you'll general question not script-specific) you should know contains dynamically created links such one: window.top.location = "<%= facebook::site_url.to_s %>/logout"; that means putting in .js file in assets/javascript folder isn't going work, since .js files can't access rails-generated variables. so how can shift javascript dynamically-generated links rails view unobtrusive javascript file? take on this project include facebook js sdk gem

c - What memory space is occupied by auto variables in stack -

i read functions in c may use local stack-based variables, , allocated decrementing stack pointer amount of space required. done in four-byte chunks (if not mistaken). but, if run code following: void foo(void) { char str[6]; ...... } what size var str occupy? 6 bytes or 6 × 4 bytes per four-byte chunks. the four-byte-chunk rule means stack pointer must point address multiple of four. in case, allocating 8 bytes satisfies rule, , such block large enough hold 6-character array 2 bytes of padding.

Combined csv via cmd -

i'm working on way combine 3 csv files , have following script so: script @echo off echo set working directory pushd %~dp0 setlocal enabledelayedexpansion set cnt=1 %%i in (*.csv) ( if !cnt!==1 ( /f "delims=" %%j in ('type "%%i"') echo %%j >> combined.csv ) else if %%i neq combined.csv ( /f "skip=1 delims=" %%j in ('type "%%i"') echo %%j >> combined.csv ) rem increment count 1 set /a cnt+=1 )' this works charm , strips header of other 2 csv files in working dir. the script outputs combined.csv , nice script output nl2 ddmmyyyy.csv . the issue have , can't seem figure out how make name of output file incremental , date-based. code can parse date elements date variable. format of date vary based on locale. mine set yyyy-mm-dd, yours may different. m:>echo %date% 2016-01-27 8:23:58.28 \\swpdcendwxtk01\d$ m:\dw_devl\paul\phs_dmx_config\bin m:>set fn...

HTML dropdown menu with links on the left -

i have following code, , works fine, except "contact" link needs last link. however, dropdown seems placed last? it navbar @ http://www.w3schools.com/css/tryit.asp?filename=trycss_dropdown_navbar want create, 2 additional links after dropdown link. <!doctype html> <html> <head> <style> ul { list-style-type: none; margin: 0; padding: 0; overflow: hidden; background-color: #333; float:right; } li { float: left; } li a, .dropbtn { display: inline-block; color: white; text-align: center; padding: 14px 16px; text-decoration: none; } li a:hover, .dropdown:hover .dropbtn { background-color: #111; } .dropdown { display: inline-block; } .dropdown-content { display: none; position: absolute; background-color: #f9f9f9; min-width: 160px; box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); } .dropdown-content { color: black; padding: 12px 16px; text-decoration: none; ...

c# - Number with decimal separator incorrectly cast to Double -

i'm experiencing weird behavior when converting number double, when using culture information. when converting "3,3" using dutch culture, handled correctly. if convert "3,3" using culture, returns 33 . expecting error. see example: static void main(string[] args) { cultureinfo culturedutch = new cultureinfo("nl-nl"); cultureinfo cultureus = new cultureinfo("en-us"); system.threading.thread.currentthread.currentculture = culturedutch; console.writeline("input 3,3 --> expected 3,3"); console.writeline("output = " + convert.todouble("3,3", culturedutch)); // actual result --> 3,3 console.writeline("input 3,3 --> expected invalidcastexception"); console.writeline("output = " + convert.todouble("3,3", cultureus)); // actual result --> 33 console.writeline(); console.writeline(); system.threading.thread.currentthread....

java - Java8: Filter and compare 2 Lists with Lambda -

the task: i have 2 lists contains of entrys (id + datetime) id's can multiple differen datetimes. i need list of id's whith following conditions: the id of list1 not in list2 if id of list1 in list2, see if has higher date if id of list1 has higher count in list2 the question: how can java 8 streams? examplecode: import java.util.arrays; import java.util.hashmap; import java.util.hashset; import java.util.list; import java.util.map; import java.util.set; import org.joda.time.datetime; import org.joda.time.format.datetimeformat; public class lambdafilter { public static void main(final string[] args) { final lambdafilter lf = new lambdafilter(); lf.start(); } private void start() { final list<entry> list1 = arrays.aslist( new entry(15, new datetime(2012, 6, 29, 0, 0, 0, 0)), new entry(101, new datetime(2012, 3, ...

java - Writing to an Excel file using Apache POI a huge data from ArrayList of Strings -

i have arraylist of strings quite huge(approximately on 500k , more of items). there possibility speed writing array excel file? right takes while , have no idea if did could(maybe problem .get method?). please refer following code(please not pay attation details- class created test purposes): import java.io.file; import java.io.fileoutputstream; import java.io.ioexception; import java.util.arraylist; import java.util.list; import org.apache.poi.ss.usermodel.cell; import org.apache.poi.ss.usermodel.row; import org.apache.poi.ss.usermodel.sheet; import org.apache.poi.ss.usermodel.workbook; import org.apache.poi.xssf.usermodel.xssfworkbook; public class tests { private static final string address = "./result/file.xlsx"; public static void readandwriteadata(int counterofexecutions, list<string> listofresults) throws ioexception{ file file = new file(address); if(file.exists()&&!file.isdirectory()){ file.delete(); } @suppresswarnin...

Replace port in url using python -

i want change port in given url. old= http://test:7000/vcc3 new= http://test:7777/vcc3 i tried below code code, able change url not able change port. >>> urlparse import urlparse >>> aaa = urlparse('http://test:7000/vcc3') >>> aaa.hostname test >>> aaa.port 7000 >>>aaa._replace(netloc=aaa.netloc.replace(aaa.hostname,"newurl")).geturl() 'http://newurl:7000/vcc3' >>>aaa._replace(netloc=aaa.netloc.replace(aaa.port,"7777")).geturl() traceback (most recent call last): file "<stdin>", line 1, in <module> typeerror: expected character buffer object it's not particularly error message. it's complaining because you're passing parseresult.port , int , string's replace method expects str . stringify port before pass in: aaa._replace(netloc=aaa.netloc.replace(str(aaa.port), "7777")) i'm astonished there isn't simple way set port...

fold - Scala: using foldl to add pairs from list to a map? -

i trying add pairs list map using foldl. following error: "missing arguments method /: in trait traversableonce; follow method `_' if want treat partially applied function" code: val pairs = list(("a", 1), ("a", 2), ("c", 3), ("d", 4)) def lsttomap(lst:list[(string,int)], map: map[string, int] ) = { (map /: lst) addtomap ( _, _) } def addtomap(pair: (string, int), map: map[string, int]): map[string, int] = { map + (pair._1 -> pair._2) } what wrong? you need swap input values of addtomap , put in parenthesis work: def addtomap( map: map[string, int], pair: (string, int)): map[string, int] = { map + (pair._1 -> pair._2) } def lsttomap(lst:list[(string,int)], map: map[string, int] ) = { (map /: lst)(addtomap) } missingfaktor's answer more concise, reusable, , scala-like.

java - Printing out .txt file with JOptionPane -

i'm trying list of words have scroll instead of window running off screen. scroller working can't dimension work. says ( new dimension( 200, 400 )) ; has error in it. cannot find symbol import javax.swing.jdialog; import javax.swing.*; import java.util.*; import java.io.*; public class print1 { public static void main(string [] args) throws ioexception { string input = ""; bufferedreader reader = new bufferedreader(new filereader("wordlist.txt")); string line = null; while ((line = reader.readline()) != null) { input += line + "\n"; } reader.close(); jtextarea textarea = new jtextarea(input); jscrollpane scrollpane = new jscrollpane(textarea); textarea.setlinewrap(true); textarea.setwrapstyleword(true); scrollpane.setpreferredsize( new dimension( 200, 400 )) ; joptionpane.showmessagedialog(null, scrollpane, "c...

How to structure a multi-modules Maven project to compile it at once? -

i have maven project multiple modules , sub-modules , want compile @ once, i.e. using 1 call "mvn clean install". for basic project, following structure work: . ├── modules │   ├── modulea │   │   └── pom.xml <--- module pom │   ├── moduleb │   │   └── pom.xml <--- module b pom │   └── pom.xml <--- super pom (at root of "modules" folder) └── pom.xml <--- aggregator pom with aggregator being: <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelversion>4.0.0</modelversion> <groupid>org.test</groupid> <artifactid>aggregator</artifactid> <packaging>pom</packaging> <version>1.0.0-snapshot</version> <modules> <module>modules</module...