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

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 314
Thread images: 41

File: DIFFERENT_zps4ac81c9d.jpg (64KB, 1024x906px) Image search: [Google]
DIFFERENT_zps4ac81c9d.jpg
64KB, 1024x906px
What are you working on, /g/?

Old thread: >>57959249
>>
>>57967490
Please stop posting anime in a technology related discussion forum
>>
>>57967490
Remember maggot!

If you use OOP or any of its ideas in your code, you're officially the sheep
you so greatly describe about when you say things about Apple fans.

Join the rebels, the one who think different, join the Functional Programming rebels!
Overthrow Codecuckism!

For starters, if you like Java (Ugh!)
- Learn Clojure or Scala!

If you like Python or Javascript (Double ugh!)
- Learn Elixir!

If you like C# or any .Net OOP language (Triple UGH!)
- Learn F#!

Otherwise, read the bible that is SICP!

There's also the Holy Language of Haskell!
>>
>>57967490
ThirD
>>
>>57967517
>Haskell users thinking their language is useful

enjoy never getting anything done, ever
>>
>>57967542
Meanwhile I'm working at Facebook making new stuff happen while you're doing codemonkey shit
>>
File: .png (224KB, 580x435px) Image search: [Google]
.png
224KB, 580x435px
>>57967517
>SICP
>mfw we're that doomed that SICP isn't even taught in Lisp
http://www.posteriorscience.net/?p=206
>>
File: kintosaa.jpg (32KB, 657x527px) Image search: [Google]
kintosaa.jpg
32KB, 657x527px
i really really like Java
it's just so fun
>>
>>57967514
If it's forbidden, report this thread.
>>
>>57967568
haskell still requires help from OOP languages in order to do any work, you would know this if you actually worked for facebook

developing spam filters doesn't sound too interesting, except maybe for an copypasta-ing autist like you
>>
>>57967646
>please
>>
>>57967514
ok janny sure things

(keeps posting anime)
>>
File: 1459572228126.jpg (36KB, 500x490px) Image search: [Google]
1459572228126.jpg
36KB, 500x490px
>>57967653
>haskell still requires help from OOP languages in order to do any work
>>
>>57967542
>tfw professional Haskell programmer

if only you KNEW
>>
>>57967517
yay, more hipster programmers!
>>
So I am sending off a Post request to an api. However if I send too many it'll time me out.

I'm using xmlhttprequest. How do I make it pause and wait for a request to succeed before sending a new request?
>>
>>57967694
It's true, though, particularly in this context.

The Haskell spam filters sit as a subsystem and small component of the entirety of Facebook's stack.

Every time with Haskell fags as "proof" that Haskell has jobs and real-world opportunities.
>muh facebook component
>>
>>57967615
C# is more fun, anon.

Join the comfy side of programming.

dumb frogposter
>>
>>57967753
>javascript
>>>/g/wdg/
>>
>>57967753
You've got to resend; you can just tell the endpoint "Yo, let me know when I can try again."

You just have to try again after an interval.
>>
File: asdf.jpg (28KB, 388x378px) Image search: [Google]
asdf.jpg
28KB, 388x378px
>>57967694
haskell should stay in academia
>>
If mutation is not purely functional, how do you count? Like if I wanted to count the number of words in a string would you write a recursive function with a base case of 1 and just set a value equal to the sum of all of them? How is this done? What if I'm counting a lot?
>>
>>57967855
>can
can't*
>>
>>57967517
Saying SICP is the bible of CS is like saying Spivak's calculus is the bible of math.
>>
>>57967931
>>57967855
How do I set this interval?
>>
>>57967490
im working on a C# program were i give it a code and it decodes it..

simple its my first C# app
>>
Ada calls c functions using pass by reference if you want, which takes some getting used to
>>
>>57967929
You sum them recursively. With the programmer using substructural types or the compiler doing optimizations, you can get the runtime benefits of mutation while maintaining all the static benefits of immutability.

Mutation isn't impure.
>>
I've made a new observation today.
If you have to draw a diagram before writing code, your code will be shitty. No exceptions.
>>
>>57967969
What language, dickbreath?
>>
>>57967981
Post code.

I want to make fun of you, and also help you.
>>
>>57968153
no like a cypher
>>
I'm trying to make a very simple console game on C, and it's amazing how simple it is to get something working with just stdio.h. I miss having frameworks do everything for me (I learned Python first), but this has been quite a fun ride.

I've made a very basic Breakout clone so far. I'm not posting the code right now because it only works on the Windows console (it uses cls to clear the screen).
>>
>>57968177
Yes, I understand that you're making a glorified Cracker Jack ring, I'm curious as to how you're going about it. I like reading beginner code.
>>
>>57968198
i don't know C# that much im still leaning by watching shitty youtube videos

i have experience with php java script html and css

>inb4 pajeet

i just have not done anything new in a while and thought this would be good
>>
>>57968238
>thought [YouTube language tutorials] would be good

ok pajeet
>>
>>57968417
fuck you thats how i learned php java script html and css

know any better ways to learn code
>>
File: 1478748801757.jpg (41KB, 443x359px) Image search: [Google]
1478748801757.jpg
41KB, 443x359px
>>57968455
>php java script html and css
>>
>>57968475
:(
>>
>>57968455
>fuck you thats how i learned php java script html and css

mfw I was right

it feels bad to be right sometimes

Pick up some reading material and write something instead of wasting your time watching videos for 5th ‘language’ and still asking for ways to learn
>>
>>57968024
What?
>>
writing a tool to do some primer design for molecular biologists

mostly just simple string comparisons, but there's so many edge cases to keep track of that the bookkeeping is a nightmare.
>>
Is it even possible to do a multi consumer multi producer lockfree queue?
>>
>>57968535
yes
>>
If this post is out of place, please tell me and I will delete.

I looking to pay a company to create a high quality StumbleUpon clone to my specifications. How much should I expect to pay for a project of that magnitude (and do you have any recommendations as to who to hire)?
>>
>>57968535
Use http://stackoverflow.com/questions/10102881/haskell-how-does-atomicmodifyioref-work for the queue
>>
Never worked with Android so I'm gonna start writing a bullshit little app.
>>
>>57968455
The fucking yellow book.

It will teach you C#, and it teaches you how to program before you even touch C#.
>>
>>57968605
Sounds to me like you can't afford it either way, you want a high quality clone of a product that has been 10 years in the making and you don't even have a rough idea how much and where to go with it. Estimate 50-100k per developer a year (or more depending where you go and what you want) and triple the estimate for how long it would take then rethink what you're doing. Ideas are not enough.
>>
>>57968605
Would probably be $40k+, plus lots of infrastructure to maintain the application and whatnot.

That's being conservative.
>>
>>57968676
>>57968696
Thats about what I expected, just wanted a second voice. Thanks
>>
Anyone have experience of Haskell on Android? I write Haskell day-to-day so thinking of dicking around there while I have some spare time. The easily-found resources all seem out of date, Keera Studios has been really quiet as far as I can tell and they were the main public user; NDK examples use Ajhc and that project closed quite a while ago.
>>
>>57967517
t. DVD c programmer
>>
>>57967517
I love how this low-quality bait is still producing (You)s for this poster
>>
File: v2.0.png (550KB, 1450x1080px) Image search: [Google]
v2.0.png
550KB, 1450x1080px
>>
>>57968771
>tfw you're slightly color blind and /dpt/ is committing micro-aggressions against you
>>
How do I learn to program?
>>
>>57967845
InteliJ Idea is much, much more comfier than MonoDevelop
>>
>>57968057
Holy shit you're right.
>>
>>57968496
Probably means where in C you have
void foo(int *bar)

when interfacing with this function in Ada you could declare it like
procedure foo(bar: in out Integer);

and not worry about access (pointer) syntax, instead treating it just like any other pass-by-reference parameter.

Not that this is anything special really, lots of languages with C interfaces work similarly. Ada apparently has a peculiar feature though in that record types declared as using C conventions suddenly become pass-by-reference by default unless you use a special convention C_Pass_By_Copy.
>>
I'm trying to hack the C++ compiler into running some code before main() by declaring a global object and having code run in it's constructor, e.g.
struct Hello {
Hello () {
std::cout << "Hello" << std::endl;
}
};

// initialize me before main
Hello _;

int main (void) {
std::cout << "World" << std::endl;
return 0;
}


However it's spread across two files and the linker keeps removing my global variable unless I actually do something meaningful with it somewhere, which I don't want to do. How should I go about solving this, /g/?
>>
>>57968817
Depends, what do you want to do with it?
There's plenty of books and online resources to use, basically just gotta pick a language, set up a dev environment and run with it
>>
>>57968919
Thanks
>>
>>57968910
>I'm trying to hack the C++ compiler into running some code before main()
why
>>
File: 68a.jpg (29KB, 400x366px) Image search: [Google]
68a.jpg
29KB, 400x366px
>>57967490
Trying to make an online multiplayer advance wars with everyone's favorite language PHP.

What i'm getting into, guys?
>>
>>57968956
Setting up some functions that are going to be called in main() so that I can just add extra .cpp files without changing the file containing main() each time.
>>
>>57968981
okay but why
>>
>>57967490
https://github.com/elbingobonito/Brainfuck-Haskell
>>
>>57969046
god, haskell code is so beautiful
>>
>>57969046
that Parses newtype reminds me of state
>>
>>57968879
Almost, the foo function you're calling should be changed to
 int bar
in that case.
>>
Do we still hate rust?
>>
>>57969250
Yes
>>
>>57968057
So if I draw the diagram after I code does that mean it's really good? =)
>>
>>57967753
Post code.
>>
File: aaa.png (266KB, 765x1045px) Image search: [Google]
aaa.png
266KB, 765x1045px
How do I learn JavaScript senpai?
>>
File: 1461502868217.gif (972KB, 500x341px) Image search: [Google]
1461502868217.gif
972KB, 500x341px
>>57967490
>>
>>57969425
You kill yourself first, degenerate weeaboo scum
>>
>>57969425
https://lmgtfy.com/?iie=1&q=How+do+I+learn+JavaScript
>>
>>57969425
>>>/g/wdg
Seriously.
>>
>>57969425
Make a lisp interpreter in it.
http://dalian.waifu.pl/
>>
>>57969453
Kek, stop trying to make that shitty general work, lad.

Nobody likes /wdg/, not even JavaScript programmers.
>>
>>57969425
kys
>>
>>57969477
/wdg/ OP has information what
>>57969425 wants.
What else?
>>
>>57969525
It's a shitty general and we shouldn't encourage thread splitting.

JavaScript is just as welcome here as any other programming language.
>>
Hate to ask for homework help but I'm pretty stuck and google searching isn't returning the information I need.

For my class's second to last lab (we're using POO IN LOO), we have to read a text file structured as follows using Scanner:
- The first line will have a number which will represent the length of an array,
int len = scan.nextInt()

- The subsequent lines will be two sets of three-letter nation abbreviations on each line, ie. USD GBP

We use that number from the first line to instantiate an object array for a custom class called Exchange:
Exchange[] exch = new Exchange[len]
and then populate that array with Exchange objects that take the abbreviations as parameters:
Exchange ex = new Exchange(from, to)
. My current problem is that I'm able to instantiate the array but whenever I try to fill it with the objects, the array is only filled with the last entry in the text file, so when I use a foreach loop to check what's in the array where len = 6, it looks like:

USDDKK
USDDKK
USDDKK
USDDKK
USDDKK
USDDKK


My codeblock that reads the file looks like:

while (scan.hasNext()) {

if (scan.hasNextInt()) {
int len = scan.nextInt();
exch = new Exchange[len];
}

if (scan.hasNext()) {
from = scan.next();
to = scan.next();
Exchange ex = new Exchange(from, to);

for (int i = 0; i < exch.length; i++) {
exch[i] = ex;
}

}
}


Am I shitting in the street too hard?
>>
>>57969548
And I don't think so.
JavaScript perfectly fits in /wdg/, and you cannot use JavaScript without a bunch of web technologies. Hell, it is the language for *Web* browsers, why JavaScript posts must not exist within more spesific threads?
>>
>>57969632
>specific
fix
>>
File: anal beeds.png (35KB, 694x542px) Image search: [Google]
anal beeds.png
35KB, 694x542px
Anyone good with MySQL?

I'm trying to filter the results to be a certain year but they always come out the same and just ignore the 'WHERE'

SELECT 
p.ProvinceName
, avg(cnd.Price)
, max(cnd.Price)
, min(cnd.Price)
, std(cnd.Price)
FROM (
SELECT
s.Price
, s.CountyID
FROM sales20102016 s
WHERE s.SaleDate = '2012'
) cnd
JOIN counties c ON c.CountyID = cnd.CountyID
JOIN provinces p ON p.ProvinceID = c.ProvinceID
GROUP BY p.ProvinceName;
>>
>>57969614
Wow, it's just like the IT labs I had to work

Look at your for loop and think about what it's doing each iteration
Also, I'm willing to bet that
int len = scan.nextInt();
is going to cause you issues
>>
>never actually used bullet
>know the code better than most contributors
>never rendered a 3d model
>wrote big parts of a library
do people actually use what they write?
>>
>>57969709
Try 2012 without the ''
>>
File: .gif (170KB, 250x188px) Image search: [Google]
.gif
170KB, 250x188px
I think it's about time to get over memes and clearly say, what's so wrong with OOP and what's so right with FP.
Anyone?
>>
File: pyruby1.gif (9KB, 184x169px) Image search: [Google]
pyruby1.gif
9KB, 184x169px
Which scripting language would be better to use for automating tasks and web scraping, and what resource for learning you recommend the most? I'm not new to programming, already know some Java and C#.

Thanks you boys!

(No bully pls)
>>
>>57969767
Still works; alas no difference.
I think its doing the functions before looking at the WHERE but I forced the FROM to sub query.

Thanks anyways though.
>>
Can you guys post some learning sources?
>>
File: 1470366634624.jpg (20KB, 424x308px) Image search: [Google]
1470366634624.jpg
20KB, 424x308px
>>57969726
>Wow, it's just like the IT labs I had to work
pic related

>Look at your for loop and think about what it's doing each iteration
D'oh. I'm taking the same object I instantiated at the start and putting it in every spot in the array instead of actually instantiating a new object for each spot in the array.

>Also, I'm willing to bet that int len = scan.nextInt(); is going to cause you issues
Oh, I see why... I think. Shouldn't it be "ok" in the context of a lab in that the first line will always be an integer?
>>
>>57969809
I don't think there's anything fundamentally wrong with OOP, it's just not very useful and it tends to have a negative effect when it's used inappropriately. FP is basically a refinement of procedural programming and isn't ever really a bad thing unless you go to far trying to make shit immutable because you've bought into the meme that I/O, mutation, etc. can never be pure.
>>
>>57969709
Can you use WHERE in the outside query?
>>
>>57969857
Functional programming is explicitly about keeping your shit immutable, by treating everything like a mathematical formula and not falling back on crutches like state variables.

What do you think FP means?
>>
>>57969924
I can; same result.
I also added to the JOIN; same result.
>>
>>57969854
>D'oh. I'm taking the same object I instantiated at the start and putting it in every spot in the array instead of actually instantiating a new object for each spot in the array.
Yes, you don't even need the for loop. You will need something else to keep track of your current position in the array though.
>Oh, I see why... I think. Shouldn't it be "ok" in the context of a lab in that the first line will always be an integer?
The line itself is correct and will work, but you might need to add something after it. I'll explain the potential problem and see if you recognize it from class or something

Let's say this is your file
4
USD
GBP
BLAH
BLAH


What you have to realize is that at the end of each line is a newline character, so really it looks like this
4\n
USD\n
GBP\n
BLAH\n
BLAH\n


Now the thing you need to know about the nextInt() method, is that it only reads an integer and stops right after that. Nothing more, nothing less. See where I'm getting at?
>>
>>57969939
Nope, it's about making the same inputs give the same outputs. This doesn't mean you can't do mutation or I/O or anything, it just means you have to be more careful.
>>
>>57969965
>>57969709
Doesn't sale date have more than the year?

WHERE s.SaleDate LIKE '%2012%'


I was helping you earlier.
>>
>>57969971
Explain why you can't do this in procedural languages.
>>
>>57970015
You can.
>>
File: parsing HTML with regex.jpg (56KB, 342x588px) Image search: [Google]
parsing HTML with regex.jpg
56KB, 342x588px
Okay so how do I parse HTML?
>>
>>57970023
So why bother making the distinction between FP and non-FP?

Or do you simply admit that you don't know what you're saying?
>>
File: image.png (68KB, 1680x1050px) Image search: [Google]
image.png
68KB, 1680x1050px
>>57967490
>What are you working on, /g/?

Exploring the deepest, darkest corners of Racket by doing Advent of Code 2016.
>>
>>57970033
You can do functional programming in languages like C# and Java.

Just because a language is made to facilitate OOP doesn't mean it can't be functional.
>>
>>57970010
I had an idea it was you as I never see anyone else doing anything Database related.

It does, but that change brings an empty set?
>>
>>57970103
Er, sorry, based on your data you would do
'%2012'
>>
>>57970114
Don't be man;its cool.
Still an empty set,
Although when I change LIKE to '=' it gives me what I had before.
>>
>>57970048
I just made the keypad a 2D array and moved the position if it didn't land on a null space.
>>
>>57970141
I may sound dumb, but does inner query work on its own?
>>
>>57969966
I think I see it now; it'll read the number and just stop reading altogether. I'm getting closer, but I'll probably bug my professor about this whole thing during class or he'll end up going over it anyway but that really helped, thanks anon. I'm not a pajeet in real life, I just play one during night classes after work.
>>
File: beeds_anal.png (28KB, 307x797px) Image search: [Google]
beeds_anal.png
28KB, 307x797px
>>57970183
Depends what I type; pic related.
>>
>>57970222
Wait, what's the datatype on that?

An actual date or is it a char type?
>>
>>57970240
Date
>>
>>57970250
It counts as income.

If someone pays me in gold, I have to declare that as 'income', based on the value of the asset.

>>>/g/sqt
>>
>>57970188
>it'll read the number and just stop reading altogether
Kind of what I'm getting at

Here's your original file (or input stream)
4\n
USD\n
GBP\n
BLAH\n
BLAH\n


int len = scan.nextInt();
runs and successfully reads the first number from the file. The issue comes in afterwards, because your input stream now looks like this

\n
USD\n
GBP\n
BLAH\n
BLAH\n


nextInt() stops as soon as it reads the 4 and leaves the newline character in, which will probably throw off the rest of the code, particularly when you get to the lines with
scan.next();

You need to get rid of that extra newline character somehow (hint hint, look up nextLine()).

Good luck senpai
>>
>>57970260
Shit, nigger, thought you had some weird text type due to the fuckups.

WHERE YEAR(s.SaleDate) = '2010'
>>
>>57970273
thanks, deleted my post and asked in SQT, sorry
>>
File: beeds_r_anal.png (17KB, 471x415px) Image search: [Google]
beeds_r_anal.png
17KB, 471x415px
>>57970297
Still an empty set, what is going on?
>>
>>57970033
Paradigms are more about thinking than they are about tools.

Functional languages facilitate and work well with functional programming but they aren't necessary for it.
>>
>>57970361
Try removing the quotes?

YEAR(SaleDate) = 2010
>>
>>57970290
My original file would actually look like

4
USD GBP
BLAH BLAH
BLAH BLAH
BLAH BLAH


I remember from a previous lab that we used scan.next() to deal with spaces between things on a line, but I'm still not sure if that's the case. I'm actually in class now so I dunno if I'll see your response until I leave, but thanks for everything.
>>
File: what.png (66KB, 725x690px) Image search: [Google]
what.png
66KB, 725x690px
>>57970389
Dude for some reason the dates didn't transfer from my CSV??

Sorry for the wild goose chase.
>>
>>57970033
>>57970374
Like, when people say "closures are a poor man's objects" and vice versa, they mean that you can do OOP in a functional language and FP in an object-oriented language by realizing similarities between closures and objects.
>>
>>57970438
o I am laffin
>>
>>57970433
I mean, next() might still work as you have it now, but that won't take care of the issue of the leftover newline character after reading the first integer

np though senpai
>>
File: extra.png (39KB, 520x469px) Image search: [Google]
extra.png
39KB, 520x469px
>>57970452
Same, but why wouldn't they transfer.
>>
>>57970442
You have no idea what you're saying.
>>
>>57970486
Maybe those aren't valid to be auto-imported by whatever you're using.

You might have to reformat the dates like YYYY-MM-DD or something before you try to import.
>>
>>57970535
Correct me if I'm wrong, then.
>>
>>57970033
>So why bother making the distinction between FP and non-FP?
Have you ever made a burrito?
>>
>>57968771
fucking roll just end me
>>
>>57970552
>Have you ever made a burrito?
I get it.
>>
>>57970538
Will do, thanks again man. Probably be back on /dpt/ soon enough.
>>
>given two integers, make a function that returns their sum
>>
>>57970573
reroll i don't want graphics shit
>>
>>57970598
long Sum(int ayy, int lmao) => ayy + lmao;
>>
>>57970598
functionThatWillTakeTwoIntegersAndAddThemTogetherAndReturnTheirSum :: Integer -> Integer -> Integer
functionThatWillTakeTwoIntegersAndAddThemTogetherAndReturnTheirSum x y = x + y
>>
>>57970598
>>57970615
OH FUCK I DIDN'T READ CAREFULLY

ONE MOMENT PLEASE
>>
>>57970619
>that formatting
Thanks 4chan
>>
>>57970598
EXCEPT YOUR SHIT IS POORLY WRITTEN AND NOW I DON'T KNOW WHAT YOU REALLY WANT

SCOPE CHANGE

FUCK YOU PAY ME

static Func<long> Sum(int ayy, int lmao) => new Func<long>(() => ayy + lmao);
>>
>>57970598
fn makeSumFunction(x: i32, y: i32) -> Box<FnOnce() -> i32> {
Box::new(move || x + y)
}
>>
>>57970598
>>57970619
Oh shit, I see
sumFactory :: Integer -> Integer -> (Integer -> Integer -> Integer)
sumFactory x y = \x y -> x + y
>>
>>57967517
i.e. be a hipster faggot and lower your chances of getting a job
>>
FUCK LAMBDA FUNKTIONS AND FUCK WHITE PEOPLE
>>
>>57970750
All relevant languages have lambda syntax
>>
>>57967517

You know it's possible to use OOP without making it look like over the top corporate bullshit, right? You know there are alternate styles to OOP and Functional Programming, right?

>>57969425

You have asked this same question, with this same picture, several times prior. Either go look up a JavaScript tutorial and start writing code, or give up and stop asking dumb questions.
>>
>>57970691
for what purpose
>>
File: anal beads.png (10KB, 691x223px) Image search: [Google]
anal beads.png
10KB, 691x223px
>>57970819
I think the Haskell is similar to what I wrote

The anon unclearly asked to make a function that returns their sum

The function makes a function that returns their sum
>>
>>57970691
This is wrong. It doesn't use the given integers, it ignores them and produces a function that asks for two integers and gives their sum.
>>
>>57970660
kek'd
all hail rust
>>
>>57970917
Is that funny or something?
>>
File: anal beads.png (17KB, 935x235px) Image search: [Google]
anal beads.png
17KB, 935x235px
WE FUNCTIONAL NOW

SORT OF

static Func<T> SumFactory<T>(dynamic ayy, dynamic lmao) => new Func<T>(() => ayy + lmao);


var SumOf10And69 = SumFactory<long>(10, 69);
var ConcatOfAyyAndLmao = SumFactory<string>("ayy", "lmao");
var DuctTapeOfRapierAndZweihander = SumFactory<Sword>(new Rapier(), new Zweihander());
>>
>>57970943
FACTORIES EVERYWHERE!
>>
>>57970897
Doesn't even run actually
fug
>>
>>57967490
can anyone tell me what string encoding this code will output?
def encrypter(key, in_filename, out_filename=None, chunksize=64*1024):
if not out_filename:
out_filename = in_filename + 'enc'

iv = ''.join(chr(random.randint(0, 0xFF)) for i in range(16))
encryptor = AES.new(key, AES.MODE_CBC, iv)
filesize = os.path.getsize(in_filename)

with open(in_filename, 'rb') as infile:
with open(out_filename, 'wb') as outfile:
outfile.write(struct.pack('<Q', filesize))
outfile.write(iv)

while True:
chunk = infile.read(chunksize)
if len(chunk) == 0:
break
elif len(chunk) % 16 != 0:
chunk += ' ' * (16 - len(chunk) % 16)

outfile.write(encryptor.encrypt(chunk))
csvtosql(out_filename)
>>
>>57968841
>not using visual studio and portable build tools
>>
i2p's network level jitter is fucking with my head
>>
>>57971152
>tfw retarded
>>
How many repos does dpt have and how do you organize them?
>>
>>57971152
what is this?

source?
>>
>>57971152

That's vomitous.
>>
>>57971634
my branch of i2pd i am unfucking
https://github.com/majestrate/i2pd/tree/udptunnel-fix
>>57971664
you're welcome hun, glad you like it.
>>
I have an OOP question regarding dot notation

I always thought you use dot notation to access a method/field which is child of a class, which is child of a namespace

So why are there statements like this:
>document.forms.form_name.elements.value

>value is the field
>elements is ?
>form_name is ?
etc etc

Can someone please explain this
>>
I need to do repeated modular division using a number in the billions. I'm using Python. Linux seems to just kill the process after an arbitrary amount of iterations.

Is this a Python issue, Linux issue, or a hardware issue?
>>
>>57971844
It'd probably be easier with a more concrete example.
I'm not sure what you're asking here because I have no idea of which of those are namespace and which of those are classes. Id assume document is a namespace, forms is a namespace, form_name is a class, elements is a class and value (probably also technically an object) is your primitive value.
>>
>>57971844
When you access a field or call a method of an object, the value you get might be an object, which you can drill into further.
>>
>>57970048
I just finished day 2 and the first part of day 3 in Clojure, myself.
>>
>>57967517
>functional as an alternative to OOP
I've considered this a lot but it's clearly not the next logical step.
And I think any serious considerations in favour of OOP disappears when you realise what it is.
Here's a blog that explains that pretty well in contrast to procedural programming, which we should probably compare to as they fit a common use case much better.
http://blog.ircmaxell.com/2012/07/oop-vs-procedural-code.html
>murrika hours
>implying you won't just throw memes at me
>>
Are you guys going to Lambdaconf?

All the SJWs are still butthurt about it using a blind speaker selection process to choose talks based on technological merit and interest rather than the speaker's political views and affiliations.
>>
>>57971995
Functional programming is the next step of procedural programming, though.
>>
>>57972051
This, OOP was a misstep.
>>
>>57972051
Yes. That's another smaller step you could take according to preference. I don't think functional is where it needs to be for me to go there yet though.
But I don't have enough functional language experience.
>>
>>57972079
And you'll never get functional language experience if you keep retreating to OOP.
>>
>>57972056

Wrong.
>>
>>57972079
>I don't think functional is where it needs to be for me to go there yet though.
How so? There are a few languages that exhibit this refinement from procedural to functional, like Rust, Nim, etc.
>>
>>57971664
I don't know why some people have a thing against blank lines in their code.
It looks so fucking dense without them, and they can be used to separate code into logical blocks.
>>
>>57972085
I'm not doing OOP, ever. That I'm aware of anyway.
It's just that I haven't needed the very high level stuff functional offers.
>>
>>57972095
NO U
>>
>>57971152
>long descriptive names
Is there anyone else here who finds this completely unreadable because of this?
>>
>>57967490
Why is Shinji dressed like a guy from California?
>>
>>57972129
yes, it's completely unreadable for me.
most of my variable names are 3 characters, it's quite jarring
>>
>>57972108
I used to think that way about it too, until I started realizing that my code contained instances of more general abstractions all over the place (abstractions that come easily in FP but are ugly as hell in OOP).
>>
>>57972108
>It's just that I haven't needed the very high level stuff functional offers.
You'd be surprised. Problems that warrant this "very high level stuff" tend to crop up all over the place, once you know what to look for, anyways.
>>
>>57972218
Not possible in Python.
>>
>>57972129
Yes, it's both awful to write and read.
The mix of PascalCase and camelCase doesn't help either. I find either of those shitty styles to be ugly to read.
>>
>>57971152
Is mmm-mode any good?

I'm trying to get better code editing in org-mode

Would you be able to share bits of your configuration?
>>
>finally understand and can use multi threading at will

I HAVE THE POWER
>>
Is there a use for dependent types beyond vectors that know their length?
>>
>>57972240

Really? Damn.

Is there a way to accomplish what I'm trying to do here?

Basically, I want to be able to take a user input and quickly and with relative simplicity, check the keyword against a list, and execute a corresponding function.

Seems like pretty basic stuff, and I know I'm essentially just reinventing the wheel here.
>>
>>57972272
Maintaining pretty much any invariant you can think of.
>>
>>57972225
I'd say my problem is that my code reuse is relatively small to begin with so I'm not that advantaged from functional. And where I have it I usually write a few pure functions and I'm fine.
But maybe.
>>57972237
Maybe.
I'd need a functional language that doesn't feel like a waste of time because I'm not really all that motivated to learn because it doesn't feel needed.
>>
>>57972271
Cool, so your Java class finished covering Runnables and locks?
>>
>>57972240
Oh come on surely it's possible. I don't know python but I've seen them do the equivalent of function pointers/references.
>>
>>57972278
I don't actually know Python, I just assume anything nontrivial is impossible in it.

>>57972285
Sounds like combinatorial explosion waiting to happen.
>>
>>57972305
>combinatorial explosion
How so? Do you even know what this means?
>>
>>57972111

Wrong again.
>>
>>57972305
>non trivial
This is certainly trivial.
>>
>>57972311
Well, wouldn't you end up dragging around a big list of invariants into pretty much every type signature in your code?
>>
>>57972318
Not in Python it isn't!

>>57972314
NO U
O

U
>>
>>57972325
Do you end up dragging around a big list of the different fields and methods that things support in every type signature in your code?

No, you have type definitions.
>>
Guys can you wait an hour or so before making any more posts? I need to go pick up groceries.
>>
>>57971844
You essentially access a member property (be it a variable or a method).

value is a property of elements
elements is a property of form_name
forms is a property document
document is the "root" object
>>
>>57972218

disregard, solved.
>>
>>57972218
def helloWorld():
print "Hello World!!"

commands = {
'hello': helloWorld
}

uComm = raw_input()
command = commands.get(uComm, None)
if command:
command()
>>
File: wojak3.png (21KB, 633x758px) Image search: [Google]
wojak3.png
21KB, 633x758px
Probably won't get any better unless I use the genuine voronoi algorithm, but that shit takes over an hour to run.
>>
A cheap Point Of Sale program in terminal to demonstrate basic fundamentals to a new student that I'm tutoring.

But on a side note. I just got a macbook air and I don't really want to code in C++. I like learning languages and have no real goal in mind. I just enjoy programming random shit and working on open source projects here and there.

Should I learn java, objective-C/C++, or give swift a go? I'm bored and want to pick up something new to try when I'm at work. Any suggestions? I don't generally program graphical things so maybe something in that area? I usually do like automation an behind-the-scenes programming.
>>
for (;;i++){
Beep(i,100);
}
>>
>>57972492
C++ will teach you more about how it all works than all the others; just make sure you use classes otherwise you might as well just use C
>>
>>57972552
Nice noise.
>>
File: y-yatta zo.webm (464KB, 1280x720px) Image search: [Google]
y-yatta zo.webm
464KB, 1280x720px
>>57972652
>just make sure you use classes otherwise you might as well just use C
>>
how do I make haskell take dash interspered functions as legal names?
>>
I'm trying to write a simple C++ application that reads json file to a buffer, parses that buffer and does stuff with values from json.
But how do I pass data from one object to another? Should I simply pass references as construtor parameters? So Reader would take a reference to Buffer that it has to fill, later on Parser would take a reference to a Buffer that it has to parse and to a vector where parsed data should be put and so on? I'm clueless.
I already did the thing in C and it works without a single leak, but I'd like to try something different.
>>
>>57972717
Yes, that sounds good.
>>
>>57972717
look up some beginner OOP tutorials on youtube
>>
Hey guys I'm going to dedicate this winter break to learning how to write Android applications. Does anyone go outside of their homes to program? I was thinking about finding a cafe and just hanging out there. I have bad social anxiety and I want to tackle it head on.

Where do you program besides at your house?
>>
who here /fold/
>tfw using foldl as much as I can
>foldr too but not much, only when order matters
>strict fold' for that efficiency

And now they added the Foldable type class?
What else can you fold, a a binary tree maybe? but there would be multiple ways to do, so I guess it it isn't in terms of left and right folding anymore

also, fuck your language if it calls it "reduce"
>>
>>57972854
don't, you'll be called a hacker or will be enriched
>>
>>57972652
How what all works? I already know how to program. I'm just looking to throw another language under the belt for funsies.

Since I'm on a mac I figured I'd might take a leap into the world of objective-c or swift and see what mac and apple have to offer. On the other hand I dislike the idea of spending time on a locked platform.
>>
>>57972855
>tfw using foldl as much as I can
>foldr too but not much, only when order matters
You've got it the wrong way around pal
>>
>>57972942
foldr (:) [] == id
foldl (:) [] -- type error
foldl (flip (:)) [] == reverse


thus, foldr for when order matters
>>
>>57972855
Look into catamorphisms and F-algebras in general.
>>
>>57972552
error: use of undeclared identifier 'i'
warning: implicit declaration of function 'Beep' is invalid in C99
Undefined symbols for architecture x86_64:
"_Beep", referenced from:
_main in test-dee6a0.o
error: linker command failed with exit code 1
>>
File: newest_stipple_algo.png (22KB, 633x758px) Image search: [Google]
newest_stipple_algo.png
22KB, 633x758px
So I came up with an entirely new stippling algo and the result is pretty good. Just trying to figure out how to do some distribution such that each region will get a few points (as some don't have any).
>>
>>57973130
Why don't you stop tripfagging once for all?
>>
>>57973252

What good would that do? After all, you RESPONDED, didn't you?
>>
>>57973266
You're literally begging for attention and it's annoying.
>>
File: 1432860473789.png (40KB, 335x342px) Image search: [Google]
1432860473789.png
40KB, 335x342px
>Write a regular expression implementation for a university assignment
>Wasn't too hard, got an A+
>Want to rewrite it into a library and add more useful features, just for fun
>Realise how hard it's going to be to implement now
>>
def weave(*args):
args = [(x for x in y) for y in args]
while len(args) != 0:
i = 0
while i < len(args):
try:
yield next(args[i])
except StopIteration:
del args[i]
i -= 1
i += 1


Ugh, I hate it. But I have to avoid looping over an iterable I'm modifying and I can't really think of a different way.
>>
>>57973310
At least he knows what he want. Do you?
>>
File: Inventory Item Class.png (331KB, 816x422px) Image search: [Google]
Inventory Item Class.png
331KB, 816x422px
New guy here, how exactly do I export my code on here in posts?
>>
>>57973121
That's just the main loop of the code. Of course you need to declare i and include windows.h.
Also, Beep() only works from XP and below. On Vista and above, you hear a muted "boop".

Here, the whole code:
#include <stdio.h>
#include <windows.h>

main(){
int i = 300;
for(;;i++){
Beep(i,100);
}
}


i starts from 37 because the lowest frequency Beep() accepts is 37 Khz.
>>
>>57973442
type in :codeblock: in the options field and type

!!CODE
and then your code goes in here
>>
>>57973460
>>57973121
To add to this: on Windows XP and below, you'll hear some sort of synth intro, until i reaches 0xFFFF. On Vista and above, you'll only hear a bunch of beeps, and the loop will fail after a while.
>>
>>57973460
>Khz
kHz? That's really high... If it's a system beep it probably starts at 37Hz
>>
>>57973508
I meant Hz, yes. And the code shows 300, but it's actually 37. I forgot to change that.

I remember doing some rad synth keyboard application once, where I used getch() to translate the keys pressed on the keyboard to sounds of various frequencies and tempos. Too bad Beep() is deprecated nowadays. I remember when graphics.h was the hot stuff too.
>>
>>57973327
Be aware program complexity always increases exponentially.
>>
>>57973470
Let me test this out.

!!CODE
Public Class Inventory
Private strInvNumber As String
Private strDescription As String
Private dblCost As Double
Private dblRetail As Double
Private intOnHand As Integer

End Class

Like this?
>>
File: poopy the freg.png (46KB, 620x683px) Image search: [Google]
poopy the freg.png
46KB, 620x683px
Hmm, I am thinking now.
>>
>>57973460
>>57973505
I'm on mac familia
>>
>>57973442

You ever used bbcode? In a lot of old forums, it was common to format your code using an HTML-like formatting language that looked [b]like this[/b]. That kind of tag would make your text look bold, [i][/i] would make it italics, [u][/u] would make it underlined, etc...

4chan uses a single bbcode tag, called code. So you surround code and /code with square brackets, and the text in between gets formatted using syntax highlighting and a monospaced font. Also, whitespace doesn't get destroyed. It should look like this if you did it right:

while true
Learn.new :things
end
>>
>>57973537
No.
Use <code></code> tags. (switch < with square brackets).
>>
>>57973555
>windows.h
>mac
Either way, the Beep() function is deprecated because it uses the PC speaker to play the sounds, and present operation systems try to pass those calls to your soundcard instead, which makes it incompatible.
I can probably record a video of myself doing it on XP. I'm pretty sure you've heard this "synth intro" effect on some movie, because it's really easy to do.
>>
>>57973442
lurk moar faggot
>>
>>57973369
I know I want him to fuck off.
>>
>>57973601
*operating systems
>>
>>57973573
>>57973580

Test again

Public Class Inventory
Private strInvNumber As String
Private strDescription As String
Private dblCost As Double
Private dblRetail As Double
Private intOnHand As Integer
End Class
>>
>>57970029
recursive descent
>>
Should I learn C or Haskell?
>>
>>57973620

Good job. Unfortunately, you used Visual Basic to test the code tags, so now all I see is ugly.
>>
>>57970029
parser monad
>>
>>57973638
Both.
>>
>>57973638
I know this is a bait question, but please don't listen to the memers in this thread on the off chance that you're genuine. Haskell is legitimately useless and C is one of the most-used languages on earth.
>>
>>57973642
I'm sorry, I'm just trying to finish my final and I was wondering if someone can explain to me how I'm supposed to use the integer in the code. I'm not asking anyone to do my work, just try to tell me how I'm supposed to implement it.

For photo reference: >>57973442
>>
>>57973638
Yes, you should.
>>
so i read sicp and then went to doctor and he said i have aids??--just wanted to know if this are linked??
>>
>>57973702
Yes, they are.
>>
File: 1456166489466.jpg (27KB, 592x448px) Image search: [Google]
1456166489466.jpg
27KB, 592x448px
Programming localisation for 10 languages

Cool with them all except Arabic, since it's right-to-left.

I can't tell if the text i'm copy and pasting is being reversed or not, it's all fucking squiggles.
>>
What the hell do I put in the interests section of a CV for an application to a PhD program? Do I just put in my main interests academically (i.e. operating systems, compilers, security)? Do I put in my interests outside of academia that may be related to my position, like the fact that I like to occasionally write toy programs or contribute to open source projects? Normally, I'd want to skip this section, but it seems the university is specifically requesting it, noting:

>Please include other activities and interests that will help understand you as a well-rounded student.

>>57973638

Learn C first, because every programmer must know C.

Learn Haskell afterwards if and only if you have an interest in functional languages, type theory, or programming language theory.
>>
>>57973785
put all that down; do you see it hurting?
anyway in my experience the only things that matter are rec letters
>>
File: sicp.jpg (100KB, 600x338px) Image search: [Google]
sicp.jpg
100KB, 600x338px
>>57969939

>>57969939

No it's not, programming is not maths. We simply can't use map and filter functions for everything.

A function does not have to be a mathematical predicate or procedure, in fact they're two very different things for a reason.

Think about it for a moment, as long as you have main memory things will never be immutable. You can't just have everything interpreted because well for starters a lot of actual mathematical functions or procedures won't allow for that.

Secondly linear recursion is dogshit. It's
O(n) * O(n)
for each recursive call or loop. That's borderline some of the worst performance ever.

If you make your recursive program iterative, ie you give it stated variables, then you can bring it down to O(n) quickly with just some clever programming.

This whole meme of people holding FP up to be flawless programming is out of control. FP is useless unless you actually use your fucking head as a programmer too and don't program trash.
>>
>>57971416
anyone?
>>
>>57971416
github
5 that matter, 11 that don't
in reality none of them matter
>>
File: H9U8Qi7.jpg (251KB, 688x1448px) Image search: [Google]
H9U8Qi7.jpg
251KB, 688x1448px
>>57970033

Calling a language a "functional language" references that it's specialized for functional programming, it doesn't mean the others can't do it.

Java for eg, happy number predicate with sqr func

    Function<Float, Float> fastSqr = x -> x * x;

Predicate<Integer> fastHappy = x -> {
float sum; float digit;
while(x != 1 && x != 4 && x != 89){
sum = 0;
while(x > 0){
digit = x % 10;
sum += fastSqr.apply(digit);
x = x / 10;
}
x = (int) sum;
}
return (x == 1);
};
>>
>>57970607

lol
>>
File: parallel.png (32KB, 1304x333px) Image search: [Google]
parallel.png
32KB, 1304x333px
Could anyone explain to me why the register becomes 0110 even if the input b0-b3 is a 0000 and it's being parallel loaded?

(on the last line)

https://www.cs.umd.edu/class/sum2003/cmsc311/Notes/Overall/register.html
>>
>>57974069
Probably a typo. Register's content will become 0000
>>
>>57973810

>do you see it hurting?
Well, I'm not sure if it would help or hinder it.

>in my experience the only things that matter are rec letters
Considering all three of the professors I asked to write letters were very eager to do so, I may have this in the bag then. Hopefully...
>>
>write a medium (templated) c++ thing
>focusing on one method at a time with nice editor and syntax highlighting, using modern practises and writing okay code
>paste it into a code dump and step back, take it all in at once
>ugly as fuck despite being actually alright code

god damn it c++
>>
>>57974175
C++ is innately ugly. You can't write non-trivial pretty code.
>>
Why do you guys hate OOP so much?
Isn't abstraction the point of programming languages to begin with?
>>
>>57974204
OOP produces poor abstractions.
>>
>>57974214
Why though.
>>
>>57970029
damn
>>
why did i bother learning bash
>>
What are your favorite books for learning programming? I'm currently in need of some java books.
>>
>>57974204
http://docs.spring.io/spring/docs/2.5.x/javadoc-api/org/springframework/aop/framework/AbstractSingletonProxyFactoryBean.html
>>
>>57974266
'sheed
>>
https://news.ycombinator.com/item?id=13163367

okay guys here's all the stuff to learn to get a job
looks simple enough
>>
https://info.ecosia.org/what

Working on saving the world
>>
>>57968817
K&R, and if you get bored, go with python. And if you then feel worthless and find out there is a web dev job nearby , go with HTML, CSS , JS, jquery and php
>>
Does /dpt/ have its own version of the Saitama training speech?
>>
>>57974320
>These are just a few of the benefits
>HAPPY PEOPLE
>The happy people are Africans?!
>>
>trying to use Gaussian distribution for sorting points into regions based on their color ""density""
>it's not working.

Fugg. I'm so god damned close to an algorithm that closely approximates Voronoi stippling without actually taking an hour.
>>
>>57974372
Nobody cares you nerd
>>
File: 1481300302478.png (9KB, 404x399px) Image search: [Google]
1481300302478.png
9KB, 404x399px
>>57974390

B-but! Wrong! WRONG!
>>
>>57974372
clean it up and publish it when you're done
>>
>>57974418

Perhaps I will. Sorting on region density works, I just can't properly massage random normal dist into appropriate indices, heavily weighting towards 0.

Maybe I'm just retarded.
>>
Python --> Go is the best learning path
>>
>>57967490
Are there any good resources for learning ladder logic?
>>
>>57974522
HTML & CSS --> Javascript --> PHP --> Python --> Java --> C (--> C++) --> Haskell --> Prolog is the best learning path
>>
>>57973367
Anyone want a challenge?
>>
>>57974522
C -> C++
>>
How do I learn x86 assembly?
>>
>>57974545
>HTML & CSS --> Javascript --> PHP --> Python --> Java
>--> C++
God no. These are all terrible languages.
>>
File: robby.jpg (19KB, 500x335px) Image search: [Google]
robby.jpg
19KB, 500x335px
>>57974522
pic

>>57974545
>what I did is best
>>
>>57974570
C --> Haskell is the best learning path
>>
>>57974569
Assembly Step By Step book
>>
>>57974583
Is there anything wrong with what I did, you little bitch?!
>>
>>57974615
>i learned sewing before i learned to swim and I think that's necessary
>>
>>57974522
C --> Scheme --> Python
enjoy guaranteed jobs
>>
>>57974615
Yes. HTML/CSS aren't programming languages and won't get you anywhere, Javascript is enough to learn some simple OO and logic, PHP won't get you anywhere, prolog is useless.

JS -> Java -> C -> C++ -> Lisp/Haskell/Something functional is fine. You don't even need to do JS for any reason.
>>
>>57974681
JS is a horrible place to start. It's worse than starting someone on Python.
>>
>>57974681
>prolog is useless
But I had to learn it for my master's degree. :[
>>
>>57973638
C will teach you to optimize your program.
Haskell will teach you to optimize your programming.
>>
File: simple typed.png (16KB, 552x230px) Image search: [Google]
simple typed.png
16KB, 552x230px
did this

going to start over for polymorphism, probably use more of a guide
>>
NEW THREAD!

>>57974736
>>
File: 1468894803492.gif (999KB, 500x700px) Image search: [Google]
1468894803492.gif
999KB, 500x700px
Currently trying out ReactJS. Horrified that a simple example app requires 1.8MB after webpack.

Going to work through Sirajology's videos on youtube and put together a HFT bot that uses Twitter sentiment analysis and Trump tweets to see if it can beat the market.
>>
>>57974570
They're not that terrible if you actually want to get a job and not be a fucking NEET.
Thread posts: 314
Thread images: 41


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

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
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.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.