Posts

java - Reading from new folders every x seconds and using their data -

currently writing application in java looks through files in directory (call 'topics'). within directory number of folders named after respective topics, maybe 'dog', 'cat', etc. i using scheduledexecutorservice through directory every 30 seconds, going through each topic folder , performing operation on contents in folder (we'll other independent piece of code writing these topic folders, maybe log file or something). what best way examine new subdirectories each 30 seconds? if start topic dog, , somewhere between 30 seconds topics 'cat' , 'bird' added, best way me through new folders? thinking comparing hashset or something, i'm not sure efficient way this. i ask because there potentially great amount of subdirectories being created, , seems me problematic try loop through each 1 directory.listfiles(). advice? use java's watchservice api. the watchservice api low level, allowing customize it. can use is, or c...

SQL select near by values -

i have table " t_person " 2 fields search by: height int, birthdate datetime . when query table want rows values near searched. example when search people height of 175 cm, this: select * t_person height = 175 i rows height value near 175. eg 174, 173,176... same thing date column. when search '2003-06-25', dates close it. is possible? you need sort of measure on constitutes close. suspect want exact matches appear first. so, order rows "nearness" use: select p.* t_person p order abs(height - 175); filtering results useful, can add where clause: select p.* t_person p height between 175 - 2 , 175 + 2 order abs(height - 175); the same idea can work dates. however, don't specify database in question , date functions highly database specific.

Python matrix using min function in k-means -

i trying learn k-means book"machine learning in action" now. using code given book in ipython notebook, outcome matrix([[<map object @ 0x0000000008832c88>]], dtype=object) happened after input locmat = mat(loaddataset("user1.txt")) , min(locmat[:,0]) . what meaning of outcome? why not exact value 3.245555? code showed below, thank in advanced! def loaddataset(filename): datamat = [] fr = open(filename) line in fr.readlines(): curline = line.strip().split('\t') fltline = map(float,curline) #map elements float() datamat.append(fltline) return datamat def disteclud(veca, vecb): return sqrt(sum(power(veca - vecb, 2))) #la.norm(veca-vecb) def randcent(dataset, k): n = shape(dataset)[1] centroids = mat(zeros((k,n))) j in range(n): minj = min(dataset[:,j]) rangej = float(max(dataset[:,j]) - minj) centroids[:,j] = mat(minj + rangej * random.rand(k,1)) retu...

java - Validation of Apache Commons Configuration Values -

i'm using apache's commons-configuration (v 1.10) library provide configuration values program. use compositeconfiguration of systemconfiguration , propertiesconfiguration in order allow users override properties file java's -d command-line argument. the problem i'm running validation of values in configuration (ensure value of x positive, example). near can tell, commons-configuration library (neither 1.10 nor 2.0-beta) not provide means of validating configuration values. yes, can validate xml document that's used xmlconfiguration (and that's hear if try google answer question). doesn't me values come systemconfiguration part of configuration class. so, missing something? library provide way validate values i'm missing, or there java library that's built on commons-configuration provides validation capabilities? or need build derivative of compositeconfiguration ?

java - The Execution of the following code fails to terminate despite giving the expected output, why? -

the execution of following code used update redirected urls urls present in excel, fails terminate despite giving expected output. program selects excel file in urls checked present updates url url present in excel redirects. can give me reason. import java.io.file; import java.io.fileinputstream; import java.io.fileoutputstream; import java.io.ioexception; import java.net.url; import java.util.arraylist; import java.util.list; import javax.net.ssl.httpsurlconnection; import javax.swing.jfilechooser; import javax.swing.jframe; import org.apache.poi.ss.usermodel.cell; import org.apache.poi.ss.usermodel.row; import org.apache.poi.xssf.usermodel.xssfsheet; import org.apache.poi.xssf.usermodel.xssfworkbook; public class selenium_sample1 extends jframe { public static void main(string[] args) throws ioexception { string s, sss = null; int rownum = 6; jframe jf = new jframe(); jfilechooser filechooser = new jfilechooser(); filechooser.setcurrentdi...

Find and Replace in Visual Studio using Regex -

i found out can use regex search queries in find , replace in visual studio. have lot of similar lines so: datum["id"] = id; datum["name"] = name; i have more lines so: this.id = datum["id"]; this.name = datum["name"]; i want turn first lines to: datum.set("id", id); datum.set("name", name); and second set of lines to: this.id = datum.get<int>("id"); this.name = datum.get<int>("name"); how possible find , replace , regex? can't figure out. after enabling regular expression clicking on 'use regular expression' button, place following in find: datum\[\"id\"\]\s*=\s*id\; and place following in replace (no need use regex in replace): datum.set("id", id); similarly: in find: datum\[\"name\"\]\s*=\s*name\; in replace: datum.set("name", name); in find: this\.id\s*=\s*datum\[\"id\"\]\; ...

Performance tuning for data quality in SQL Server -

i working in sql server 2008. have database use run data quality validations on test files receive our source system before load our production data warehouse instance. in past, these test files have been small. but, receiving large amounts of data (on order of 3 [gb]). have been asked performance tune our database handle this. because run data quality validations, have designed tables in db handle trashiest data possible. instance, though equivalent tables in production have appropriate data types, had create columns varchar(255), such import of test data tables doesn't run data type conflicts. also, there duplicates. so, tables simple. they're bunch of varchar(255) columns, no constraints, indexes, or key relationships defined. also, tables truncated. general process follows: -a user loads test files tables -the user executes stored procedures against table, run our data quality tests -the next user loads test files tables , runs data quality tests ... -the t...