Posts

filehandler - java open files not cleaned, even when the process is killed -

there java program read files folder, processing , write output files in folder. ran 4 hours , produced few files failed after throwing following error: "too many files" then modified program close (bufferreader , bufferwriter) , started process again. time process failed after starting throwing following error: java.io.filenotfoundexception: <file> (too many open files) then tried running lsof , searched process having no of open files. realized networkmanager. not sure whether should kill process or not. restarted machine. after when ran java program, still got same error. in worst case might possible code still having leaks in terms of not closing everything, still failing after starting process. have feeling lying in system previous run. if start same process in other machine, runs hours before failing. you cannot retain resource between runs of program, if wanted to. leave system without enough resources in theory, though unlikely, restarting...

windows - Python - how to run the application and leave until it end? -

how can run application , leave instead of waiting when ended? example : /var/tmp/runme.sh & following code working waits forever when google chrome exit. how can run google chrome let script exit? import subprocess import sys import time line = sys.argv[1] print line def kill_chrome(): subprocess.call(['taskkill', '/im', 'chrome.exe', '/f']) def run_chrome(): subprocess.call(['c:/program files (x86)/google/chrome/application/chrome.exe', '--kiosk']) def run_java(): subprocess.call(['java', '-cp', 'c:/python27/pdfbox-app-2.0.0-rc3.jar;c:/python27/jprint.jar', 'jprint']) try: if line.startswith("myjava:website"): print "google chrome - idle" run_chrome() elif line.startswith("myjava:a4"): print "printing - java" run_java() elif line.startswith("myjava:kill"): print "killer" kill_chrome() except...

How to read bytes line by line in Java using NIO or apache commons IO? Whichever is more efficent -

i have bunch of bytes written line line file each line can have varying number of bytes , need read them line line wondering how in efficient way using nio or apache commons io? trying see if there way api can take care of allocation , deallocation of buffers since dont know length of bytes in each line. can read string , .getbytes().length() sounds bit awkward. if file consists of lines, can read millions of lines second bufferedreader.readline(). don't need else. in case nio doesn't support reading lines in way shape or form.

Rails: Pie Charts legend in Chartkicks -

in highcharts show percentage along pie_charts , legend can customized this: legend: {labelformat: '{name} : {y} ({percentage}%)'} but in chartkicks can't find how this? if @ documentation specified on chartkick gem homepage, says: you can pass options directly charting library with: <%= line_chart data, library: {backgroundcolor: "#eee"} %> so in scenario, should try like: <%= pie_chart data, library: {legend: {labelformat: '{name} : {y} ({percentage}%)'}} %>

Spring Cloud Config Server without Spring Boot -

i have looked @ spring-cloud-config client without spring boot , many others , have not found convincing answer. here goes again: question : possible, in spring app, use spring cloud config server/client without automagic configuration of spring boot? using spring boot requirement using these frameworks? if is: is there documentation describes needs done in order enable spring cloud config server/client without spring boot? is there sample project describes needs done in order enable spring cloud config server/client without spring boot?? i'm not aware of documentation or sample project. doing in our projects. you need include configuration server uri property source, assuming using propertysourcesplaceholderconfigurer: <bean class="org.springframework.context.support.propertysourcesplaceholderconfigurer" id="propertyplaceholder"> <property name="locations"> <list> <value>http:/...

Jointjs creating link once it is deleted -

i have started working jointjs. have not seen example/tutorial on website mentioning creating of link again once deleted. example on link. http://jointjs.com/demos/org i wonder if possible create link again between 2 members once deleted. i tried code in function function (x, y, rank, background, textcolor) : '.rank': { text: rank, fill: textcolor, 'word-spacing': '-5px', 'letter-spacing': 0, magnet: true, pointerevents:'none' } but not working. i not sure if member type has ports. if yes need add ports recreate links once rendered. if @ source code, links created during render if refresh page or run code again links come back.

php - insert data to mysql using populate dropdown list -

i'm trying insert data database table name dokter , populate dropdown list poliklinik. when i'm trying insert it,the notification keep showing "undifined vaiable : kodep" here form code <select class="form1" name="kodecrot"> <?php $query = mysql_query("select * poliklinik"); if(mysql_num_rows($query) != 0) { while($tampil = mysql_fetch_array($query)){ echo "<option value=".$tampil['namapoli'].">".$tampil['namapoli']."</option>"; } } ?> </select> here process code <?php include'../koneksi.php'; $kodedokter = $_post['kodedokter']; $nmdokter = $_post['nmdokter']; $almdokter = $_post['almdokter']; $telp = $_post['telp']; $kodepoli = $_post['kodecrot']; $kodejadwal = $_post['kodeja...

Inno Setup Studio - Install the main application executable file to subfolder -

Image
i using inno setup quickstart pack 5.5.6 , perfect. i installed inno 5.5.8 quickstart pack 5.5.8 , i'm having problem. ok if start inno can select appname, company , can select path of program , program exe file, screen: like can see selected main .exe in \binaries\win32\ located not in main folder of program in sub-folder. now code have inno script studio automatically write wrong exe path, not main folder of program said in \binaries\win32\ . but why did ? worked inno quickstart pack 5.5.6 , never seen problem , correct path correct if exe in sub-folder. you have these 2 entries in [files] section. [files] source: "c:\temp\life strange episode 5\binaries\win32\lifeisstrange.exe"; \ destdir: "{app}"; flags: ignoreversion source: "c:\temp\life strange episode 5\*"; \ destdir: "{app}"; flags: ignoreversion recursesudirs createallsubdirs this not make sense. entries overlap. it seems believe selectin...

python - c pointers and ctypes -

so, have c++ class wrap in c can use in python using ctypes. declaration of c++ class: // test.h class test { public: static double add(double a, double b); }; //test.cpp #include "stdafx.h" #include "test.h" double test::add(double a, double b) { return + b; } c wrap: // cdll.h #ifndef wrapdll_exports #define wrapdll_api __declspec(dllexport) #else #define wrapdll_api __declspec(dllimport) #endif #include "test.h" extern "c" { wrapdll_api struct testc; wrapdll_api testc* newtest(); wrapdll_api double addc(testc* pc, double a, double b); } //cdll.cpp #include "stdafx.h" #include "cdll.h" testc* newtest() { return (testc*) new test; } double addc(testc* pc, double a, double b) { return ((test*)pc)->add(a, b); } python script: import ctypes t = ctypes.cdll('../debug/cdll.dll') = t.newtest() t.addc(a, 2, 3) result of t.addc(a, 2, 3) negative integer. there problem pointer,...

javascript - Traversing up and finding a child element with attribute equal to a specific value -

i have list ul contains element article has attribute data-level . traversing in javascript through articles. adding replyto symbol comments have data-level larger 1, username of parent, need traverse comment list , find article element has data-level="0" , username element. i can't use jquery closest() because doesn't check inside element. if use parent().parent() run closest() on parent, not good. how can run closest() function or familiar on article element (red arrow in image) find first article element above has attribute equals 0 ( data-level="0" ). here's html code: <ul> <li> <article itemprop="comment" itemscope="itemscope" itemtype="http://schema.org/comment" data-user-id="28" id="comment-40" data-comment-id="40" class="comment-wrapper" data-level="0"> <header> <p class="comment-title">...

PySpark : how to split data without randomnize -

there function can randomize spilt data trainingrdd, validationrdd, testrdd = rdd.randomsplit([6, 2, 2], seed=0l) i'm curious if there way generate data same partition ( train 60 / valid 20 / test 20 ) without randommize ( let's use current data split first 60 = train, next 20 =valid , last 20 test data) is there possible way split data similar way split not randomize? the basic issue here unless have index column in data, there no concept of "first rows" , "next rows" in rdd, it's unordered set. if have integer index column this: train = rdd.filter(lambda r: r['index'] % 5 <= 3) validation = rdd.filter(lambda r: r['index'] % 5 == 4) test = rdd.filter(lambda r: r['index'] % 5 == 5)

java - Editing value of TableView column -

i encountered problem unable solve. thing is, tableview populated , need cells match criteria set value zero. have variable korzemljiste , if condition fullfilled cells in column colosnovica need set value 0.00. here tried: if (korzemljiste < 10000) { tbltabela.getitems().stream().foreach((o) -> { colosnovica.setcellfactory(textfieldtablecell.fortablecolumn()); colosnovica.setoneditcommit( new eventhandler<celleditevent<nepokretnost, number>>() { @override public void handle(celleditevent<nepokretnost, number> t) { ((nepokretnost) t.gettableview().getitems().get( t.gettableposition().getrow()) ).setosnovica(t.getnewvalue()); } });});} sorry, ugly end of code, couldn't make copy properly. this part modified oracle example , error: error: incompatible typ...

jspdf - Generate multiple tables using ajax call -

i using jspdf , jsautotable generate pdf table in dom. first of want create multiple tables present in dom using button click. secondly want create pdf file multiple tables using ajax call server using button. have tried around tutorial have not found specific. can please. i have been able create multiple tables. since needed create 2 tables in pdf file, needed call autotablehtmltojson function twice after getting information html tables. after doing can define options each of table also. since there limited assistance available js auto table if needs in regard comment below, might able help. var elem = document.getelementbyid('employee-table'); var data = doc.autotablehtmltojson(elem); var elem2 = document.getelementbyid('employee-table2'); var data2 = doc.autotablehtmltojson(elem2);

JavaScript - pass string variable to eval -

part of code generates string, suppose used function generated chuck in voxeljs. an example string "(y == 1)? 1 : 0" which need added function this, eg. "function(x, y, z){return (y == 1)? 1 : 0}" i thought using eval change string needed code, this: gtest = function(x, y, z){return eval(generationstring) }; but misunderstood how eval used, , realized needed try else. if @ gtest in javascript console says it's structure function (x, y, z){return eval(generationstring) } when want function (x, y, z){return return (y == 1)? 1 : 0}} . attempting pass code containting eval causes voxeljs crash/freeze when tries generate new chunks. how can convert string javascript code code in function in way want? i realize might hard understand question, sorry that, i'm not sure how describe other way. i found answer literally 30 seconds after posting this, use function() constructor. given string describing javascript function, convert javasc...

classcastexception - How does class casting work? -

consider c1 base class of c3. below code works perfectly. c1 obj1=new c3(); c3 obj2=(c3)obj1; but, there classcastexception in below one c1 obj1=new c1(); c3 obj3=(c3)obj1; what have missed? i think what's happening creating obj1 instance of c1, , trying cast class further down inheritance chain c1. in first example, c1 base type of c3 , can create instance of c3 type c1..that's fine. c3 child of c1 , inherits properties , methods. in 2nd example, however, creating instance of c1 type of c1. trying cast child. child class may have additional properties , methods parent doesn't have. to summarise, child can of parent type , cast it, however, parent cannot child , cannot cast such. if need further clarification, let me know.

java - Odata V4 Client: getEntityCreate method -

i developed odataclient in java in order create new entities. encountering difficulties create new entities. took initiative see messages sent client fiddler. odataentitycreaterequest<cliententity> request= client.getcudrequestfactory() .getentitycreaterequest(new uri("http://localhost:8888/"), cliententity); request.addcustomheader("content-type", "application/json;odata.metadata=minimal"); request.setaccept("application/json;odata=minimalmetadata"); odataentitycreateresponse<cliententity> response = request.execute(); below first line of body obtained fiddler: 17b {"@odata.type":"#odatademo.product", ....} i tested manually fiddler create new entity , first line of message body should be: {"odata.type":"odatademo.product", ....} i know if possible set body of request odata in order delete "@" , "#". thanks...

android - Strange Black Background after setMeasuredDimension in Custom ImageView -

Image
i have library allows circularimageview have problem can't fix. i add in layout way: <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:orientation="vertical"> <linearlayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:gravity="center" android:orientation="vertical"> <com.mikhaellopez.circularimageview.circularimageview android:id="@+id/circularimageview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/test" app:civ_border="true" app:civ_border_color="#3f51b5" app:civ_border_width="8dp" app:civ_shadow=...

android - choose photo from gallery for s7, s7 edge, note 5 not working -

i have app uploading image gallery. working fine note 4, os 6.0, not working note 5, s7, s7 edge. what mean not working is i can see gallery, when select image, gallery dismissed only. nothing ahead happened. did happened before? right not posting code because might know why happening. post code incase if needed. targetsdkversion 21, means don't worry permissions now. problem lies somewhere else. the problem device when choose image gallery onactivityresult() call in normal case when choose image devices oncreate() method call , nothing happens due oncreate() solution write below properties in androidmanifest file of activity.this works me. android:configchanges="orientation|keyboardhidden|screensize"

How to insert text from RTF to Word Document in c# -

i using winservice creating word docs. problem have paste rtf word selection. i have code: private static void pastertf(object bookmarkname, office.application wordapplication, document worddocument, string rtftext, bool winservice) { if(bookmarkname == null || wordapplication == null || worddocument == null) return; if (!winservice) { clipboard.clear(); clipboard.settext(rtftext, textdataformat.rtf); idataobject formatedtext = clipboard.getdataobject(); if (formatedtext != null) { worddocument.bookmarks[bookmarkname].range.select(); selection sel = wordapplication.selection; sel.paste(); } clipboard.clear(); } else { ???? } } do have idea how without using clipboard? if rtf text...

typescript - Angular2 build in Visual Studio Team Services (was Visual Studio Online) -

Image
i have angular2 client visual studio vnext (asp.net 5) project. trying create build in visual studio team services, , getting errors on build step: cannot find module 'angular2/core' this problem typescript compiler. have tsconfig.json in project not sure if team services using it. i don't have problem building locally in visual studio. any idea how should handle this? you need add "npm" task run "npm install" command in build definition install npm packages before vs build. otherwise, angular won't installed during build. remember set "working directory" project folder npm configuration file "package.json" placed.