/dpt/ - Daily Programming Thread

General Programming Thread edition

Previous thread What are you working on, Jow Forums?

Attached: 1537999538766.jpg (1125x1476, 283K)

Other urls found in this thread:

introcs.cs.princeton.edu/java/home/
book.pythontips.com/en/latest/map_filter.html
youtube.com/watch?v=8W5Jd_wzB90
twitter.com/NSFWRedditVideo

heh thats a nice picture
these are often very good

Im trying to make a simple application that takes the input [point/coordinates]
and sorts them into different arrays for 1st of every pair being the domain and the latter being the range
im not sure if there is a specific syntactical way of doing this in python ; take the first value from a point in an array and sort it into a subsequent array

Why do "programmers" who are also "writers" and "code architects" and "designers" always put animals on their books? Do they have a sick fetish? Why are they always full of shit?

>why do these programmers keep writing books about programming?
>Do they have a sick fetish for programming or something?

cause animals are relevant

Attached: developing.jpg (600x788, 87K)

introcs.cs.princeton.edu/java/home/

Thoughts on this?

Edie Freedman, a designer at O'Reilly Media thought Unix is weird and so are old engravings of animals so he put the two together. Tim O'Reilly liked it so they went with it.

I'm more curious about the SICP cover, why does the table have that weird leg?

Attached: sicp.jpg (1152x720, 83K)

gabu a cute

Attached: gabu.jpg (800x450, 78K)

I'm struggling with organizing structure of my projects. Especially constantly growing projects at work, that start as simple webservice ("we need it small and simple and on yesterday") and then grow to enormous proportions, with business logic scattered between controllers, models and helpers.

Is there some way to prevent it? Do you use some scalable project structures? How do you organize your code?

The maiden stands for functional programming. She's a maiden (i.e. a virgin) because functional programmers can't do anything that has side effects. The table stands for COBOL. That's why it has a demon foot. The bowl stands for riches, which rests on COBOL, because at least you can use COBOL for writing a business application. The maiden is being tempted by the table to give up on Lisp and write something that people will actually use. That's why she's pointing to the table. The wizard is attempting to dissuade her. The pointy things in the wizard's hand are for killing the maiden if she refuses. (Functional programmers get testy in the presence of COBOL.)

>user I need you to write a flexible framework that grabs the latest build JAR from Artifactory but saves the current JAR if there is one and maybe connect to the current builds on Git and convert them to JAR using some remotely deployed process you'll need to source from some department not involved with us and you need to write it all in a way that can be explained to other devs in a single PDF page and have it all launchable and controlled via gralde commands

Attached: 1542404966331.gif (394x383, 15K)

like this?

>>> input_array = [(2,1), (1,4), (3,5)]
>>> output_x = sorted(map(lambda i: i[0], input_array))
>>> output_y = sorted(map(lambda i: i[1], input_array))
>>> output_x
[1, 2, 3]
>>> output_y
[1, 4, 5]

very deep lore

nobody cares

I want to invent my own programming language with two types, word and address.

"nah i'm good, see you later"

i started maybe like a week ago , is this sorting by this lambda function ment to be learnt by beginners ie; am i learning python wrong

nobody cares?

O'Reilly books are (usually) great, you mongoloid.

new to c
plz rate
#define max(a,b) ((a) > (b) ? (a) : (b))

void longest_common_subsequence(char *a, char *b, char *out, size_t len) {
if (!a || !b || !out)
return;

char *l = calloc(len + 1, len + 1);
if (!l)
return;

char *r = calloc(len, len);
if (!r)
return;

for (int i = len - 1; i >= 0; i--) {
for (int j = len - 1; j >= 0; j--) {
if (a[i] == b[i]) {
*(l + (i * (len + 1)) + j) = 1 + *(l + ((i + 1) * (len + 1)) + j + 1);
*(r + (i * len) + j) = a[i];
} else {
*(l + i + j) = max(*(l + ((i + 1) * (len + 1)) + j), *(l + (i * len) + j + 1));
}
}
}

size_t i = 0, j = 0, k = 0;
while (i < len && j < len) {
if (*(r + (i * len) + j)) {
out[k++] = *(r + (i++ * len) + j++);
} else if (*(l + ((i + 1) * (len + 1)) + j) > *(l + (i * (len + 1)) + j + 1)) {
i++;
} else {
j++;
}
}

free(l);
free(r);
}

C-- had something like that, iirc

Lambas are retarded functishit and should be avoided by any high IQ person

unreadable garbage/10

so how would i do what i said in without it ?
i mean it worked, and i sorta get how it works, is there a better alternative and why is it better ?

its just a function without a name

map(lambda i: i[0], input_array) is just for taking the first element of each point in input_array. Its roughly an equivalent of running for loop, so you could do it like that:
x_elements = []
for i in input_array:
x_elements.append(i[0])
output_x = sorted(x_elements)


but with map is more elegant

map(f, l) basically runs function f (so lambda i: i[0] in example above) for each element of list l
check out this link for further reading
book.pythontips.com/en/latest/map_filter.html

Write a callable method like a non-degenerate

Don't listen to pajeet, lambdas are fine.

Any recommandations for quality resources where I could learn sorting algorithms?

i understand, that was my original question. i dont know how to, so i was asking, im not familiar with the python syntax

how can I improve the readability?

Attached: CLRS.jpg (297x335, 20K)

ctrl + f (you)
8 results
good thread

>im not familiar with the python syntax
you could improve your python programming skills very fast by learning basic python syntax before asking questions on vietnamese tapestry forum

this book is the pinnacle of retardation. absolute terrible garbage.

Its easy just
def myFunction(paramater) :
doSomething()

why's that?
Ive been looking for an algorithms primer.

im trying, i cant find reliable sources anywhere to teach me, either people are telling me step by step how to print out a string or they are praising OOP and sucking its dick while not explaining shit and speaking in terrible abstractions
any good starting point ? im just pissed from all the missinformation

whats wrong with using print to console statements to debug

have i been programming wrong the last 3 years

autists like me care

Go to the Jow Forums wiki and get one of the recommended books (Specifically 'Automate the Boring Stuff')
Always use books and avoid stupid pajeet webtutorials

kys

thanks man, most coherent advice and explanation so far

thanks man, most coherent advice and explanation so far

JavaScript rocks!

Attached: js_rocks.png (1433x779, 473K)

It's mostly this shit:

*(r + (i * len) + j)

Simplest thing would be to just use a VLA since you're freeing anyway.

char r[len][len];
r[i][j]

thanks user

I've read that a lot of C programmers dislike VLAs - is this really true?

It definitely would make the code cleaner, in this case.

In Clips interpreter i did

(setf x '20)

And then

(+ x 14)
gives
34
Why? '10 with ' is quote, right?

use pastebin/dpaste
don't use one letter variables other than i and j

vla are tricky
different platforms restrict vla size

>He doesn't know that's an O'reilly thing

Attached: 0072 - gu0XYfy.jpg (234x250, 10K)

>never write comments
>write unit tests ad hoc without much organization
>always debug using printf
>sometimes copy paste code
>trash variable names
>use global variables

when i make my github and upload my programs there, should i go back and write some comments, try to tidy up

the stuff works
idk about clips, but im rpetty sure in regular scheme, if you do (eval (quote 10)) you will get 10

and (+ x 14) will first eagerly evaluate the arguments

did you not read sicp

VLAs are considered bad because you can't check how much stack space is left so you might blow it up, you can't check if it fails like malloc.

For your exercise program, it's fine.

Why have you not killed yourself yet?

Quote returns its argument unevaluated.

Basically, when the Lisp interpreter reads "10", it creates a numeric object "10". Then, you quote that numeric object, which simply results in the numeric object being returned. You may also evaluate numeric objects, which results in the original numeric object. There's no need to quote self-evaluating objects such as numbers or strings.

(= 10 '10) ; T

how many books has he written
does he secretly have some brilliant strong AI program that writes the books for him
whenever i come across one of his books it's often a pretty hefty tome

how does he do it

He's just a super high IQ autist. Just be glad he cares this much about helping out his developer bros

I think imma fail a course and make parents waste 1.2k dollars to retake the course
h-hug me

Nothing. It's a tradition going back even before there were consoles to print to. In this talk, Niklaus Wirth (creator of Pascal) gives an anecdote about how they would use an instruction to ring a bell at certain parts of a program written on punch cards to debug:
youtube.com/watch?v=8W5Jd_wzB90

But you should still be aware of and use debug tools like gdb and valgrind. Not all types of errors can be debugged with print statements alone.

Attached: laughing_crows.jpg (900x600, 68K)

what course ?

idk, i never liked any of his books i came across
too much
>and now there is this feature and this feature and this feature
valgrind is awesome, i never use gdb, seems it might take me too long to learn

i gotta say, some of the most valuable lessons i've learnt are from zed shaw - use a text editor not IDE, use the cli, use valgrind

sorry for cursing on 4channel
kys

Retake the course, not just repeating the exam?

>Advanced Java

Is this a college course?

Yeah apparently
It's an elective but since small university we had no choices but this

>"""Advanced""" java
>still living off parents
Absolute state of this dude

no other option to both
minimal wagekeking here is like 200-250$ a month
Doesnt even cover basic shit let alone school

So you're stupid and poor. Quite a combo you got running there

my parents got money its okey
i just feel bad for failing
>stupid
yeah for java maybe
fuck that shit

That is literally what maven install does

watching this makes me feel guilty my own compiler is a piece of trash that has the simplest and most memory inefficient garbage collection ever
8 gigs of memory, what a luxury

I couldn't find the stupid questions thread so here it goes, how many times does the done() method execute in jade?

Do numbers in lisp are nullary functions that returen themselves?

I know but my firm uses three extra layers of worthless shit on top so I have to use them

I feel you bro. At least you don't have PCI compliance bs to worry about

>tfw passed my first interview today

What happens if you don't do your programming job properly?
Do you get fired?
I'm always shit at debugging

You get promoted to a managerial position

this unironically

I mean, you might be able to think of them that way, but that's not how Lisp views them.

Lisp has two fundamental types of objects: atoms and cons'. Everything that is not a cons is an atom:
(consp (make-array 10)) ; NIL - an array isn't a cons
(consp
(consp 1) ; NIL - a number isn't a cons
(consp nil) ; NIL - nil isn't a cons
(consp (cons 1 2)) ; T - a cons is a cons
(consp (make-hash-table)) ; NIL - a hash-table isn't a cons


Lisp has a few simple evaluation rules:
* quote[s] = s
* all atomic data-structures except symbols evaluate to themselves (including functions)
* symbols are evaluated by searching the d-list for the relevant binding
* eval[cons['cond, rest]] = [null[rest] -> NIL
| eval[caar[rest]] -> eval[cadar[rest]]
| T -> eval[cons['cond, cdr[rest]]]]
* eval[cons[a, rest]] = apply[a, eval-list[rest]]

>tfw not sure if I'll go to a final interview with a Managing Director of Accenture tomorrow morning or just stay in bed and sleep because I don't actually want the job

Do you want the money though

I'll probably be paid less than my current job. Accenture seems only suited for people interested in sales who can't produce shit themselves

how do I name my threads in Rust? in Go I name them Gophers and they are cute all working together >.

"kill yourself"

Crabs

>the life of a soi-developer

Alrighty Jow Forums
I'm trying to login onto a website with python using a post request.

When I do the login authentication via Chrome the browser runs a script named ioBlackBox which puts out an authentication string which it passes along to the target website with the post request. The script seems to be integrated into the website and my question is how I would go about running this script on Python so I can log into this website without using a browser.

Thanks!
J

Free coffee is a free coffee...

that's pretty easy and in my opinion sounds like a very clear specification for a language, which means it's very doable

basically you can either compile to C and use pointers and words

OR you can actually directly compile to assembly (with or without an intermediate of your design)

i like it, and you can actually do all kinds of programming using such a language

your specification lacks one thing though, the data at the addresses are you going to garbage collect it or leave it to the programmer to figure this out

>Thanks!
>J
anyways. the request module makes this easy with requests.Session(). if you're more stubborn like me you could try and use urllib.request but it requires more steps and everywhere you look everyone recommends the request module because learning how http works is too much work for python programmers.

Attached: 1544314147260.jpg (540x960, 35K)

Stop posting that disgusting thing.

>requests.Session()

I'll see how that works. So far I've been using requests.post(url, data) to the website's login server. Perhaps session() is a bit more robust. Thanks

Attached: 01e676cccfad997657c45507af08b9ab.828x828x1.jpg (828x828, 68K)

>have a Python script to do some stuff I often do, placed at /home/user/foo/bar/foobar.py
>have symlink set up (/usr/local/bin/foobar -> /home/user/foo/bar/foobar.py) to use 'foobar' freely
>decide to rewrite the thing in C so that it's faster
>place my C project in /home/user/foo/bar2
>compile and install it with cmake (standard mkdir build; cd build; cmake ..; make; make install)
>everything seems to be working nicely
>go back to my Python script to check something
>it's binary? wait, what?
>check 'which foobar'
>it's still a symlink pointing to /usr/local/bin/foobar -> /home/user/foo/bar/foobar.py
>cmake's install overwrote the symlink target (i.e. the Python script) with the C project binary

Am I the dumb one here? I would have expected the default install behavior to be either copying the binary to /usr/local/bin or setting up a new symlink to the /home/user/foo/bar2/bin/foobar binary. I guess it makes sense since replacing the symlink target is less likely to require elevated permissions.

Attached: brain gremlin.png (766x432, 392K)

wait what
but aren't they in different folders
wow i saw this comic
can i have more of this 19 yo girl

>girl

Yes, they are in different folders. The cmake install apparently resolves the symlink and replaces its target (wherever it might be) with the binary.

Definitely not what I expected.