« first day (1587 days earlier)      last day (3348 days later) » 

fge
12:22 AM
Uhm, why? It's easy enough to write yourself
 
But then I'll be writing it every time. It's a standard method, it should be in the standard libraries.
 
fge
IntStream.range(0, arr.length).forEach(index -> { arr[index] = supplier.get(); })
 
37 mins ago, by Unihedro
IntStream.range(0, INPUT_SIZE_1).forEach(x -> {
  input1[x] = gen.nextInt(UPPER);
});
I just wrote one of that half an hour ago. :p
This method, again, loads four dependency classes, whereas a straightforward loop does none of that. While it's not performance-hurting, it has unnecessary side effects. Or rather, it's a non-pure function!
 
hey @Unihedro what was the thing you mentioned you can put in your software project to prevent people using your code without permission. lol
 
... prevent... copyright?
Do you mean... like... the other way? protecting your copyright?
 
12:27 AM
^
 
simply don't do anything, and your code is YOUR intellect property. No one will be free to reuse, redistribute, or claim as yours under your liability.
It's in the Digital Millennium Copyright Act.
If you find someone stealing your code, you can DMCA (that term above) them to takedown their material.
Or even to sue them!
But that's expensive.
 
fge
There's another solution
 
However, as an open source developer, you'd likely put a kind of open source license to your code
 
fge
Stream.generate(supplier).limit(theSize).collect(Collectors.toArray())
 
which is a non-revoking license which grants users rights to use your code under use terms and no liability and fancy stuff like that
You can check out licenses you can pick that most of us recommend here:
 
12:29 AM
is there any generic open source license I can add to it? not saying my code is genius but want to include it in my college project.
 
Wait, it's a college project? Then I have a recommendation for you
 
(y)
 
Don't mind the fact that it has the word "crap" in it, it stands for "the Community Research and Academic Programming License"
 
lol just noticed that
they had to have called it that on purpose
:P
 
:p
 
12:31 AM
do I just add it as a text file to my project, like copyright license or something
 
go to section "How to use the CRAPL"
it has instructions.
Basically, download this file, add it in the root directory of your project, then write some kind of readme indicating that reuse of the code must comply with the license
 
thanks
 
You're welcome
Good luck with not getting yelled at by your teacher after reading the use terms of the license your college project!
 
lol
 
@fge Huh, that's awesome!
Because a stream doesn't compute each element until a terminal operation occurs, the fact that an infinite sized stream is created doesn't induce expensive computation as I expected.
Except... Collectors.toArray() does not exist ;-;
well, you have to use toArray() instead of .collect(Collectors.toArray())
 
12:43 AM
looking forward to starting this web spidering application, haven't received the spec yet though, last major Java project before I finish college :)
 
gl hf :)
Except... It's kind of wasteful that you end up with an Integer[] and not int[]
you have to use .mapToInt(x -> x) for unboxing
 
Question, do y'all always use static in your function declarations? I've noticed in many OOP projects there is a mix between statically referencing an object, versus just calling this.var
Why use static at all when you can just refrence thru 'this' ... is it the norm to keep everything static (even in php projects, i see a mix)
 
Is this a Java question?
 
im working with java right now, so yes. for example, i always taught to begin with public static void main(String[] args)... but then I keep up with declaring variables statically. is it okay to refrain from using static at all?
in OOP
 
In Java, it's a good practice to keep the use of any scoping to the instance level. At very few times is static used.
While the main method is static and most utility types uses static methods, instance methods works better.
For example:
main(String... args) {
  Main main = new Main();
  // do stuff with main, instead of calling static methods in scope
}
 
fge
12:56 AM
@Unihedro uh yeah, that's right; it's Stream which has .toArray()
 
12 mins ago, by Unihedro
Except... It's kind of wasteful that you end up with an Integer[] and not int[]
also that
generate gives a T[], int is not a dimension of T, so it's boxed into Integer
1 message moved to Trash can
 
fge
Well, .mapToInt(Number::intValue).toArray() then
 
or you can use mapToInt x -> x
thanks to syntactic sugar :p
 
fge
And IntStream also has .generate() anyway
 
it does?
...
 
fge
1:00 AM
Yes it does
 
That made life so much easier
 
fge
IntStream.generate(someRandom::nextInt)
Meh
 
wait, I need to pass a parameter
 
fge
Well yes
An IntSupplier
 
I mean, into nextInt
As you do someRandom::nextInt, the MAX_VALUE version is called
so it has to be () -> someRandom.nextInt(6), unfortunately.
 
fge
1:02 AM
Uh
Look at the Random class' javadoc :p
 
/**
 * Returns the next pseudorandom, uniformly distributed {@code int}
 * value from this random number generator's sequence. The general
 * contract of {@code nextInt} is that one {@code int} value is
 * pseudorandomly generated and returned. All 2<sup>32</sup> possible
 * {@code int} values are produced with (approximately) equal probability.
 *
 * <p>The method {@code nextInt} is implemented by class {@code Random}
 * as if by:
 *  <pre> {@code
 * public int nextInt() {
 *   return next(32);
 
Wait, what?!
aaaaahhhhh
Now the entire program is in one line!
 
fge
and here the developer recalls the value of documentation
:p
 
printStats(rand.ints(20L, 0, 6).summaryStatistics());
done in five minutes
A++ will totally use Random again
the scream of awesome
 
fge
1:10 AM
Don't tell me that's for some code golf again?
 
no
the person in the room looking for me earlier, needed some scrap code
i'm refining the scrap code to presentation quality, and then mailing it to him :p
 
1:33 AM
Hi all
I have a quick question. How can I check Inf value in the sqlite database row?
Some values are recorded as "Inf", although the others are just fine and float
 
1:44 AM
Just curious, is there a way to get a website's JavaScript content through Java? If, so please notify me. Thanks.
 
@Lucas I believe Selenium has a java class you can use for webscraping
 
@LucasBaizer yes
 
2:17 AM
How to box a primitive array?
int[] -> Integer[]
 
2:35 AM
@SecondRikudo @rlemon localStorage doesn't work for mobile browsers. Are there alternatives (fallbacks)?
all operations are returning undefined
 
huh?
localStorage works on mobile
 
not on chrome for android and the iOS webbrowser
I think
 
@Unihedro jsfiddle.net/jzvzj8se works on mine
 
Gotcha, i'll go debugging
 
2:54 AM
wow, google is actually smart occasionally
 
3:41 AM
@sec @rlemon are localstorage browser specific or per se website?
 
4:31 AM
Morning
 
Morning
 
@ItachiUchiha why not both?
Or did you mean that regardless of browser, the local storage would be the same, if it was website specific?
 
 
1 hour later…
5:37 AM
@Gemtastic Consider a scenario, where it is browser specific. My website x.com stores a key localstorage.put(key, value1) and then I browse into y.com which again stores a key localstorage.put(key, value2) <<< Under such scenario, the value stored by x.com is lost. I am sure, this doesn't happen. So, how is it stored?
 
Hmm
 
Hope you understand my predicament
 
Well, the thing is, even if it is or isn't stored by website, it's stored in the browser, not the tab or specific window
The browser has its own database, and databases don't null them selves every time you change site or close the browser
You could probably of course program it so that when someone leaves your site, all the saved data will be lost (but then i wonder why you'd chose to save to the local storage at all)
But by default, it doesn't and that's the point.
Do I make sense to you? :P
 
No, I am talking about data getting over-written because of the same key.
 
5:52 AM
Ah
Well, That remains to be known. :p
 
6:14 AM
@Ita why don't you migrate the question into the HTML/CSS/Webdesign room?
There are people active in there who might know
I hope you don't mind the invite
 
6:25 AM
lolz..
I will wait for @SecondRikudo since people you don't know, often make fun of your area of weakness
 
They are kinda nice in there as long as you don't help vamp. You had a real question
I can ask it for you?
 
fge
Moo
 
Heya!
 
6:41 AM
@Gemtastic Well, if you did understand my question, go on !
 
Good morning, Java
 
7:13 AM
@ItachiUchiha I got no response so, I suppsoe we'll have to wait for second lemon
 
No Worries! I am in no hurry as such. Thanks for the effort, though.
 
 
1 hour later…
8:17 AM
Dead Room?
 
8:28 AM
@ItachiUchiha It's not lost.
localStorage is per site
You can store the same key in x.com and y.com, and they'll be different.
More accurately, localStorage is per domain
so x.com, www.x.com, y.com are three different "sites".
 
@SecondRikudo ahh! cool!
 
@Gemtastic ^
 
9:38 AM
hmm?
Well, now we know ^^
 
=)
@Gemtastic can has link to your webapp again?
 
@Gemtastic take it as a challenge to rewrite it with better practices.
Delegate more control to client-side, and get rid of singletons :P
 
I already have
 
9:52 AM
taken the challenge I mean
 
Already took it as a challenge, or already rewrote it? Ah. :P
 
I'm gonna rewrite it when I'm done with this course's project
how do you strike out text?
 
Don't bullshit me, magic is just science you don't understand
 
You're a smart girl, I'm sure you'll figure it out :P
@Gemtastic s/science/stuff/
 
9:54 AM
That was not it
 
@Gemtastic hint: RTFM
 
Where is the f*** manual? XD
It only mentions bolding and italic where I read it :(
 
I actually did google it, but it didn't amount to anything :(
fucking finally
 
@Gemtastic now, 10 points to you if you can figure out why this thing happens if you star this message. ‮
 
9:57 AM
why what thing?
 
@Gemtastic Star it.
=)
 
lol
I have no clue :P
I don't know how to see it unformatted
 
​
Also, reverse pinging! ‮@Gemtastic
 
^ that's what I figure, but since I can't see it unformatted...
 
10:06 AM
Was there a specific reason why you wanted to have a second look at my webapp?
 
@Gemtastic I haven't completed my review and accidentally closed the tab a while ago.
 
Ah :)
For someone who's never made a webapp before and who had to learn it in a week, how do you think I fared?
(the html/css I knew before but not JS)
 
Divided everything into functions, not bad for a beginner
But I guess that's the Java dev in you :P
 
I've only done Java for 6 months
 
Worth noting, JavaScript got modules very recently (and it's still not widely implemented)
That means that all JavaScript files are implicitly on the same, global scope.
To prevent collisions, it's considered good practice to wrap each file in a self invoking function
 
10:12 AM
No prior programming to that. Unless you count the C++ course I took in senior high, and compare that to the java beginner course, it doesn't really count imo >_>
 
Taking contact.js as an example (because it's the shortest):
(function() {
    $(function(){
        $("#contactMessage").on('submit', function(e){
            var messageForm = $("#contactMessage");
            e.preventDefault();

            $.ajax({
                "type": "POST",
                "url": "/LillaKammaren/contact/sendmessage",
                "data": messageForm.serialize(),
                "success": messageSent
            });
        });
    });

    function messageSent(data){
        location.reload();
        $("#msgSendingSuccess").append("Ditt meddelande har skickats!");
 
In hindsight I figured that it's probably better to just stick to as few JS files as possible
 
@Gemtastic Not necessarily.
In production you generally want, unless you have monstrous amounts of JS, one bundled file.
There's absolutely no reason why it should be the same in production.
Just like in Java you have multiple .java files, but it ends up being packaged into one executable .jar file.
 
Well, I did notice that my functions were repetitive and I could have made then dynamic and more DI
 
JavaScript has tools to do the same on build time (somewhat comparable to Java's compile time)
Yes
Another thing I see at contact.js
$("#contactMessage").on('submit', function(e){
    var messageForm = $("#contactMessage");
Why not
var messageForm = $("#contactMessage");
messageForm.on('submit', function(e){
 
10:16 AM
the answer to why not is simply because I'm inexperienced. I didn't really read any manuals on JavaScript; I just looked at some syntax in my teacher's code and mimiced it
 
variables are cheap, DOM is expensive. What $("#contactMessage") does is traverse the DOM tree to look for the element with the ID contactMessage
You're doing that lookup twice, instead of once :)
 
@SecondRikudo yup, that's partly what I meant with repetetive and not dynamic
The thing is that I was unsure of how I could use JS, in reality you probably can do exactly the same since I understand it that they both are OOP?
 
@Gemtastic In 95% of the cases, client-side JS is 95% about the DOM
 
nods
 
Make this element have this classname, make that element change text
 
10:19 AM
nods
 
JS gets a lot more interesting when you use it as an actual language on the server-side
There are a few bad practices in your JS code, but I wouldn't guess that this was your first time coding JS, if I hadn't known better.
(That was a compliment, your JS is much better than your average noob)
 
@SecondRikudo I think it's because JS can do those things that so many people make JS do things it's technically not designed for.
 
@Gemtastic People take JS as this freeform language that can do pretty much anything
And it can
But that freedom requires discipline :)
Discipline most developers don't have.
 
@SecondRikudo While I do reserve myself on the point that I probably already know what you mean, those bad practises are things I want to know so I can fix that
@SecondRikudo truth
 
@Gemtastic the ones I spot are
- Wrap each file in a self-invoking function. `(function() { YOUR CODE HERE })();`
- Don't rely on outer scope, pass arguments directly.
- Variables are cheap, DOM is expensive
Point 1 in your specific case can be further refined
You're using a global variable in all of your files
Can you spot it? :)
(The same global variable)
 
10:26 AM
wait, I gotta open my project and look XD
 
well duh, message form :P (I have no idea)
I'm using data an awful lot if that's what you're referring to?
hmm so it's counted as a global variable.. guess it makes sense
 
Nope, it's not that
Another guess?
@Gemtastic ^
 
10:43 AM
I'm sorry to say no. This is what happens when you don't RTFM XD
 
fge
@SecondRikudo location?
<-- doesn't know JS
 
is it e?
 
I thought that was a jQuery thing O.o
you're not supposed to use it?
 
Doesn't make it any less global
 
fge
10:45 AM
Yeah, indeed, $ is globally defined by jQuery
 
that makes sense
 
fge
But then how would you go not using it?
 
It's okay to use it
I'm from mobile so can't write code
 
And it fills in a big questionmark I had about jQuery back-end XD
 
Will demonstrate later :P
 
fge
10:46 AM
Well, this $ has to come from somewhere after all
 
@fge that's what I was wondering; where does it come from? what is it?
 
fge
Well, when you source the jquery main file, this is the "variable" which holds everything
And it has "variables" which are, in fact, functions/methods/whatever
(JS does have functions as first class citizens, unlike Java)
github.com/fge/json-schema-validator-demo/blob/master/src/main/… <-- the only JS I have ever written in my life
And I know it sucks all right
 
@Gemtastic when something is set on the window Object, it's globally available
That's what jQuery does
 
You know how this subject was covered in class? "I just googled and copy-pasted this function off of Stack Overflow. It's jQuery, you don't have to know more."
I can't tell you enough how much I appreciate your help
 
When I get back to my pc I'll show you how to somewhat mitigate the global problem
 
fge
10:55 AM
Hooo
Someone has contacted me from Spain due to my SO profile
 
oh?
 
fge
A "parser for Sonar", huh
 

« first day (1587 days earlier)      last day (3348 days later) »