« first day (1716 days earlier)      last day (3219 days later) » 

12:01 AM
Though I should probably ask "Does anyone know anything about CDI?" to start with :P
 
12:49 AM
Meow, hello
 
1:19 AM
hello tristan
morning
 
 
1 hour later…
2:48 AM
i am getting error when connection ftp in eclipse
option failure due to network I/O
java.net.SocketException
Connection reset by peer
socket write error
 
 
4 hours later…
6:27 AM
hi..
need help on closeablehttpclient
am not getting any response
 
6:51 AM
does anyone know if I am adding many files to a fileset then how to make it wait before it does anything else as otherwise it wont run the dependent operation at all. A way to do that is sleep tag but any better way to do it?
 
7:01 AM
@fscore Yes.
 
7:19 AM
What is it ? @Unihedron
 
Hi @Unihedron...
need help on closeablehttpclient
 
@thanga What exactly?
 
httpResponse = httpClient.execute(httpRequestPost);
above code is working for two records
when it reaches thrid time .it got stuck
is there anything that i hav to reset or is it bcuz of timeout ??
any idea
 
 
3 hours later…
10:13 AM
/javadoc Integer#signum
 
@Unihedron int signum(int i): Returns the signum function of the specified int value. (The return value is -1 if the specified value is negative; 0 if the specified value is zero; and 1 if the specified value is positive.)
 
/javadoc Arrays#sum
 
@Unihedron Sorry, I can't find that method. :(
 
Oh well, Arrays.stream(intArr).sum() it is then
/javadoc Integer#compareTo
 
Which one do you mean? (type the number)
1. java.lang.Integer#compareTo(Integer)
2. java.lang.Integer#compareTo(Object)
 
10:14 AM
1
 
@Unihedron int compareTo(Integer anotherInteger): Compares two Integer objects numerically.
 
10:56 AM
More like "how to upset any programmer", but still a bit funny: quora.com/How-do-I-annoy-a-Computer-Science-student
 
@Gemtastic I've seen that question before :)
 
:P
 
11:50 AM
@Gemtastic Meh
People don't need this answer to be able to annoy us. They manage just fine on their own.
2
This whole approach of "Computers are fairy magic" that everyone seem to have annoys me to no ends already.
 
rofl
I've given up already
Mar 25 at 17:01, by Second Rikudo
People who don't give a fuck about computers don't know computers, shock!
^ golden
 
:)
Guys, what's the correct way of getting information from stdin?
(Do I really need to instantiate 3 objects to read stdin..?)
 
System.in.read()
Or, if you don't need to get so 'raw' into the implementation, use a scanner
 
^ that
try (Scanner scanner = new Scanner(System.in)) {
    scanner.read()
 
How do I differentiate between input from pipe, and input I request specifically?
Rather, I want to make sure something was piped in, and I don't want to have the program wait for input.
 
12:00 PM
scanner.hasNext()
 
I have been shifting places and the new place is getting into my nerves..
 
@Unihedron This waits for input
try (Scanner scanner = new Scanner(System.in)) {
    if (!scanner.hasNext()) {
        throw new RuntimeException("client-properties import expects stdin input. Please pipe something to it");
    }
}
 
huh
 
this seems draconic...
 
/javadoc System#in
 
12:03 PM
@Unihedron Sorry, I can't find that method. :(
 
/javadoc System
 
Which one do you mean? (type the number)
1. android.provider.Settings.System
2. java.lang.System
 
2
 
@Unihedron java.lang.System: The System class contains several useful class fields and methods. It cannot be instantiated. (1/2)
@Vogel612 java.lang.System: The System class contains several useful class fields and methods. It cannot be instantiated. (1/2)
 
My faith towards Java has dropped.
I can't find anything relevant.
 
12:22 PM
damn why does my XML program eat 30% of my mem??
that doesn't make sense... it started out with a tenth or so..
and I just modified ~10 nodes and now It's hogging memory?!
 
@Unihedron System.in.available() == 0 looks promising
 
@MadaraUchiha I thought of it too but my groovy console stabbed me in the face
So I wasn't confident enough to suggest it
 
12:40 PM
I forgot too much of how to use postgres >_<
 
fge
@Vogel612 are you using DOM or a stream API?
 
DOM
JDOM2 actually
I figure how I edit nodes is the root cause of the problem, but I need to check that back
 
1:01 PM
14
Q: make sounds (beep) with c++

user319854How to make the hardware beep sound with c++? Thanks

wtf for the accepted answere
 
\a
 
1:15 PM
"client-properties foo".matches("c")
Why is this false?
String foo ="client-properties foo";
Pattern.matches(".", foo);
This too for that matter.
 
you guys should learn C++......so much better than java
 
I'm kinda tempted to kick you for just that
 
Anyone knows? :(
 
/javadoc String#matches
 
1:21 PM
@ElSordo boolean matches(String regex): Tells whether or not this string matches the given regular expression. (1/2)
 
unsolicited, biased and subjective statements against the room topic are a really great way to make friends @TheArtist /sarcasm
@MadaraUchiha since matches automatically anchors
 
> Attempts to match the entire region against the pattern.
 
So basically, it adds ^$ for me?
 
yes... unless you do it with a real Matcher
 
1:24 PM
@MadaraUchiha Because matches() performs an anchored match
Use Pattern.find()
/javadoc Pattern#find
 
@Unihedron Sorry, I can't find that method. :(
 
/javadoc Matcher#find
 
Which one do you mean? (type the number)
1. java.util.regex.Matcher#find()
2. java.util.regex.Matcher#find(int)
 
@Unihedron boolean find(): Attempts to find the next subsequence of the input sequence that matches the pattern. (1/3)
 
1:24 PM
I lied, use Pattern.matcher(str).find() instead
 
Morning, Java!
 
morning
 
okay great...
wtf JTable...
412 shallow heap: 40m retained heap..
wat
 
@Unihedron That will only find the first match.
 
while find() extract..
 
1:36 PM
@fge
Caused by: java.lang.ClassNotFoundException: com.github.fge.lambdas.consumers.ThrowingConsumer
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 11 more
 
@Michael I'm pretty sure we only care if it matches, not at all what the match result is
 
fge
@MadaraUchiha that is rather hard to analyze without some context
 
<dependency>
    <groupId>com.github.fge</groupId>
    <artifactId>throwing-lambdas</artifactId>
    <version>0.5.0</version>
</dependency>
reader.lines()
        .peek(line -> {
            if (!line.matches("^client-properties(?:-new)? .+")) {
                throw new RuntimeException(String.format("Invalid line: [%s] (does not start with client-properties)", line));
            }
        })
        .map(line -> line.split(" "))
        .map(parts -> Arrays.copyOfRange(parts, 1, parts.length))
        .forEach(Throwing.consumer(commandParser::run));
 
fge
BootstrapMethodError?
First time I have ever seen that exception
 
Guessing it's a spring thing.
Nope, it's a Java thing
 
fge
1:39 PM
java.lang <-- that's not Spring, certainly
But it seems to be related somehow
Looks like there's a class loading order problem or something like that
 
Shouldn't, I'm using a static method
 
fge
Can you try and Class.forName("com.github.fge.lambdas.consumers.ThrowingConsumer") before reader.lines() etc?
@MadaraUchiha that's unrelated
 
@fge Should I try to output it?
 
fge
Try and insert that line before, then run again, and see whether there is still an exception
I wager there will be one, but a different one
And then again this is Spring we're talking about, therefore, uh :/
 
Different error this time, but same cause
Exception in thread "main" java.lang.IllegalStateException: Failed to execute CommandLineRunner
	at org.springframework.boot.SpringApplication.runCommandLineRunners(SpringApplication.java:680)
	at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:695)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:322)
	at com.taboola.clientproperties.ClientProperties.main(ClientProperties.java:33)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 
fge
1:42 PM
No, the exception is different
ClassNotFoundException
It is definitely a class loading order problem
 
@fge That's the cause for the previous error too.
 
fge
No, the other was BootstrapMethodError
 
@fge Which was caused by...
5 mins ago, by Madara Uchiha
full trace https://gist.github.com/MadaraUchiha/c38ea71c72b63b4c9669
 
fge
Anyway
The root cause is that the classloader you use doesn't have throwing-lambdas in it
No idea why
That's probably some Spring setup issue
 
Ugh, I think I might know why
Yeah, PEBKAC.
 
fge
1:49 PM
By the way, I'm not sure what you want to do exactly but your current code will run on lines which are valid before an invalid line is encountered; is this really what you want?
 
Spring!! \o/
 
fge
If I were you I wouldn't do it like that; I'd first collect the elements and only then process them
 
@fge I have a deeper problem than that
Each of those lines are a command being run
Each command is likely to change database state
If there's an error I can't detect, I'm in deep trouble.
 
fge
Define "state"
DML or DDL?
 
@fge Does INSERTs and UPDATEs
 
fge
1:51 PM
So, DML
 
So I need transactions, but I'm at a different layer of abstraction. This layer isn't aware of there being a database run
 
fge
Well then run all of them in a transaction, and .abort() it is you encounter an error
 
fge
What is more, start the transaction only after you have collected the arguments
 
@fge Again, I'm running this at a higher layer
This layer isn't aware of there being a database at all.
 
fge
1:53 PM
And how does that prevent you from collecting the lines before?
 
It prevents me from using transactions.
 
fge
Sorry, I don't really understand what you mean here
But your stream is doing too much work for its own sake
 
Finally.
 
fge
Seriously
 
Done coding TicTacToe game.
 
fge
1:54 PM
That's a stream abuse
How does each individual command proceed to connect to the database, then?
 
@fge Via a method call to a lower level object
 
fge
And this lower level object, I assume, is unaware of its siblings? If yes, maybe you should try and fix that first
I don't know the architecture of your code, so I can't really tell more
 
@fge unaware of its siblings?
 
fge
If you have two commands c1 and c2 which use low level object l1 and l2, l1 and l2 are not bound to each other by a transaction, correct?
If yes, this is what you should fix first and foremost
Otherwise you will end up with inconsistent state at one point or another
 
@fge lucky for me, both command c1 and c2 use the same low level object
A service of sorts
 
fge
1:59 PM
The same instance?
 
@fge Yes
The problem is, that service is used by other components in different projects, moreover, by convention, every method starts and ends its own transaction.
 
fge
Then have that one method you code collect all that you have to do
 
Last but not least, that service level object doesn't interact with the database directly. It does so via crapp DAL objects which manage that sort of state.
 
fge
But the first thing I'd fix if I were you was line collection
Honestly, your .peek() is buggy
 
Hey, I'd love a CodeReview of the Tic Tac Toe game I programmed in Java using JavaFX.
0
Q: JavaFX Tic-Tac-Toe Game

Hassan AlthafI programmed a Tic Tac Toe game using JavaFX, and I'm looking for a code review of it to improve my skills and practices in Java. It would highly be appreciated if you reviewers emphasize on these points specificially: Bad practices which I am following Inefficiencies and how would I rectify th...

 
2:02 PM
@fge So what would you do? Iterate twice and filter?
and if the first iteration returns any lines which failed the validation throw an error?
 
fge
I would create a method which returns a list, or whatever, of things to run; and this method would throw an exception on error
Advantage: you can test this method too
(and ensure that no command will be run in the test)
Divide and conquer :p
 
@HassanAlthaf Put the Circle and Label objects in arrays
 
@fge Some context:
 
@HassanAlthaf That way, you don't need all those "showCircleNumber()" classes
 
The program (client-properties a CLI) has an export command, this outputs, to stdout, a bunch of lines which are each valid client-properties commands.
 
2:06 PM
@Michael I don't get what you mean bro. Can you put it up as an answer on there?
 
Then, what used to happen, was that you pipe that to a file or save it in some other way, then when you need it, you pipe it to bash -x to execute all the commands one by one.
This is slow and error prone. I'm working on "The Better Wayâ„¢"
So I want a command which accepts a bunch of lines, and executes them in the same context. Ideally with transactions.
 
@fge I got the memoryhogging fixed I'd say..
it wasn't the XML itself, but how I bound an event listener to a JTable over and over...
 
@HassanAlthaf See my answer.
 
@Michael Alright mate.
 
fge
@MadaraUchiha wait, did those individual shell script update a database?
That's weird
 
2:14 PM
@fge I know.
It's still a broken workflow. But it's a better one than what we have right now. By a lot.
 
fge
So, basically, what you want is: read the lines from stdin; turn them into something like Statements; execute those statements in a single transaction?
 
@fge Correct.
.forEach(Throwing.consumer(commandParser::run));
 
fge
Well then you have your steps already; what problem do you face in the implementation?
 
commandParser is the actual command line parser for the app.
@fge The way to transactions is 3 layers deep.
And I cannot afford to leak abstraction.
 
fge
Well you'll have to, here; you have to have a transaction for all these commands/statements you want to run. Can't you have a command parser factory which creates instances linked to one transaction?
I can only give suggestions, really; without seeing the code I can't do more :/
 
2:20 PM
@fge That would have worked... but every call to my service already opens and closes transactions internally.
 
fge
Then can't you call the service only once and execute all the commands in it?
It looks to me like you try to fit a square peg in a round hole here
 
@fge No, I'm trying to fit a Icosahedron into a square peg.
 
fge
sigh I have plenty of ideas but no basis to tell whether they would work or not
 
2:49 PM
@HassanAlthaf Wait a minute. "Bro" and "mate"? What are you?!
Either you use "bro" or you use "mate". You can't use both.
 
3:08 PM
@Michael What if your mate is your bro?
 
@MadaraUchiha Not possible.
Your mate can be your brother, but not your bro.
 
What if your brother is your bro?
 
That's fine.
 
3:31 PM
waaaat
your mate can be your brother, and it's fine for your brother to be your bro, but your mate cannot be your bro?
that's messed up
 
@Unihedron Correct.
 
3:49 PM
Nyyuugh... Where can I find what the different role types in postgres actually do. >_<
 
3:59 PM
Hello Java!!!
 
4:51 PM
Off to lunch. Bye Java!
 
 
1 hour later…
user1648409
6:19 PM
Hi. Trying to write a GUI in Swing. Struggled with updating my UI based on the model and wrote a whole bunch of update() functions to manually trigger the update in the UI. Now i changed my JList to a JTable and used AbstractTableModel as it's model. I ONLY instantiated the model once and never changed it afterwards. When then letting my program run and change the data, shown in the table, it magically appears there. Am i correct by assuming that since using the AbstractTableModel i don't have
 
user1648409
to worry about updating the UI by myself now since the model will actually take care for me of that? And whenever my program will add / remove something i simply implement add() and remove() functions that will add and remove the stuff not only in my program but also in my model? Did i finally understand it? :D
 
6:35 PM
maybe
 
6:48 PM
I have one question why in java its not necessary to write default constructor explicitly if we override parameterized constructor on our own. In C++ we have to explicitly re-write the default one if we override any single constructor(parametrized, copy constructor) on our own.
 
7:00 PM
@Shiuyin assuming your model calls the appropriate fire* methods at modification, you should be fine. JTable listens to those changes
 
user1648409
@kiheru I wrote an public void add() in my custom Model class extending the AbstractTableModel using fireTableDataChanged(). As far as i can tell, it SOMETIMES updates the data automatically in the table, but not always. There are definetely some cases when the data shown in the table is not updated...
 
@Shiuyin sounds like you don't call the fire* methods then. The table will show the new data when it reads from the model, but the table can't magically know when it needs to update. The methods that AbstractTableModel implements do that, but your add() does not
 
user1648409
@kiheru I guess there is one thing i dont understand. I added a custom add() and remove() to my class extending AbstractTableModel. They BOTH fire fireTableDataChanged(). These both work for adding and removing data from the model. But what about updating data from the model? I guess this is where i don't fire manually atm. I guess i have to add a custom update() that will only fireTableDataChanged() and call it whenever i update data?
 
oh,, fireTableDataChanged?
fireTableDataChanged() is likely a bit overkill, unless you really modify a lot of data, but I suppose it should work. I'd use one of the more specific methods
 
user1648409
@kiheru but still i guess i forgot to fire it when updating and not only firing it on add and remove, correct?
 
7:12 PM
If you have other methods to update the data than just add()/remove(), you should call the appropriate fire* there too
 
user1648409
ok, thanks
 
user1648409
swing is wird
 
user1648409
*weird
 
@Shiuyin sounds like that. If the data changes, but no event is fired, then the table can't know it should update what is drawn
Not really specific to swing. Standard observer pattern
 
user1648409
hah, worked
 
user1648409
7:21 PM
thanks :D
 
you're welcome
 
 
4 hours later…
11:16 PM
anyone know about javax.el.PropertyNotFoundException?
eclipse + Jsf + ManagedBean
 

« first day (1716 days earlier)      last day (3219 days later) »