[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 37
File: timetocode.webm (2 MB, 1152x648) Image search: [Google]
timetocode.webm
2 MB, 1152x648
This is /dpt/, the best subreddit of /g/

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, anon-chan ?
>>
File: Screenshot_010616_155736_0.png (205 KB, 502x667) Image search: [Google]
Screenshot_010616_155736_0.png
205 KB, 502x667
Any cheaper alternatives?
>>
>>54857034
https://drive.google.com/file/d/0B2Y-n6IlHYliSXZxMk0xT0NSY1E/preview
>>
>>54857034
https://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?
>>
>>54857047
>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.
>>
>>54857016
A NI ME
>>
>>54857109
Sounds about right.
>>
>>54857109

Yes, that is correct
>>
>>54857046
>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
>>
>>54857299
20MB is cheaper than the book, faggot.
>>
>>54857299
>the picture
holy fuck
>>
>>54857016
I never really cared for anime but holy fucking shit that is the cutest thing I have ever fucking seen what the fuck
>>
File: 1464605356930.jpg (217 KB, 838x1024) Image search: [Google]
1464605356930.jpg
217 KB, 838x1024
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
>>
>>54857360
producer consumer
>>
>>54857367
(define pair (cons 1 2))
>>
>>54857016
UMARU
Yaaaaaaasssssss boooy finally umaru-chan dpt is back in town baby
>>
>>54857327
I just always wondered what 1.5k pages of book took up
>>
>>54857367
nm i forgot to do prefix notation in a spot
>>
>>54857034
>>
File: 1455889314087.jpg (125 KB, 850x850) Image search: [Google]
1455889314087.jpg
125 KB, 850x850
>>54857016
Wouldn't having your computer on the floor cause a lot of upper body pain from looking down for hours, Umaru-chan desu wa?
>>
File: For the AUTISM!.jpg (289 KB, 1920x1080) Image search: [Google]
For the AUTISM!.jpg
289 KB, 1920x1080
>>54857046
>https://drive.google.com/file/d/0B2Y-n6IlHYliSXZxMk0xT0NSY1E/preview

How can I download that book?
>>
>>54857522
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 /g/ents?
>>
>>54857664
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.
>>
>>54857664
>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.
>>
>>54857614
want me to upload it to you?

just say the word
>>
File: 1463497539681.jpg (278 KB, 1024x768) Image search: [Google]
1463497539681.jpg
278 KB, 1024x768
>>54857764
The word
>>
>>54857792
here you go

https://my.mixtape.moe/kiuvpf.pdf
>>
>>54857692
>>54857733
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,
>>
>>54857948
Use PostgreSQL.

Don't use MySQL.

http://grimoire.ca/mysql/choose-something-else
>>
What are your thoughts on JetBrains?
>>
>>54858003
really good software company soon to dominate the industry.

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

https://www.jetbrains.com/
>>
>>54857792
just remove the /preview from the url and you'll get the google drive normal interface, with the download button at the top
>>
>>54858003
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#
>>
>>54858041
>https://www.jetbrains.com/
i like the part where you felt the need to include a link to their website... shill
>>
>>54857569
i want to fug sirufin
>>
File: 1437562354954.webm (2 MB, 852x480) Image search: [Google]
1437562354954.webm
2 MB, 852x480
>>54857354
>>
>>54858141
>scala
actually their language is fucking kotlin, even more shit and obscure
>>
>>54857016
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?
>>
File: spoiler-v1.png (209 B, 100x100) Image search: [Google]
spoiler-v1.png
209 B, 100x100
>>54858239
It's a cat with cheeks as the rests

fucking perv
>>
File: yeeaaaahhhhhh.jpg (8 KB, 480x360) Image search: [Google]
yeeaaaahhhhhh.jpg
8 KB, 480x360
>>54858283
now

that's what i call

cheeky
>>
>>54857391
That's boring af tho.
>>
Oh senpai, I got the best idea for my web based file manager. Make all functionality a plugin.
>>
>>54858398
then it's not really web based is it
>>
>>54858208
THAT'S EVEN CUTER
>>
>>54858412
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)

>>
>>54858557
why?
>>
>>54858557
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?
>>
>>54858695
first because i want to learn how it's done.

plus its a fun exercice and less code
>>
>>54858730

Why is less code good?

compare

>>54858557
>>54858722

which one can be understood faster when something needs to be changed?
>>
>>54858722
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
>>
>>54858762
>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
>>
>>54858557
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.

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

could you understand the code of test2 function faster than test1 ?
>>
File: zeitmessung.webm (2 MB, 1920x1080) Image search: [Google]
zeitmessung.webm
2 MB, 1920x1080
look
>>
>>54858722
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].

>>54858857
I like this one better though.
>>
>>54858857
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?

>>54858894
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?
>>
>>54858857
>>54858930
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));
}
>>
>>54858924
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?
>>
>>54858952
>r8 my reverse string function niggers

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

and your function is not good!
>>
>>54858952
stackoverflow/10
>>
>>54858951
U welcome. Also functional constructs are the way, remember it.
>>
>>54858968
except it's not
this function is so short I'm sure someone else wrote the same
>>
>>54858989
it's alright anon
>>
>>54857065
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?
>>
>>54858476
i thought you meant like a browser plugin
>>
>>54858987
do you usually write one-liners when writing code?
can other people understand?

do prefer writing it that way or normal pseudo-code?
>>
>>54858999
thanks 3/2 satan
>>
>>54858952
absolutely disgusting
>>
>>54859035
Write something better then
teach me senpai
>>
>>54858964
>nor male
are you a female or some kind of queer

post feet
>>
File: 1320467413867.png (41 KB, 322x191) Image search: [Google]
1320467413867.png
41 KB, 322x191
>>54858964
>nor male
You know the rules, tits and timestamp.
>>
File: rpamphet.png (113 KB, 993x723) Image search: [Google]
rpamphet.png
113 KB, 993x723
>>54859016
>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.
>>
>>54859077
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
>>
>>54858963
He asked for a one liner :P
>>
File: code bloat.jpg (99 KB, 630x655) Image search: [Google]
code bloat.jpg
99 KB, 630x655
>>54859095
> :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.
>>
>>54859095
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.
>>
>>54859077
itertools is usually considered good practice, no worries.

Where do you intern?
>>
>>54859115
Start a project involving android dev.
>>
>>54859155
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?
>>
>>54858919
Noice.
>>
File: odoo.png (5 KB, 800x600) Image search: [Google]
odoo.png
5 KB, 800x600
>>54859134
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.
>>
>>54858919
what is this?
>>
>>54859120
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.
>>
>>54858919
I guess you built it? Nice way to skill up while being useful, unlike most of us. GG
>>
>>54859220
>tfw no nepotism
>>
>>54858919
That's nice anon
>>
>>54858722
also, fails when a=[] unlike >>54858857.
>>
>>54858919
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.
>>
>>54859048
inline std::string strrev(std::string const& src)
{
return { src.rbegin(), src.rend() };
}


Why do you have to overcomplicate things.
>>
>>54859558
indeed

def strrev(string):
return string[::-1]
>>
>>54859558
>>54859630
which is faster?
>>
>>54859650
Why do you care?
>>
File: 550af6cf8c600.jpg (30 KB, 615x410) Image search: [Google]
550af6cf8c600.jpg
30 KB, 615x410
>>54859650
Lets see how fast it goes around our track
>>
File: proud-developer.jpg (18 KB, 324x324) Image search: [Google]
proud-developer.jpg
18 KB, 324x324
I copy paste from stack overflow and I'm proud of it.
>>
>>54859650
>which is faster
>C++ or Python
Wew lad.
>>
>>54859231
What university? I'd like to take a look at the curriculum.
>>
>>54859729
>inb4 >languages can't be slow only implementations
>>
>>54859727
same
>>
>>54857354
Fuck off, OP
>>
File: Caterina_fake.jpg (1 MB, 2848x4144) Image search: [Google]
Caterina_fake.jpg
1 MB, 2848x4144
>>54859225
it is a lap timing system build with arduinos.
It works "rfid-like", only that the tag is active and not passive to achieve the desired range.
I could have used uhf rfid, but those are too expensive for me
>>
File: tomoko lite using thinkpaddu.png (984 KB, 1920x1080) Image search: [Google]
tomoko lite using thinkpaddu.png
984 KB, 1920x1080
When using pthreads, can I make the threads loop forever instead of joining them?
Also, am i supposed to pass them a function pointer in order to do work?
Are the stack variables in every thread private to every thread?
>>
>>54860289
>When using pthreads, can I make the threads loop forever instead of joining them?
Yes. But it would mean that your program will never terminate, which is ridiculous.
>Also, am i supposed to pass them a function pointer in order to do work?
Dunno.
>Are the stack variables in every thread private to every thread?
Yes and no. You must be more precise.
>>
>>54860324
I want every thread to have it's own stack that's private from all the other threads.
Is it default behavior?
>>
>>54860289
>When using pthreads, can I make the threads loop forever instead of joining them?
Sure. Whatever made you think you can't?
>Also, am i supposed to pass them a function pointer in order to do work?
When you create a thread, it runs the code you tell it to run. How do you do that? By giving it a function pointer. What is this? STUPID QUESTIONS FOR DERPHEADS?!
>Are the stack variables in every thread private to every thread?
Yes, unless you hand out pointers to them. Sometimes that's even a good idea (usual rules on shared resources apply, of course).
>>
>>54860362
I realize that I'm not sure about that. How is it possible?
>>
<?php
$meme = 'meme';
echo strrev($meme);
?>


>>54859048
>>
>>54858964
>your code sucks
>im a girl btw
>>
>>54860365
One more question, how do I pass arguments through the function pointer?

Let's say that i want all the threads to have access to a stdout mutex and their own unique rand_r() seeds.
I have them declared in main() because globals are gross.
>>
(I've been slow at writing)
>>54860289
>When using pthreads, can I make the threads loop forever instead of joining them?
> To allow other threads to continue execution, the main thread should terminate by
> calling pthread_exit() rather than exit(3).
as per pthread_exit(3), so do that. I don't think you need to detach them, as pthread_detach(3) contains
> The detached attribute merely determines the behavior of the system when the thread
> terminates; it does not prevent the thread from being terminated if the process ter‐
> minates using exit(3) (or equivalently, if the main thread returns).

> Are the stack variables in every thread private to every thread?
There are as many distinct stacks as there are threads, but if you pass around pointers, nothing will stop anyone from writing anywhere. Does that answer your Q?
>>
File: image.jpg (30 KB, 352x352) Image search: [Google]
image.jpg
30 KB, 352x352
>Cant find an entry level coding job that doesn't require 3 years of experience in a dozen frameworks ive never used
>I live in NYC
>>
>>54860433
You have to exploit the void pointer you get to pass along with the function pointer to pthread_create. It exists precisely because there is no other way to "customise" if you will, function pointers by attaching a set of runtime values to them. In higher order languages we could create a function with a closure, but in C it doesn't exist.
>>
File: 1464731615076.jpg (46 KB, 400x458) Image search: [Google]
1464731615076.jpg
46 KB, 400x458
I'm a retarded first year student and I got a task for a job interview.
it asks me to implement a framework for building FSMs. also asks to provide as much common functionality as I can.

I'm wondering what "common" functionality is reasonable to expect in such a thing. I can't quite think of any.
furthermore, what is a good way for understanding how to make such a thing? read code of other frameworks? read up on design patterns? etc.
>>
>>54860464

learn web development and make a shopping cart . You can use node.js, jQuery or php to get it done! Install xampp and learn how to do CRUD with mySQL. You can do it anon-kun!
>>
>>54860510
>You have to exploit the void pointer you get to pass along with the function pointer to pthread_create

How do I do that?
>>
>>54857016
Please help me with MVC design pattern, i can't find anything related on google


Map data in form of 0,0,200,200,0,200,0,200,200,0,400,0,200,200,0,0,200..... are read from a file and stored in an array inside the model.

Now I need that array in my View for the g.drawRect methods and for defining Shapes that will be have mouselisteners attached to them in the controller.

The simplest way to do it would be to just type model.array but it's against everything in MVC. How do i transfer map data from my model to the draw methods in view?????
>>
>>54860577
MVC is nonsense
>>
>>54860464
start a project, if you're unemployed you have time for it anyway, and the project will give you experience and maybe make you money so you can start your own software company
>>
>>54860544
Most of the time, programmers create a dedicated structure type with exactly what they need, and pass a pointer to a struct thru the void pointer. You have to be extremely careful about not destroying the struct before the new thread gets to consume it, even more so because it's multithread, so if you don't synchronise it can happen extremely late with regard to the parent thread's instructions. I think the simple and safe approach would be to dynamically allocate in the parent and free in the child, because if it's on the parent's stack it will be risky. Maybe someone has guidance on that?

add: I know of at least one other way, using var_args and synchronising. Here it is on Plan 9, just for the lulz:
typedef struct {
void (*f)(va_list*);
va_list l;
} VaThreadCreate;
void vathreadcreate2(void *aux) {
VaThreadCreate* tc = aux;
tc->f(&tc->l);
}
int vathreadcreate(void (*f)(va_list*), int stacksize, ...) {
VaThreadCreate tc;
int id;
tc.f = f;
va_start(tc.l, stacksize);
id = threadcreate(vathreadcreate2, &tc, stacksize);
yield();
va_end(tc.l);
return id;
}

typedef struct {
VaThreadCreate;
int stacksize;
Channel *done;
} VaProcCreate;
void vaproccreate2(void *aux) {
VaProcCreate *pc = aux;
threadcreate(vathreadcreate2, (VaThreadCreate*)pc, pc->stacksize);
yield();
chanclose(pc->done);
}
void vaproccreate(void (*f)(va_list*), int stacksize, ...) {
VaProcCreate pc;
pc.f = f;
va_start(pc.l, stacksize);
pc.stacksize = stacksize;
pc.done = chancreate(sizeof(void*), 0);
proccreate(vaproccreate2, &pc, mainstacksize);
recvp(pc.done);
chanfree(pc.done);
va_end(pc.l);
}
>>
Is a linked list and a sparse matrix the same thing?
>>
>>54860658
But dynamic allocation is probably more efficient, especially with posix threads. I just did that for the lulz and the flexibility and the elegance.
>>
>>54860538
I already know node and JQuery. I'm looking for both software and web jobs(but not front end)

Maybe I should look into front-end though, since angular is bringing web applications to it
>>
>>54860653
I would but every idea has been done, and by coders of much greaer skill
>>
>>54860682
>I would but every idea has been done, and by coders of much greaer skill

then you're useless
fuck off
>>
>>54860682
even if you make some basic shit that's inferior in every way it'll still help you learn and prepare you to make better shit
>>
File: 1432095026626.jpg (35 KB, 440x310) Image search: [Google]
1432095026626.jpg
35 KB, 440x310
>>54860682
Pathetic
>>
/dpt/ give me your most difficult programming interview questions and I'll try to solve them
>>
i have an array with 9 items in it. What sorting algorithm do i use?
>>
>>54860737
sleep sort ofc
>>
>>54860754
pls no memes.
>>
>>54860775
Meme questions get meme answers.
>>
File: 2016-06-01 16_33_16-Atomica.png (97 KB, 552x798) Image search: [Google]
2016-06-01 16_33_16-Atomica.png
97 KB, 552x798
Just added in skip to previous/next track buttons.

How can I make this UI look better? Any suggestions?
>>
>>54860718
>>54860689

You know what? You're right, I am bitching. I'll just do something that's been done
>>
>>54860737
Isn't quicksort by definition the quickest?
>>
>>54860860
Fuck yeah dude, best of luck!
>>
>>54857034
>>54857046
Thanks guys for the book.

However, is there anywhere I/we could also locate the two other texts that supplement this one? Programming Python and the book Python Pocket Reference are two other texts mentioned by the shill in the preface. If I wanna take the time to learn this shit I'd like access to as much resources as possible m8s.
>>
>>54860737
insert sort
>>
>>54860933
>https://kat.cr/usearch/?q=Python+Pocket+Reference

>https://kat.cr/usearch/?q=Programming+Python+o%27reilly

Literally took me 5 secs.
>>
>>54860820
make the volume slider vertical.
>>
>>54860658
So basically, you have to allocate your own stack variables manually?

That sucks.
I wish C had anonymous function literals so bad.
>>
>>54857360
Tripcode generator
>>
>>54860909
I even have an idea already, im just worried Ill get a cease and desist.

[spoiler]mar.io[/spoiler]
>>
Is there anything that Monads CAN'T solve?


Performance excluded
>>
>>54861028
damn I never thought about this. Interesting suggestion. Almost all music managers
(and video players) have it horizontal though. I think it may come out looking awkward, what do other anons think of vertical volume controls?
>>
>>54861189
website already exists
>>
>>54861190
Simplicity.
>>
>>54861212
Monads do simplify
>>
>>54861228
A tiny island of sanity in a cesspool of madness.
Compared to a design in a non-hippie language, they are anything but.
>>
>>54857360
Do an n-body simulation.
>>
>>54861210
I know, I could just change it to shroom.io or toadstool.io

The idea is to just do to mario bros what slither.io did for snake
>>
>>54861245
They reduce code complexity and quantify abstractions

f(x) + f(x) + f(x); -> 3*f(x);
>>
File: 1463438166601.jpg (75 KB, 424x383) Image search: [Google]
1463438166601.jpg
75 KB, 424x383
>be windows user
>try to open 200MiB text file
>wordpad chokes
>notepad chokes
>atom chokes
>firefox chokes
>download Vim from vim.org
>loads instantly and searching is instantaneous

holy shit
>>
>>54861296
The simple fact that people have trouble grasping them, makes them complicated.
There is no value in simplifying things through an abstration, if the abstraction itself is so complex that few people can use it.
That it is possible to use monads is the best I can say about their simplicity.
>>
>>54861330
>wordpad
>>>reddit
>>
>>54861340
Yet people use lists, async, exceptions & optionals all the time
>>
So I have just started to mess around with php and decided to make a dumb script that just prints a certain character x number of times for y lines. After a while I thought about how complicated I could make it and ended up with this. Are these kind of "optimizations" common or a practice in actual code ?
http://pastebin.com/rkJiSAF7
>>
>>54861366
Which are typically much simpler to use, although they can result in somewhat more complex code.
>>
Working on my taggable image viewer, Ivy. Rather, just fixed a few bugs and then decided it was time to publish a new version. I'll get binaries set up for all three platforms later today, but if you'd like to view the source (or build it yourself), it's located here: https://github.com/lehitoskin/ivy.git

I added a bunch of command line stuff so that you can manage your images and tags from scripts, which I think is nice if you have a whole lot of images that share tags (like I do).
>>
>>54861377
What optimisation?
Outside of the general brainded code, and the fact that you do i*j instead of 5*i, this is as straightforward as it gets.
>>
>>54861071
You mean allocating your own closure? Yes, that's the thing.

I finished rewriting my stuff for Unix, maybe you'll like it (maybe there's a bug, I'm not sure):
#include <stdio.h>
#include <stdarg.h>
#include <pthread.h>
#include <unistd.h>


typedef struct _aux_t {
void *(*f)(struct _aux_t*);
va_list l;
pthread_spinlock_t s;
// protocol: f shall consume aux->l, then unlock aux->s, then do its thing
} aux_t;

static void* wrap(void* aux_) {
aux_t* aux = aux_;
return aux->f(aux);
}
int va_pthread_create(pthread_t *out, const pthread_attr_t *attr, void *(*f)(aux_t* aux), ...) {
aux_t aux;
aux.f = f;
va_start(aux.l, f);
pthread_spin_init(&aux.s, PTHREAD_PROCESS_PRIVATE);

pthread_spin_lock(&aux.s);
pthread_create(out, attr, wrap, (void*)&aux);
pthread_spin_lock(&aux.s);

pthread_spin_destroy(&aux.s);
va_end(aux.l);
}


// Example:
void* sub(aux_t* aux) {
printf("lel\n");
int i = va_arg(aux->l, int);
pthread_spin_unlock(&aux->s);
printf("Hello from #%d\n", i);
return NULL;
}
int main() {
printf("hello world!\n");
for(int i = 1; i <= 10; i++) {
pthread_t t;
pthread_attr_t a;
pthread_attr_init(&a);
pthread_attr_setdetachstate(&a, PTHREAD_CREATE_DETACHED);
va_pthread_create(&t, &a, &sub, i);
printf("done starting #%d\n", i);
pthread_attr_destroy(&a);
}
return 0;
}



                  ¡ R8 !
¡¡ R8 !!
¡¡¡ R8 !!!
¡¡¡¡ R8 !!!!
¡¡¡¡¡ R8 !!!!!
¡¡¡¡¡¡ R8 !!!!!!
¡¡¡¡¡¡¡ R8 !!!!!!!
¡¡¡¡¡¡¡¡ R8 !!!!!!!!
¡¡¡¡¡¡¡¡¡ R8 !!!!!!!!!
¡¡¡¡¡¡¡¡ R8 !!!!!!!!
¡¡¡¡¡¡¡ R8 !!!!!!!
¡¡¡¡¡¡ R8 !!!!!!
¡¡¡¡¡ R8 !!!!!
¡¡¡¡ R8 !!!!
¡¡¡ R8 !!!
¡¡ R8 !!
¡ R8 !
>>
>>54861377
Nested loops are very common.

You can use this syntax for arrays btw.:
$a = ["Hello", "world"];
>>
>>54861384
>I'll get binaries set up for all three platforms later today
>all three platforms
BSD fags on suicide watch
>>
>>54860537
pls respond.

like, literally anything so I can stop feeling stuck.
>>
>>54861443
WWF would like a word with you
Something about abusing animals of an endangered species
>>
>>54860537
Have you ever built software before?
>>
>>54861443
?

the project is licensed under GPLv3, an open, free software license. Assuming it doesn't have any strange dependencies, BSD fags can simply compile their own binaries.
>>
>>54861443
Obviously I meant GNU/Linux, BSD, and Haiku :^)
>>
>>54861529
It must hurt a little bit when even Linux users don't recognize you as a real platform.
>>
>>54860820
Make some frame for an image. Raw pasted images looks terrible imho without some predefined place for them, that is visible even without said image.
>>
will learning scala help with job opportunities?
>>
>>54861505
yes, biggest thing I did was a (very) simplified compiler.
it's just that this is the first time that I get vague instructions with very little hand holding, and I'm feeling lost and overwhelmed.
>>
>>54861625
sorry, that was supposed to be no, I haven't built software yet. just implemented some easy shit and did coursework.
>>
A friend and myself are building a system around weather data, and we just found out we're looking at about 1,750,000 rows of data a day.

I'm not so much worried about the rows per day as much as the actual size of the data - 200MB/day. Pegs at outgrowing our shitty laptop server in 3-6 months. Is anyone aware of a hosted database solution (we're currently using postgres).

From my currently research it seems best to just get a VM on AWS/Azure/Google and attach a big ass disk to it and run the database that way.
>>
>>54861427
Its my first code, of course its braindead. What I was asking is if things are okay to be overcomplicatedlike this. I could have just echoed some of the values raw without the need for the arrays or variable concatenation
>>
>>54861625
>>54861653
Okay well, imagine you're the user of your program and you want to build FSMs, think of what you could possibly do with a FSM.
Build your library so that most of the hard work of using FSMs is coded in the library.

Stuff like easily adding states and transitions, setting callbacks when something interesting happens (like reaching or leaving a certain state), something to trigger transitions, etc.
>>
>>54861683
It depends solely on what you're trying to make. Usually you'd rather use raw string literals.
>>
>>54861683
It looks a little strange, usually people don't do that unless there's something more complicated they need to do with the variables & arrays.

So here it'll work, but you probably shouldn't to not confuse the reader.
It's like using a shovel to serve food, it might work, but there's a simpler way and people will think you're crazy.
>>
>>54861624
no
http://jimplush.com/talk/2015/12/19/moving-a-team-from-scala-to-golang/
>>
is there any reason to use ajax nowadays when you have websockets available?
>>
File: ????.jpg (45 KB, 577x622) Image search: [Google]
????.jpg
45 KB, 577x622
Should I declare all of my functions in the header or just the ones that absolutely need it?
>>
>>54861765
Ajax is much simpler, and websockets have a real cost on the server.
>>
>>54861769
Templates can only be defined in the header

If you use non-templated functions there's probably something wrong with you
>>
>>54861769
If it's a public header, only declare what you're committed to maintain and don't mind other people using.
If it's the private header, same thing, but you're not in trouble if you fuck up.
>>
>>54861769
That's kind of why header files exist, right? Just put them in there.
>>
>>54857046

>Monty python references fucking everywhere

Fucking hell, I hate Python enthusiasts.
>>
File: 1.png (80 KB, 599x300) Image search: [Google]
1.png
80 KB, 599x300
>>54861802
This is C though.
Of course I could always implement templates.
>>
File: 2.png (74 KB, 599x300) Image search: [Google]
2.png
74 KB, 599x300
>>
>>54861868
>>54861885
C-cute
>>
>>54861700
thank you, that helped. I think I was overthinking it.
>>
>>54861868
>I could always implement templates

someMacro(int) does not do the same thing templates do
>>
>>54861384
I think you need some interpolation there my friend.
>>
Looking to get into dependent types. I'm familiar with Scala (used it at my job for 4 years) and have used its dependent typing a bit, but it's very limited. Is Idris a good place for me to start?
>>
>>54861962
I was only jesting.
>>
>>54862004
Yes, or a dynamically typed language
>>
>>54858557
>>54860658
>>54861432
>>54858857
I don't get it, why all the abreviations? Why not just use descriptive variable names so that people can actually read the code?
>>
File: 1423010757075.jpg (14 KB, 249x243) Image search: [Google]
1423010757075.jpg
14 KB, 249x243
>tfw working on a personal project for months
>had a lower-level bug that plagued my program for months with endless frustration
>finally fixed it today, and for the first time my application runs buttery and consistent.

Who knows how great this feel is?
>>
File: KTLteIM.webm (1 MB, 966x646) Image search: [Google]
KTLteIM.webm
1 MB, 966x646
>>54862040
>inb4 abbreviations*
>>
>>54861751
So that is the hubris of custom operators?

What sort of idiot defines an operator with no meaning? Thats like defining a method as void fhdkvskv(int wknlpfwhns, double *sigphd) {}

Don't blame scala for a developer intentionally making code unreadable
>>
>>54862026
>dynamically typed language
How would that be useful for dependent types?
>>
>>54862087
Dynamic typing is just dependent typing in U∞
>>
>>54862059
I don't know that feel because I don't let major bugs linger for months ;^)
>>
>>54862059
what is the project
>>
>>54861990
How do you mean?
>>
>>54861624
no it's a shitty obscure hipster meme lang
>>
>>54862085
All the articles I've seen of the form
>why I moved from Scala to a language with a less powerful type system
have all been written by people who simply weren't smart enough to take advantage of even a fraction of Scala's expressiveness and flexibility. You can safely ignore such articles because they are not worth reading.
>>
>>54862124
It's used quite a bit in fintech.
>>
>>54862059
>>had a lower-level bug that plagued my program for months with endless frustration
you're doing it wrong
>>
If I have 0 javascript knowledge should I start learning Node.JS?
>>
File: 1424386128204.png (93 KB, 645x773) Image search: [Google]
1424386128204.png
93 KB, 645x773
>>54862098
>>54862094

It was actually a bug from using a python GUI module in conjunction with threading.
Fucking Tkinter. Last time I ever touch it, just too lazy to recode everything to something else like PyQt.
>>
>>54862210
No. In fact, the question can be simplified and the answer is the same:

>Should I start learning Node.JS?
No.
>>
>>54862210
no
>>
>>54862091
But don't you lose the advantage of the compiler calling you out when you get the types wrong?
>>
>>54862210
only if you want lots of money
>>
>>54862231
Why not? Seems like it would be great for sites like "csgo roulette" etc. not that I plan to make one as there's already hundreds of them but I did plan on making something similar for a different game, I don't have time to learn Go.
>>
>>54862272
even for webshit nodejs is deprecated it's all about python with django/flask
>>
>>54862210
I meant where* should I start learning Node.JS
>>
>>54862273
>>54862288
>>>/g/wdg
>>
>>54862257
Not if it's strongly typed
>>
>>54862257
>>54862324
I mean you could still have lemmas and proofs, and compilers for all the stuff you'd have in a regular language, but you'd have the additional benefit of all types & terms being able to coexist
>>
>>54862324
You'll have to help me out a little here and explain what you mean by 'dynamically typed', evidently my understanding (which is admittedly hazy) doesn't seem to align with yours.
>>
>>54862361
The simplest explanation would just be that type is dependent on runtime value, but really it's that types are just another kind of term
>>
>>54862361
A dynamic language can still have strong type constraints, and can still have static type constraints that can be evaluated at compile time, e.g. there's no reason in theory why a function int -> int where int is a primitive determined by the compiler should perform worse in a dynamic language, but the problem is most dynamic languages don't have int -> int they have value -> value and their int -> ints are just
if (isAnInt(someValue)) then Value(...) else throw exception
>>
>>54862433
Forgive my ignorance, but in what sense would that then be a dynamic language? I sense there's something basic I'm missing here.
>>
>>54862458
You would still have dynamic values & runtime type construction
>>
>>54862458
Basically in the same way dynamic languages have primitives they can easily have primitive functions
>>
>>54862488
>>54862479
>>54862393
Thanks yall. I'll try to get my head around it. My basic intuition has thus far been that dynamic languages are things like Python, JS and Ruby.
>>
>>54862116
I can see that there are jaggies in that image.
If they do not appear at native image res then the problem is that your scaling method does not implement pixel-data interpolation, or that it implements a poor one.
I would go bicubic.
>>
File: 2016-06-01 17_59_14-Atomica.png (81 KB, 552x798) Image search: [Google]
2016-06-01 17_59_14-Atomica.png
81 KB, 552x798
>>54861575
I can see this working well. I tried to compensate for said issue by having that consistent white thin border for everything as you can see.
Still trying to keep it minimal.

What do you mean by frame? like a sunken look or some type of simple square image that is under the album art while being a bit bigger (to see the album art "contained" in it)
If the latter, what should it be? maybe just a different shade of grey?
>>
>>54862571
In a dependent language, you have something like

Vect :: Nat -> Type -> Type
(Nat is an arbitrarily big natural number)
The universe of the first type parameter is n, while the universe of the second parameter is n+1

I say Universe ∞ because in dynamic typing -
Vect :: Nat -> Type -> Type
The universe of the first type and second type are the same. ∞ + 1 = ∞
>>
>>54862643
This is just my musings though, dynamic languages without strong static typing & proofs (i.e. all of them) don't have the same safety & aren't guaranteed to be well formed like normal dependent languages, but it's useful for learning
>>
>>54862612
Ah, I think I'll look into that. Thanks anon.
>>
>>54862067
>that webm
they dont work like that
>>
>>54862838
how would you know? are you a windmill engineer?
>>
>>54862040
>python and C shitters
>readable code
good one m8
>>
is pastebin offline for anyone else? it's the only site offline for me and i also tried going to it on a vm
>>
>>54862908
it's up
>>
>>54862927
try going to this http://pastebin.com/sfUW2jT1 and tell me if it's still up
>>
>>54862968
still up
>奴隷との生活 -Teaching Feeling-
>>
>>54862231
>JS is bad
This is a stupid meme.

1) HTML5/JS is a powerful platform that delivers applications to billions of people around the world, it runs on billions of devices.
2) Javascript is a descendant of Scheme and Self, so it is pretty cool language, especially if you forgive it its small defects. Solving the same problem in javascript seems to require 3-4x less code and 2-3x less dev time than solving it in C/C++/Java.
3) Fastest compilers/runtimes ever written for a dynamic languages were written for JS: V8, Chakra, Spidermonkey, Javascriptcore. JS is the fastest dynamic functional language in the world.
>>
>>54862997
what do you think the issue is? and idk what that is you're talking about i must've mistyped it i'm talking about programming. it works on my iphone but not a different browser on the same computer
>>
>>54863006
i dunno lol maybe try in >>>/g/sqt
>奴隷との生活 -Teaching Feeling-
is what came up at your link
>>
>>54862998
>JS is not bad
this =(==?(===?)) false
>>
>>54860464
>a big programming studio in your area didn't require any formal work experience nor a degree, just knowledge of some networking, c++ and python

cool as shit, got the job as a junior c++ dev even though im a hs dropout
>>
>>54863006
maybe it's a temporary fault with your ISP
>>
>>54863035
that crossed my mind but it works on my phone which only has wifi
>>
File: Untitled045920.png (66 KB, 1920x994) Image search: [Google]
Untitled045920.png
66 KB, 1920x994
Deciding how to implement records in zones.
I finished the WTForms stuff for DNS, but I still have to replace all other with it too.
>>
>>54861432
God C is truly disgusting.
>>
is there any decimal relation when doing bitwise operations with AND, (X)OR? Like 100 XOR 40? I dont really see it
Thread replies: 255
Thread images: 37

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.