/dpt/ - Daily Programming Thread

This is /dpt/, the best subreddit of Sup Forums

Umaru-chan edition, the best of all editions.

In this thread:
r/programming
r/compsci
r/ReverseEngineering
r/softwaredevelopment

code of conduct:
no racism
no insult
no sexual harassment
no gender discrimination

wat r u working on, user-chan ?

Other urls found in this thread:

drive.google.com/file/d/0B2Y-n6IlHYliSXZxMk0xT0NSY1E/preview
learnxinyminutes.com/
my.mixtape.moe/kiuvpf.pdf
grimoire.ca/mysql/choose-something-else
jetbrains.com/
twitter.com/SFWRedditVideos

Any cheaper alternatives?

drive.google.com/file/d/0B2Y-n6IlHYliSXZxMk0xT0NSY1E/preview

learnxinyminutes.com/

Pythonfag here, running a silhouette analysis on my k-means clustered data. I have a bunch of vectors and for every one I have to calculate an AI (the average distance between that vector and other vectors within the same cluster) and a BI (the lowest average distance to all vectors from another cluster).

Here's part of the code:
for cluster,clusterNumber in zip(clusterDict.values(),range(len(clusterDict))):
aiList = []
for vector1 in cluster:
listOfDistancesAI = []
for vector2 in cluster:
distanceAI = silhouetteDistance(vector1,vector2)
listOfDistancesAI.append(distanceAI)
averageDistanceAI = sum(listOfDistancesAI)/len(listOfDistancesAI)
aiList.append(averageDistanceAI)

biList = []
for vector, clusterNumber in zip(cluster,range(len(clusterDict))):
clusterDistanceList = []
for otherCluster in clusterDict.values():
listOfDistancesBI = []
for vector2 in otherCluster:
distanceBI = silhouetteDistance(vector,vector2)
listOfDistancesBI.append(distanceBI)
averageDistanceBI = sum(listOfDistancesBI)/len(listOfDistancesBI)
clusterDistanceList.append(averageDistanceBI)
clusterDistanceList[clusterNumber] = 10**100
biList.append(min(clusterDistanceList)


The vectors are fed from a dictionary which has a key for every cluster and then a list of vectors as values. The problem is, the AI values are getting calculated just fine, but its only calculating 9 BI values. The amount of vectors in the cluster should match the number of AI and BI values. The biList.append statement is in the for-loop for the vectors, so it should be appending as many BI values as there are vectors.
As it happens, 9 is the amount of clusters I'm telling my k-means algorithm to make, so stuff might be in the wrong loop?

>C# is an elegant and type-safe object-oriented language that enables developers to build a variety of secure and robust applications that run on the .NET Framework.

A NI ME

Sounds about right.

Yes, that is correct

>20 MB

On windows how can i know if something is printing? also how can i get the page count?

On command i need this on command i have yet to find something useful

inb4 not programming i need this to implement a feature

20MB is cheaper than the book, faggot.

>the picture
holy fuck

I never really cared for anime but holy fucking shit that is the cutest thing I have ever fucking seen what the fuck

Does anyone have ideas for simple (or very slightly complicated) multi-threaded programs? Something like the DPT challenges but with multiple threads in mind.

how do i make a pair variable in scheme? i do define but it's making it a procedure and giving me errors when i try to car or cdr

producer consumer

(define pair (cons 1 2))

UMARU
Yaaaaaaasssssss boooy finally umaru-chan dpt is back in town baby

I just always wondered what 1.5k pages of book took up

nm i forgot to do prefix notation in a spot

...

Wouldn't having your computer on the floor cause a lot of upper body pain from looking down for hours, Umaru-chan desu wa?

>drive.google.com/file/d/0B2Y-n6IlHYliSXZxMk0xT0NSY1E/preview

How can I download that book?

I mean cheap as in cheap beer, not less work

What is the best way to write a database? MySQL? using it mostly for web, but has to scale up like no other, i mean like facebook size.

Running a test and dump random generated usrs in database with usrname pass folder for pics, post info, etc. Advice Sup Forumsents?

You sound like you have no idea what you're doing, but you expect to scale up to "facebook size"?

Also, I bet you were planning to store passwords in plain text.

>but has to scale up like no other, i mean like facebook size
You have LITERALLY no idea what you mean by this.

Google the term 'big data', and familiarize yourself with node-based DB systems.

Something like Facebook uses a combination of multiple DB styles, some relational, some hierarchical like MongoDB for caching.

want me to upload it to you?

just say the word

The word

here you go

my.mixtape.moe/kiuvpf.pdf

Yes, it is true anons, I am a newfriend when it comes to databases, i literally dont know shit. This is why i am asking for a point in the right direction.

Ive just read that mySQL is good, up to a certain point, then it can get slow. That is all really,

Use PostgreSQL.

Don't use MySQL.

grimoire.ca/mysql/choose-something-else

What are your thoughts on JetBrains?

really good software company soon to dominate the industry.

you have IDE's for every languag (at least , the important ones)

jetbrains.com/

just remove the /preview from the url and you'll get the google drive normal interface, with the download button at the top

they're shit, have fun paying for a fucking basic ass IDE, and top kek if you fell for the scala meme, scala is shittier and less relevant than both java and C#

>jetbrains.com/
i like the part where you felt the need to include a link to their website... shill

i want to fug sirufin

...

>scala
actually their language is fucking kotlin, even more shit and obscure

How does she slide past the green seat cushion?
Why does she have a booby mousepad with no design on it?
Where can I get a DOLL computer?

It's a cat with cheeks as the rests

fucking perv

now

that's what i call

cheeky

That's boring af tho.

Oh senpai, I got the best idea for my web based file manager. Make all functionality a plugin.

then it's not really web based is it

THAT'S EVEN CUTER

What do you mean? It's just a website for file management. I want users to choose only the plugins they want.

can someone write me a one liner of this function?


def test(a):
vp = 0
q = a[-1]

for p in a:
vp += p[0]*q[1] - p[1]*q[0]
q = p

return abs(vp / 2)

why?

test = lambda a: abs(reduce(lambda acc, (p, q): acc + p[0]*q[1] - p[1]*q[0], zip(a, [a[-1]] + a[1:]), 0) / 2)


like this?

first because i want to learn how it's done.

plus its a fun exercice and less code

Why is less code good?

compare

which one can be understood faster when something needs to be changed?

this doesn't seem to work

the a parameter is a list of tuples like this [(10,20),(56,21),(12,12),(98,88)]

you can test your one liner and my function to see if thee results are the same

>Why is less code good?
>compare

i, by no means, want to use one liners in production code, because readability and maintainability are important.

i just wanted to see what it look like and to learn how they do that

from itertools import *

def test1(a):
vp = 0
q = a[-1]
for p in a:
vp += p[0]*q[1] - p[1]*q[0]
q = p
return abs(vp / 2)

def test2(a):
vp = sum(p[0]*q[1] - p[1]*q[0] for p, q in zip(a, islice(cycle(a), 1, None)))
return abs(vp / 2)


print(test1([(10,20),(56,21),(12,12),(98,88)]))
print(test2([(10,20),(56,21),(12,12),(98,88)]))

two lines, but you get the idea. I refuse to write a messy abomination.

>which one can be understood faster when something needs to be changed?
test2 indeed, it's declarative.

>test2 indeed, it's declarative.

could you understand the code of test2 function faster than test1 ?

look

True, the error is in the 2nd parameter of the zip. Namely the a[1:]. It must be the init of the sequence, i.e. a[:-1].

I like this one better though.

explanations:
itertools is the go to for this kind of thing, although sum and zip are standard functions. I started by sum because the vp is indeed the sum of something, the sum of p[0]*q[1] - p[1]*q[0], where p is drawn from a and q is drawn from a, shifted, and that's the only subtelty in fact. I had to check the docs btw

btw it's the shoelace formula rite?

oh clearly yes! it's direct, it totally reads like English or almost. Maybe I'd do three lines and separate a_shifted in its own variable, but that's the only thing. That for loop clearly takes too long to break down.

I bought The Shellcoder's Handbook and couldn't finish the first chapter because they require you to understand x86 assembly. So where should I go to learn that?

thanks man! appreciate it!

>btw it's the shoelace formula rite?
yes it is!

r8 my reverse string function niggers

std::string reverse(std::string const& str)
{
if(str.empty())
return {};
return str.back() + reverse(str.substr(0, str.length()-1));
}

I know lambda is the way, but naming functions and values out is also an option mate. To me this version, while more true to the original, is no better than a muddy for-loop. After all, isn't the One Question to separate true masterlangs from garbage, can your language abstract away an iteration?

>r8 my reverse string function niggers

first of all, i'm not a nigger nor male.

and your function is not good!

stackoverflow/10

U welcome. Also functional constructs are the way, remember it.

except it's not
this function is so short I'm sure someone else wrote the same

it's alright user

i did an implementation of Kmeans in C++, shouldn't one of the vector distance values always be 0 because it is the distance from the vector to itself, thus giving you 0 and 9 other values?

i thought you meant like a browser plugin

do you usually write one-liners when writing code?
can other people understand?

do prefer writing it that way or normal pseudo-code?

thanks 3/2 satan

absolutely disgusting

Write something better then
teach me senpai

>nor male
are you a female or some kind of queer

post feet

>nor male
You know the rules, tits and timestamp.

>normal pseudo-code
normies can go die really.

>do you usually write one-liners when writing code?
>can other people understand?
I admit I have no experience team-programming in Python 3. Maybe if I take this internship I'm on, they'll respond that itertools is evil if I ask, I don't know.

But regardless of what the populace does, once you swallow the functional red pill, you can't forget the truth, so I hope I'll find myself places filled with like-minded folks.

btw I no Scheme isn't functional, it's just that I don't know how to categorise my preferences. Maybe superior masterrace without any adjective, idk

He asked for a one liner :P

> :p

What's a good way to get started with android development? I've been skimming through a udacity course but want to start working on my own app soon.

Ja richitig, just rambling about. btw this way of programming is enlightened rather than superior, I don't want to come across like an evil bigoted racist. Because that's what C programmers are.

itertools is usually considered good practice, no worries.

Where do you intern?

Start a project involving android dev.

wow thanks!

I am looking for some papers about writing your own process to get into other process loaded into memory and change value of a specific int variable.

What is this kind of method called?

Noice.

A local small business centered on Odoo, so it's a company that provides services for companies, I don't know how to call that in English. Maybe I'll touch NoSQL stuff, or maybe get to explore the territory of some new hardware they've recently gotten. I'm competent in system administration because muh hobbies, but I know a number of languages, and I know Python is how Odoo is made, so there's that. I have an appointment soon, we'll see. Also the boss is family, as if by chance.

what is this?

We learned Haskell in the first semester of uni (Germany) actually, wasn't until Scala that I have seen it being used in "real-life projects". And, of course, you can use some of these idioms in Python.

What I found out is that at least some FP is a good filter for workplaces: they're less likely to disappoint.

I guess you built it? Nice way to skill up while being useful, unlike most of us. GG

>tfw no nepotism

That's nice user

also, fails when a=[] unlike .

This is an important development. Some might even call it revolutionary.

Despite its importance, however, the technologies that will underpin this new method of telling lap times are the property of major tech firms who don't necessarily have the public's best interests at heart.

Not anymore.

inline std::string strrev(std::string const& src)
{
return { src.rbegin(), src.rend() };
}


Why do you have to overcomplicate things.

indeed

def strrev(string):
return string[::-1]

which is faster?