/dpt/ - Daily Programming Thread

old thread: What are you working on, Sup Forums?

Other urls found in this thread:

spark.apache.org/
twitter.com/SFWRedditImages

First for Gambas!

Making some art

im gay

>Gambass

suck my cock faggot

no youre not lol

Being mocked by someone who posts animu unironically is actually very encouraging.

looks like a sword

Ok, heres an stupid question.

Im using Netbeans 8.1 with JDK 1.8 and I'm trying to make a JavaFX project.

Problem is I cant find JavaFX anywhere, not when i choose Add-> Other, nor in Tools -> Options -> Java

Im using Linux, Elementary OS.

Been googling but cant find anyone with the same problem. How do i even link Scene Builder with JavaFX in netbeans if I cant find JavaFX in Tools->Options -> Java.

>mfw when people thinks it's fine to post traps without first editing programming related dialogue/objects into it first

Repostan because I have awful timing

I'm doing something in c++. To make this shorter let's just assume that vector in the following text is std::vector
class foo{
vector *_v
...
setV(vector *other){
_v = other;
}
};
...
vector a = new vector;
foo f;
f.setV(a);

This worked fine, I could access the _v in f, but when I changed it so that _v is just an object, not a pointer, and that setV takes a reference to a vector the program later crashes when I try to access the elements inside. i checked in the debugger and the elements inside other in the setter function are all null. Why is this happening? I thought passing references was used exactly for this, to avoid fiddling with addresses when you don't have to.

Interesting. What about this one?

they're all null because you're deleting them at some point accidentally


make your data members const

Working my way through some Clojure exercises.

>complaining about animu on an animu website

Same here dude. Look at my art.

like a shooting star

Try setting _v to the pointer of the object instead of the object iself?
I dont know C++, im just a superior C dev.

these are pretty cool dude, how are you generating them?

I made a bad example, the vector "a" in the code above isn't actually declared on the spot, its a field of the class inside of who's method is setV called, so "a" is stable until the program terminates. Not to mention that if that what you told me was true then the solution with pointers wouldn't work either. the program crashes only when I implement it with references.

what if tinder but for turds

Turder?

What's that smell? I smell trillions of dollars

You are right though, I could just go back to pointers, but I wanna figure out why references aren't working.

What's the best book for learning cpp?
Is it Programming: Principles and Practice Using C++ (Bjarne Stroustrup). For a beginner..

They're n-body simulations.

monospaced fonts are over-rated for programming
Not pointless, but very over-rated.

>mfw Verdana

In c, if i have
struct vec3 {
float x;
float y;
float z;
}

struct vec3 myVec;
myVec.x = 2.0;
myVec.y = 1.0;
myVec.z = 0.0;

struct vec3 *vecPtr;

vecPtr = myVec;

it sets vecPtr to the 1st 8 bytes of myVec, which would be 00, 00, 00, 02, 00, 00, 00, 01.
not to the pointer of myvec.

I'd not considered the artistic implications of n-body simulations :-D

thats pretty cool of you, if you don't mind what language are you implementing them in?

>what is indentation

You're not writing a book, you're writing software. Get real, loser.

So do you have particles of differing masses and do the gravity calcs of them to determine there paths? Is the color velocity or something? Looks cool

>there paths
t. ameritard

You're going to need to post a bit more code then, what your explaining should absolutely work.

thats not a healthy shit fix your diet

But if i have the myVec i already made,
and..
struct vec3 secondVec.

and i do

secondVec = myVec.
It will copy the data from myVec into secondVec. then i can edit one without effecting the other.

Mathematica

All the particles are of mass = 1 and also G = 1 just for simplicity

The color represents the position along the trajectory

>Mathematica

...

>Mathematica
Absolutely Wolfram.

Name me one scripting language that doesn't suck.

Hey, when I run this C code:

main() {
long wc = 0;
while (getchar() != EOF) {
++wc;
}
printf("%d\t", wc);
}


say i do:

1111
^Z

I get a number of 5, is it because of the null terminator at the end? aka '\0'

PHP

As a consultant for large scale data science companies, it hurts me deeply that you're using mathematica (only because it's stunting your potential not because you're lacking in any faculties) but the stuff you're doing is really cool you should keep at it.

WAIT

Yes.

I'm currently on a Java course, and my laptop almost literally blew up yesterday.

Was wondering if there's a way to set up JDK or whatever alternatives into my phone for the time being, but I have no idea about it

Any kind of help would be appreciated

>Mathematica
Wew lad how long did that take for you to run?

What was your laptop?

Any decent college will provide computers with the required development environment if they offer java courses.

>not a doujin
lame

What makes you say that?

Pretty much instantaneous.

And old Lenovo I got as a gift 4 years ago, made the mistake of putting my roomate in charge of buying a new charger due to me being busy, and then made the mistake of using it without checking.

10 seconds in, it just overheated and killed everything.

third world country, not a college course but more of a State approved course designed to generate manpower and delegated to several shit-tier institutions

>What makes you say that?
ur mum

>instantaneous
Why you gotta lie bro?

Hmm..
>Java
>Third world country
>State approved
Are you by chance an Indian?

I'm sorry to have bothered you, I made a mistake somewhere else. At the moment I called setV I haven't yet filled the vector with values, so the pointer approach still works because I access the vector after I fill it up, the reference ones doesn't.

Although I wasn't exactly looking for that, thank you for the help and a short reminder of how strcuts work in. it's appreciated.

This one is of 20 bodies (far beyond what makes for a nice looking image) and it took ~2 seconds. The previous images were of like 4 or 5 which takes on the order of 1/10 of a second.

why doesn't this work for bake and pale? why does c magically change from 2 to 0?
def one_away(str1, str2):
if len(str1) > len(str2):
originallonger = list(str1)
originalshorter = list(str2)
else:
originallonger = list(str2)
originalshorter = list(str1)
longer = originallonger
shorter = originalshorter
c = 0 # edit count
# insertion
if (len(longer) - len(shorter)) > 1: return False
if len(str1) != len(str2):
for i in range(len(longer)):
if shorter[i] != longer[i]:
shorter.insert(i, longer[i])
c += 1
if c

don't get me wrong, when it comes to academia mathematica is approachable and feature-rich to be capable of a lot of cool things. The issue is that when you start working with extremely large corpus' of data, and on your own infrastructure, it doesn't perform nearly as well as some other languages that have things like parallelizing functions across cluster nodes built in. You should keep with mathematica for as long as it suites you just start looking at things like Scala, Python, or Java for large scale things. (people who say R or Julia are cute but have no industry experience.)

Is reading and parsing a program you don't understand and investigating the things you don't get until you can understand what the program is actually doing a good way to learn?

I've found myself doing this recently more and more as a beginner and it's helped me out a lot.

yes. I've learned more from dissecting code than I ever have from any book. period.

Fix your variable names, your code is so dense because you didn't separate your logical structures.

Are you using vector or vector&? If you are using vector&: How do you initialize it?

pic related

>tfw it takes minutes for my Mathematica to calculate Maslov indices and several hours to run a simple quantum Monte-Carlo
Ok

>extremely large corpus' of data
How large we talking?

Help, I need to extract values from strings that look like either of the following:
$4,610,676 (USA) (27 December 2015) (100 screens)
Or
$4,610,676 (USA) (27 December 2015)
I'm doing this in Java and I need the first and 3rd columns. What's a good way of getting this stuff extracted into an int and a string, respectively? Thanks in advance.

...

Simplify your bug. im not going to look through 50 lines.

it depends on what the nature of the process is. sometimes I come in to help people with things that are not exactly crunching lots of data but may just be computationally intensive (monte-carlo, etc) other times it's doing lots of inline transformations on existing data (from a corpus) or doing analytics, or running long term streaming processes, or creating a node architecture for BPNN's. Most of the really interesting things I've gotten to do tend to be terabyte-petabyte in scale. I got to do some work with TRI once (toyota research international) and they operated on an exobyte of data per simulation (they generated a fuckload of sensor data during tests)

/r/egex

It's VERY easy to write slow MMA code if you're not careful, like if parts of your computations are being done in exact (bignum) arithmetic or stuff like that.

Share notebooks?

c = 0
for i in range(len(longer)):
if longer[i] != shorter[i]:
shorter[i] = longer[i]
c += 1
print(c)
if c

Even if c was 2, it wouldn't print that.

I really want to know who are you quoting.

I don't know how python interprets whitespace, is everything in the same indentation level guarded by the if statement above it?

run the code

Nice job not knowing how to read.

Yeah I probably wouldn't use it for things like that but I'm guessing it takes some pretty specialized knowledge to write programs on such a scale regardless of what language you're using.

>c

I don't believe you look anything like that picture of yourself.

>==
Instant shitlang.

justin@debian:~/python-programs$ python3 One-Away.py
bake
pale
p b
1
a a
l k
2
e e
replace str1 to str2 worked with 0 replacements
True
justin@debian:~/python-programs$

while it defintely takes a lot of specialized knowledge to create the underlying infrastructure (setting up hadoop, mesos, etc, config managing the nodes, optimizing nodes for applications, yada yada) the part *you'd* have to deal with as a developer is really simple actually ^_^ . You should take a look at Spark it'll change your life:

spark.apache.org/

works great with Python, Scala, Java, and some other stuff for real get into it.

1.) it's awesome for what it does
2.) you have Spark on your resume people will pop a major boner.

How can it be the case that I don't look like a picture of myself?

Yes, it'll only print if c is less than or equal to 1.

>>there paths
>t. ameritard
I quoted the person I replied to:

>So do you have particles of differing masses and do the gravity calcs of them to determine there paths? Is the color velocity or something? Looks cool

See at the end of the first sentence?

if you know why does c change from 2 to 1, please stop being cryptic and say

>responding seriously to a shitposter

Yes, I see now. This is indeed correct.
Do you happen to know who the other posters were quoting?
Who said that?

It's very airbrushed.

*2 to 0

I am not being cryptic. You yourself wrote that logic.

>Do you happen to know who the other posters were quoting?
No, I don't. I'm sorry.

wait do you think that

How do you write an append that does this in Prolog???:

append([a,b,c], [1,2,3], List).
List = [a,1,b,2,c,3].

How does Spark compare to Hadoop?

What are you using to learn it?