« first day (1507 days earlier)      last day (3438 days later) » 

12:02 PM
If I do gameFile.setScore(points-=5) will it simply set the score to current score -5 or actually subtract 5 points from the variable itself?
Often find myself asking the most basic of questions..
 
fge
@Juxhin if you don't know --> don't do it
 
Wouldn't it better to learn though? Realistically speaking it's a rookie question, if someone does ask me I'd like to know myself
Anyway I can check myself so it's fine :)
 
fge
@Juxhin this kind of code is confusing to read
 
True, seems better to just assign it outside
 
fge
Anyway, it will first substract the value of 5 from point and then pass that as a parameter to the method -- it is equivalent to gameFile.setScore(points = points - 5)
 
12:05 PM
points -= 5;
gameFile.setScore(points);
 
fge
Yep, that's better
 
Alright cheers
 
fge
Your fellow coworkers will thank you
 
@Juxhin Ugh, golfed code!
 
Will take a couple more years till I get to actually work with people
So most of the time I have the bad habit of coding like that
 
12:08 PM
@Juxhin They do say habits grow.
 
Better start doing it properly from now then haha
Is it simple to host a small server to hold track of basic highscores?
I'm literally doing all this for learning purposes and have never really gone into server stuff
 
#define simple what?
 
Math quiz
 
fge
Yeah, heroku for instance
 
End of quiz score and profile is uploaded
 
12:10 PM
Using home machine as an important home server?
 
Just profile name and score achieved
 
fge
You have a pretty decent VM which is yours alone
And a postgresql database to boot
 
Anything really, I'm dumb when it comes to this which is why I'm asking
 
Not a java related, but how would you guys approach a GUI interfacing with a database in the quickest, dirtiest way possible
 
fge
(cheers to them for NOT providing MySQL, except as an option)
 
12:11 PM
@MLProgrammer-CiM ermph....
 
@MLProgrammer-CiM "dirtiest way possible" - bribe someone to write it for you
2
 
Unihedro gets another star from me
 
it's handmade xmas gift
 
@MLProgrammer-CiM lolz, I just fell off laughing
 
12:12 PM
Anyway will be AFK for a bit. Later
 
First, GUI as in what? webpage? desktop?
 
haha I know. Thing is, I do slow & clean GUIs on ANdroid, but I was after something for desktop to code before xmas
I cannot into webpages for my life
 
@MLProgrammer-CiM Use JavaFX
+ Scene Builder
 
depends on what you want the GUI to do..
but Quick and dirty?? sure that's easy..
 
A gui can't be build faster than this
 
12:13 PM
Geez, star more messages from others as well! The star transcript is full of me, it's becoming a monopoly!
 
@ItachiUchiha how are the odds?
 
database of customer's emails, combobox with template style, it spits a formatted email
 
@Vogel612 Try me :P
 
@ItachiUchiha how about something that takes an Object, iterates over it's properties and generates named GUI elements depending on the property types?
WOUE
 
@Vogel612 Well that has got nothing to do with the GUI
 
12:16 PM
oh does it?
 
It has more to do with the language
yes
 
meh you don't even have to start up a SceneBuilder or anything..
 
AFA @MLProgrammer-CiM question was concerned, it stated the fastest method to build a GUI ready with a database to commit/fetch data
 
just feed it to that class....
 
cool, thanks mate
Is it IntelliJ-happy?
 
12:18 PM
@MLProgrammer-CiM what?
 
nah I was wondering if Scene Builder could be integrated with IntelliJ but apparently not
 
oh, awesomesauce
thanks
 
12:44 PM
How magical is MethodHandle?
prepares for fge attack
 
@Unihedro it isn't...
it's just an object representation of bytecode level method representation
or in other words, It's a way to reach into the bytecode and call it even from source.
just without all the other unnecessary wrappers around methods like.. object references and type-erasures and all the other abstractions
 
Oh cool!
 
fge
It has a big advantage over reflection however
MethodHandle invocations can be inlined, therefore optimized
JRuby with Java 7 is more than twice as fast as it was in Java 6, all thanks to MethodHandles
(and is the fastest Ruby implementation out there by far)
 
Is it possible to produce closures out of methodhandles?
 
fge
Yes
 
12:50 PM
IIRC closures are implemented as invokespecial though... and MH's are represented as invokevirtual, right?
 
> The behavior is what happens when the method handle is invoked, using the method MethodHandle.invokeExact. The special capability of method handles is that invokeExact accepts any number of any type of arguments, and can return any type or void. A regular invokevirtual instruction performs this. (It is rewritten secretly to invokehandle, as discussed below, but this can be ignored except by HotSpot implementors.)
 
fge
@Vogel612 hmwell, you can access constructors with handles and they are invokespecial
 
@Vogel612 Thanks! I see that methodhandle allows bypassing reference typing.
 
Polymorphic signature ftw.
 
yes, that's new...
The entire concept is too much to grasp for now... Maybe I'll inspire from it another day, but not today.
:P
 
fge
12:54 PM
@Unihedro from that same page: "method handles can easily be bound to arbitrary Java objects, producing closures."
I want them for grappa
 
@fge whoops, overlooked it
 
fge
I have recursive rule calls
MethodHandles can handle that for me
 
Im trying to parse a Date, but getting ParseException
how can I fix it? ideone.com/Cj3y4a
 
don't use Date...
dead simple, right??
use Calendar instead
 
@Vogel612 There's not Date. It's a string.
The SimpleDateFormat is broken, that's why.
 
12:59 PM
Sept 19th 2014
 
So, if I'm looking to build parsers or engines, then I would need MethodHandles? Does it have every-application use cases?
 
fge
@Unihedro dynamic languages based on the JVM
 
Ohh
Can I build a Java code parser with MethodHandle? :D
 
fge
Yeah, hack grappa to use them instead of bytecode generation and you're good to go :p
grappa-examples already has an example of a Java parser, but it's for 1.6 though
 
\o/
 
fge
1:03 PM
And the way the grammar is written is, uh
Not very good
 
> The JVM is going to be the best VM for building dynamic languages, because it already is a dynamic language VM. And InvokeDynamic, by promoting dynamic languages to first-class JVM citizens, will prove it.

Using reflection to invoke methods works great...except for a few problems. Method objects must be retrieved from a specific type, and can't be created in a general way.<...>

...reflected invocation is a lot slower than direct invocation. Over the years, the JVM has gotten really good at making reflected invocation fast. Modern JVMs actually generate a bunch of code behind the scenes
 
fge
Too big --> JIT will say "no"
 
Can I ask a noob question? Googling didn't give anything helpful unfortunately.
What does AccessController.doPrivileged(new PrivilegedAction()) do over not wrapping the call in the Action?
 
execution as admin...
or sudo in linux terms...
 
Oh, so I can install stuff with it even if System.getSecurityManager() disallows?
 
1:09 PM
prob. the user will get prompted for credentials / authorization tho
@Trollkemada
 
@Vogel612 how can I parse it using a Calendar?
 
oic :)
 
ermph...
@Trollkemada you'll need to use the SDF, too...
40
Q: Convert String to Calendar Object in Java

Doug MolineuxI am brand new to Java, usually work with PHP I am trying to convert this string: Mon Mar 14 16:02:37 GMT 2011 Into a Calendar Object so that I can easily pull the Year and Month like this: String yearAndMonth = cal.get(Calendar.YEAR)+cal.get(Calendar.MONTH); Would it be a bad idea to parse...

 
@Unihedro how can I fix it? Why do you say SimpleDateFormat is broken?
@Vogel612 I am using SDF as showed in my example, but it is not working, I dont know why
 
unfortunately neither do I..
 
1:12 PM
You feed it a string format that isn't going to do what you want.
 
That string format comes from Google Calendar =s
 
I am having hard time parsing json, I am using Jackson could someone please help me
 
fge
1:36 PM
@Tarun Jackson makes it pretty easy; what's the problem?
 
1:51 PM
@fge I have bit complicated Json Structure
[
  {
    "body": {
      "actor": {
        "id": "Member:942852",
        "assetType": "Member",
        "displayName": "Alam Zamir",
        "username": "zaansari",
        "email": "zansari@axway.com",
        "avatar": "NULL"
      },
      "verb": "Updated",
      "object": {
        "id": "Scope:987918:7812027",
        "assetType": "Scope",
        "displayName": "R&D Monitoring",
        "assetState": "Active"
      },
      "time": "2014-12-08T12:03:25.747Z",
      "summary": "Alam Zamir Updated Scope 'R&D Monitoring'",
Right now it contain only one body elements, but the actual response can contain 1000 of body elements
I am interested only in those body elements where my "assetType" is "Scope"
 
yaaay duck-typed JSON...
 
In the above example, "Target" key contains only one object(defined in curly braces) but it could contain many such objects. In each object value of "newValue" and "oldValue" Key can be string or another object(collection of key value pair defined inside {} )
@fge Could you please tell me how to convert it into Collections with Filtering
 
fge
2:08 PM
@Tarun collections? You're joking, right?
Create a POJO
 
@fge How would i handle the scenario that newValue, oldValue key could be string or a object
By object i mean, Collection of key,value pairs
 
fge
@Tarun Jackson supports that as well with @JsonTypeInfo; though this is quite a strange JSON you have here
 
@fge sorry for ignorance but cant we do it via Collections
I dont understand why is that a strange JSON
 
@Tarun because usually you have near-immutable stuff sent via JSON..
that doesn't really allow switching through types, like your newValue value
usually it should be possible to represent a json property with a single type ;)
 
ok thanks @Vogel612
 
fge
2:24 PM
Well, I guess you can deserialize those as JsonNodes
A JsonNode will basically "swallow" everything
 
Hi all..
I am trying to port an application which reads/writes into Input/Output Streams of Sockets, to use NIO (using Netty)
Is there any class which can provide some adaptation between stream/channel handlers so my protocol stack implement doesnt have to be changed ?
 
@fge thats how i tried to do, But the problem is I have to iterate through all the nodes whereas i want to iterate through only those nodes where "assetType" is "Scope"
 
How on earth do you place a link in comments?
![desc][1] [1]: url doesn't seem to work
 
fge
@Juxhin: opening bracket, text, closing bracket, opening paren, link, closing paren
 
Alright, thanks @fge
 
2:33 PM
@fge is there anyway to filter nodes from tree or select nodes with condition
 
fge
@Tarun see the javadoc of JsonNode; it offers plenty of navigation options
Otherwise there is this, but its expression power is limited (doesn't handle empty property names for instance)
(still, it may turn out to be useful for such malformed JSON)
(s,malformed,idiotic)
 
@fge Since i have to use the information extracted from Tree at multiple places so i am thinking to iterate over the tree once, pull out useful information and put it into some sort of multi-dimesional Collection structure.
 
fge
@Tarun "muti-dimensional collection" == "design smell"
Create a POJO, or several
But do not overuse collections
 
@Juxhin [text](url)
 
Already settled, thanks @Uni
Should I actually use JFileChooser to load/save files?
There seem to be other alternatives
 
fge
3:15 PM
Java mishap #1: == with Strings; Java mishap #2: mixups between chars and bytes
 
I'd not consider the first a mishap..
 
fge
@Vogel612 how would you describe it then?
 
if you want to have that as mishap, then the whole reference-problem is a mishap.
since == always compares reference equality..
it's just consequent to have Strings be the same in that respect.
booleans are internalized anyways, so that's fine
same goes for primitive shorts IIRC
 
fge
Err
Disagree
The fact that == always compares references is, to my eyes, a good design decision
And so is .equals()/.hashCode()
 
@fge so why are you complaining about it?
 
fge
3:30 PM
@Vogel612 I am not
Maybe "mishaps" was wrong here
Let us replace that with "user errors" if you wish
 
oh yes
that's incredibly true ;)
 
fge
Sorry for my poor vocabulary, heh
 
fge
3:42 PM
@Vogel612 sorry, I may have sounded harsh, wasn't the intent
 
no you didn't ...
 
fge
Anyway, back on track, can someone on Windows please tell me the result of this: Paths.get("").getNameCount()
(Java 7+ required of course)
 
**eval Paths.get("").getNameCount();
**help
 
3:55 PM
**eval:Paths.get("").getNameCount();
 
:20344925: compilation failed with error startup failed:
UserScript: 1: expecting EOF, found '(' @ line 1, column 10.
Paths.get(&quot;&quot;).getNameCount();
^

1 error
 
I don't have a windows handy though :(
 
fge
@Vogel612 those quotes again? Want me to write a grappa grammar?
 
:O fge offers to help
 
fge
Hey, that's harsh
 
4:01 PM
no, I'm impressed that you're so kind :P
sincerely
er... never mind, have a picture instead
runs away after not-knowingly being harsh
 
fge
@Unihedro if this picture is meant to refer to some kind of internet meme I don't get any of it :p
 
It's a picture of a Minecraft scene.
remembers that fge doesn't play games
 
fge
Sorry :p
But me, kind? Meh
Oh, it reminds me of something
@Vogel612 about the dos command to manipulate DOS attributes, it's not attrs; it is something like attrib or attribs, can't remember
It's been 20 years since I've been using DOS (gives an idea of my age; at least I could type at a keyboard 20 years ago)
 
4:22 PM
Eeeeek! That's not the current state of javabot...
 
Isn't that Minecraft? Nevermind just read that lol
 
19 mins ago, by Unihedro
It's a picture of a Minecraft scene.
 
Looks pretty
 
fge
@Juxhin graphics are nice, sure; now, the architectural concept, err...
 
I did write a 3D rendering engine using OpenGL
 
4:24 PM
Can someone help me with this please?
 
But still had alot to finish on it, never continued
 
I like OpenGL.
 
0
Q: How can I edit the default TestNG html report

StudentI don't want to create a new one or a custom listener. Is that possible? Where is the html report created in TestNG?

 
fge
Even as an art form I don't see the point, except maybe as a contest as to who is gonna predict the most accurately when the thing is going to collapse :p
 
:D
 
4:25 PM
OpenGL is nice, can be tricky but that's the fun of it
 
fge
OK, the guys in california have contacted me again... Which made me change my next fs target, since they also do storage and provide free accounts
 
~JavaBot at your service
 
fge
**eval IntStream.rangeClosed(1, 10).sum()
 
:20345444: undefined execution error: No such property: IntStream for class: UserScript
 
fge
Eh?
I thought it was pure Java
 
4:27 PM
it's groovy
 
fge
Ah :/
 
urk dammit..
 
and intstream isn't imported
and groovy only supports Java 6
 
the darn replies don't work properly with that...
 
fge
Oh great
 
4:28 PM
**shutdown
~going down
 
fge
@Unihedro I thought you'd have salvaged my compilation code by now
 
Yes... I'm in the middle of converting that :)
 
~JavaBot at your service
 
fge
Argh, I keep forgetting, but there's a super library packaged by com.sun for source code generation
jsonshchema2pojo uses it
 
Yep! And there's JavaCompiler, both are awesome
 
fge
4:30 PM
Ah
codemodel
Use that
 
:O
What's that?
 
fge
It is a Java code generation library
Really
If it's an eval expression you can surround it with your class declaration, the main declaration, System.out.println, and the rest
And then you use JavaCompiler
 
:D
 
fge
Of course you can do it by hand as well, but...
 
File#getName() returns the file extension aswell?
Or just the file name?
 
fge
4:32 PM
@Juxhin an "extension" is only a human notion
 
I'm having a little approach problem.
 
So I presume it's the former?
 
fge
It is the filename which is returned
 
I need to build a web browser in javafx that supports multitabs.
 
fge
The OS doesn't care when it sees a dot
 
4:33 PM
Ah alright, thanks. Does make sense
 
Except, the problem is, I can't get the url box to listen to the right tab.
 
fge
(well, DOS cared)
 
It remains the same for all tabs, which makes the webview in only the first tab go to the url.
 
Store it's value somewhere with the tab and make it change depending on which tab you're in...
where's the problem? @DemCodeLines
 
I can't put the url box inside the tab, it's required to be one global box.
The problem is attaching it to individual tabs.
 
4:38 PM
I still don't see the problem..
you just need to change it's visible value when changing tabs, right?
and the tab's corresponding URL can be stored along with the Tab's controls, right?
 
each tab has a webview inside it
 
so?
I still don't see the problem....
 
I can't figure out how to store individual tab's history.
 
use a mapper?
tab id -> stuff for each tab
 
basically, when the user types in a url and hits go, that url is stored in the url comobox, I need a way to do that for each tab, so each tab has separate history.
 
4:42 PM
Map<Integer, TabContent> map = new TreeMap<>();
 
fge
@Unihedro why a TreeMap?
 
@fge whatever map will do really, but I like using treemaps when T is a number
 
fge
@Unihedro a TreeMap is a waste if you don't need ordering
 
Hmm, really?
 
fge
(as in "natural ordering"
Well, yes
 
4:44 PM
:O
They really need to implement JSON objects in the java api.
 
fge
@Unihedro coming along with javax.json
 
Wait, really?
 
fge
JBoss already has an implementation of it and it's a pretty good API
 
how do I get the index of the currently selected tab?
 
fge
Unlike Jackson, javax.json's JsonValue is immutable
@DemCodeLines may I suggest you read this? mangstacular.blogspot.fr/2014/05/presenter-first-overview.html
(this post should imho be a permanent "fixture" to this room)
 
4:46 PM
not to be rude, but what relevance does that have to getting the currently selected tab's id?
.getSelectionModel().getSelectedIndex()
 
fge
Well, the base desing makes it easy to know this information, that's why
 
@fge Why does my kitten sense tell that the blog is written by Michael?
 
fge
@Unihedro you're exactly right strokes the kitten
 
:O
room topic changed to Java: Holy cow! It's Java! | "Presenter First: An Overview" linked for your convenience: mangstacular.blogspot.fr/2014/05/presenter-first-overview.html [java] [javabeans] [java-ee] [javafx] [jsp] [servlets] [swing]
 
Now the problem is, how do I attach the map to the combobox.
I initially thought of doing a forEach and adding items to the combobox everytime the currently selected tab has changed, but I have no clue how to detect when the tab has changed.
 
4:53 PM
Hello. If it is possible to post links here I
 
Since asking the question it hasn't even been an hour....
relax ;)
 
fge
@Unihedro just opened an account at readthedocs; since the format is markdown I shouldn't have much difficulties
 
:D
Enjoy! I'm going to sleep!
 
Alright, final question, ready?!
 
Nope, wait a bit
 
4:57 PM
Getting ALL the values from a key
 
or a byte, if you have that many bits
 
fge
@DemCodeLines what key?
 
I initially did Map<Integer, String> map = new TreeMap<>();
Integer became tab index id, so unique
String became url.
 
fge
Eh?
Why don't you store them as URIs?
 
so there were multiple entries in the map with same Integer, but difference String value.
 
fge
5:04 PM
@DemCodeLines not possible
 
But it looks like it doesn't work like that.
What alternative do I have then?!
 
fge
Depends on what features you expect from your keys
Err
 
Replace String with a collection like arraylist
 
fge
Values
Basically you want a stack
 
And ensure collections are created
 
5:05 PM
I literally just need to track down a list of Strings (URLs) for each tab id.
 
fge
I'd suggest ArrayDeque
Or just go Guava
And use a Multimap
Well, just go Guava in any case, it's never a loss
 
I can't use third-party.
 
@fge I am not sure wether a queue-like access is a good idea here...
I'd suggest some array-based storage..
 
fge
@Vogel612 true, you would lose the forward function
 
0
A: Java 3D array assign values

UnihedroFirst of all, variable fields usually start with lowercase with camel text by convention. static String[][][] school= new String[1000][20][5]; Secondly, arrays do not work like this. String[][][] holds {{{entry...}entry...}entry...}. The entries may contain duplicates, which makes it an unfeas...

 
fge
5:07 PM
Well then, a wrapper over a List
 
and the backward and jump around function, too...
yes probably.
 
Something like that. But collection s instead of maps
 
alternatively a List over a wrapper...
 
fge
@Vogel612 uuh, explain
 
List<ContainerClass>
with ContainerClass being similar to a C-Struct
 
fge
5:08 PM
@Vogel612 I fail to see how this would provide backward/forward navigation
Anyway, the basic problem has been solved, now a solution needs to be picked
 
you navigate over the list
and not the container-class...
 
this sucks!
i'm done!
 
fge
Meh, actually the design of java.nio.file is very smart in some places but in others it... Uh... scratches head
Still, it's infinitely better than whatyouknow (not difficult to be n times better than 0, right?)
 
5:41 PM
What's the meaning of instance in java?
some says instance is equal to java.
but in some books, they says like "create an instance for this particular object"
i'm so confused with the instance.
 
fge
@AvinashRaj for a class C, an instance is a concrete, standalone existence of type C which you have built (using new most of the time)
It does not know about any other instance
 
@fge I thought of different solution
 
If I have a 2D grid consisting of tiles, lets say in total 172 tiles , and I want to find all possible paths, will the amount of paths then be 172*172?
I've been sutck on a bug for a while and it made me think that maybe the total amount of paths is 172^172, instead of 172^2
 
yes it probably is, depending on how you define "path"
 
5:55 PM
A* star pathfinding from A to B
The way I did it was to code a two-dimensional for-loop, both which cycle trough ALL the tiles, the first for loop cycled trough what would be the start point of the path, and the second loop would cycle trough what would be the end point. So I got two variables: Start and End, which I gave to the pathfinder class
 
fge
@user1658294 SO is not really the site to discuss algorithms in depth
Other StackExchange sites might be more appropriate
 
Ah, sorry got carried away :)
 
fge
6:39 PM
@user1658294 no worries, I easily get carried away as well
 
fge
7:02 PM
After box.com --> java7-fs-more
MoreFiles, MorePaths -- easy recursive copy and deletion, path resolution as you expect it to work, easy query of attributes etc
 
 
2 hours later…
fge
8:34 PM
Masters of their instruments at "work" (pleasure, really...)
 

« first day (1507 days earlier)      last day (3438 days later) »