[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: 35
File: comb.png (336 KB, 1536x2048) Image search: [Google]
comb.png
336 KB, 1536x2048
babby's first combinatorics homework edition

Old: >>54972264
>>
>299 posts
Yeah, fuck off.

Saged.
>>
>git gudder
>suddenly find myself needing linux
What does it mean?
>>
File: crying-baby-1.jpg (15 KB, 635x414) Image search: [Google]
crying-baby-1.jpg
15 KB, 635x414
>>54980570
>>
>>54980467
4th for Go.
>>
>>54980718
Stop crying you stupid fucking woman, clearly you're fucking new around here
>>
>>54980787
>being this butthurt
>>
so in trying to learn Berkeley DB and following their stuff but clang and gcc both claim they dont know of db_create...

i included db.h and checked to and if it existed. Why would it not find db_create?
>>
>>54980796
>b-b-b-b-b-b-b-b-ut i-i-i-i-i-i-i w-w-wanted to make the op image!
>wwwwwaaaaaaaaaaaaaahhhhhhhhhh
Fuck off you stupid fucking child
>>
>>54980815
>>b-b-b-b-b-b-b-b-ut i-i-i-i-i-i-i w-w-wanted to make the op image!
what the fuck?
>>54980815
>Fuck off you stupid fucking child
nice projection
>>
>get ears cleaned out
>can hear 20% better and can tell the difference between 320 mp3 and flac

I bet you fags use cotton swabs
>>
>>54980836
>h-h-h-hahah-ha y-youre p-projecting
>>
>>54980714
git is best on linux
>>
>>54980873
nick bate is that you?
>>
>this thread only has 4 on-topic posts

>>54980467
Some of these would be fun for a newbie programmer to do in their learning language.
>>
>>54980970
That's what happens when someone starts such a cancerous thread
>>
>>54980970
You don't need a computer for them
>>
>>54981013
They're still good practice for learning basic syntax in a language.
>>
NEW THREAD WHEN?
>>
>>54980570
>>54980787
>>54980815
>>54980876

reported
>>
Reposting for /g/entoomen help
>need block device with FAT32 partition for USB gadget
>want to "export" CIFS share as that device
>planning on writing a FUSE file system that creates the block device from scratch and places all the files in the CIFS share into it, redirecting reads to the CIFS share when reads are performed on the specific file in the virtual FAT32 file system
Is there an easier way to do this? Like a way to turn a directory tree into a block device or something?
>>
>>54981097
>7
ishyggy
>>
>>54981097
Clearly the janitors lost us long ago if a thread can be made 12 posts too soon
>>
>>54981103
>turn a directory tree into a block device
you don't even realize what those words mean, do you?
>>
>>54981125
pure chaos, totally worth incessantly shitposting over
>>
File: garbage.jpg (79 KB, 911x824) Image search: [Google]
garbage.jpg
79 KB, 911x824
Making a scraper.

Scraped the previous thread, here's a frequency map of it.
I'll probably think of some way set it up graphically on my end later on.
>>
>>54981165
>java
>Poo
it's pottery
>>
>>54981156
>telling a faggot off for breaking the unwritten rules of the thread by splitting it so he can post his own fucking image
>shitposting

Eventually it'll be 20 posts early, and then 30 posts early. A few days ago (or maybe more?) we were having threads 50 fucking posts early
>>
File: 1363930107434.png (101 KB, 822x796) Image search: [Google]
1363930107434.png
101 KB, 822x796
>applying for C# and SQL jobs
>have no idea what kind of questions C# jobs will ask

anyone got any ideas? is it going to be just about the language C# or will there be algorithm designs? I would be better with algorithm designs as some of the stuff with C# I don't know like delegates, Reflection, anonymous methods.

I tried to look up interview type questions in C# but they all strictly focused on the minutia of the language.
>>
>>54981182
Oh no! That might interfere with these TOP QUALITY discussions!
>>
whoa! 30 posts already! this thread is old, when do we start a new one?
>>
>>54981165
help me understand this.

so you scrap the entire thread, and then you build an image automatically with those words written?
>>
File: 1958201258.png (147 KB, 815x627) Image search: [Google]
1958201258.png
147 KB, 815x627
Reminder that ALL /dpt/s are cancerous these days, regardless of when they were started or if the old thread was at the bump limit
>>
>>54981273
can you even EOF, jsfeg?
>>
>>54981240
Should do it just to provoke more autistic conniptions tbqf
>>
>>54981291
Who the fuck is jsfeg and how retarded are you to presumably be defending someone who says sum types aren't necessary?
>>
>>54981242

I didn't build the image myself, not yet. It's something I'm going to implement later.

I merely scraped the thread for posts and built a dictionary with word frequencies. Then I used some online tool to make the image.
>>
>>54981304
>I can't into
jshit confirmed
>>
>>54981321
retard
>>
>>54981214
Well I've been asked about LINQ knowledge, delegates, properties, if I ever used winforms and know what an event is.
As I said cpp is my strongest side I've been asked few questions about it.
From sql - transactions, difference between having and group by, dbms i know and worked with etc.

i'm working in .Net now but back then I wasnt attending purely for that position as it's an ousourcing company and they use shittons of technologies.
>>
>>54981273
>union types
>not sum types
I'm unable to even
>>
>>54981321
What?
>>
>>54981307
Could you share that tool?
And what format of input data does it accept?

Looks pretty nice desu.
>>
What's the best hash map for C?
>>
>>54981336
>struct types
>not diff types
wtf anon?
>>
I'm running into some design issues.

Basically I want to tag images using directed graphs. So if there's two people in a picture kissing, the simple tag graph would be

(Person A) <---(kissing)---> (Person B)

Now, by the current mindset of searching pictures with tags, we'd have three tags in this picture. Person A, Kiss and Person B.

In a graph the persons would be nodes, and the "relationship" an edge. Now, from a user perspective, I want to search for any images that has the tag "kiss" in them. In other words, this qualifies as both a node and an edge.

Anyone familiar with graphs and storing/querying them using relational databases?
>>
>>54980813
anyone?
>>
>>54981357
surely you mean product types
>>
File: javafag.png (28 KB, 610x365) Image search: [Google]
javafag.png
28 KB, 610x365
>>54981336
I asked anon to do something like this

type BankAccountStatus = Closed | Open of float

He said it was disgusting and retarded
>>
File: k2s.jpg (31 KB, 549x371) Image search: [Google]
k2s.jpg
31 KB, 549x371
>captcha solver
surprisingly easy
>>
>>54981351
the one you write yourself
>>
>>54981347
I just googled word frequency map and got this:
http://worditout.com/

I'm sure there are better tools out there but this one worked fine.
>>
>>54981365
>So if there's two people in a picture kissing
please keep this sexual language out of /dpt/. we, as a community, really have to adopt a code of conduct.
>>
File: 8.png (16 KB, 260x80) Image search: [Google]
8.png
16 KB, 260x80
>>54981370

Keep2Share's shitty captcha I should add, not Google's
>>
>>54981379
Thanks, my gf is making her final projects related with literature. This thing might come handy in some of her presentations.
>>
>>54981370
>>54981392
whats your accuracy?
whats your process? are you using a neural network?
>>
>>54981370
>>54981392
>not getting the i
>>
File: scraper.png (34 KB, 1058x85) Image search: [Google]
scraper.png
34 KB, 1058x85
>>54981165

neat
>>
>>54981370
>>54981392

Trying to automate downloading your fetish porn off k2s, I see.
>>
>>54980467
Does anyone know of any free pre-packaged gamestate C++ libraries similar to HUMP's Gamestate.lua?
>>
>>54981507
>pre-packaged
>C++
babby...
>>
>>54981611
>babby
this isn't reddit anon
>>
>>54981611
okay pre-packaged is clearly the wrong term but I mean pre-written or something. You know how SDL, OpenGL, etc. let you use GR4PH1KZ without having to write your own GR4PH1KS rendering code? I want something that'll let me use gamestates without writing my own gamestate code.
>>
>>54981418
>whats your process? are you using a neural network?
Deep convolutional neural networks
>>
>>54981706
What do you mean by gamestate?
>>
How do you decide what to put as a template parameter when writing C++ code?

Like if you're implementing something that uses floats, it makes sense to use a template because somebody else might want to use doubles.
Maybe internally you use a std::vector to store values, but in order to allow people to use custom storage and allocation, you might want to template the container as well which makes your code rely on generic container concept and makes it use types like Container::iterator all over your code which makes it completely unreadable.

Also, how do you know if you're supposed to implement something as a function or a class?

For example the algorithm you're implementing takes two lists of values, does some computation on them and returns the result.
If you implement it as a class, you take care of the storage of the values, its changes and implement the algorithm as a method.
If you implement it as a function, the user has to write a lot of extra code, but makes it much more flexible to use.
Another example would be the regex library which is implemented as a bunch of templated functions in the standard.

I feel like once you get to the point where you know too much about C++, it becomes harmful to your productivity because you start worrying about things like this instead of just writing code.
>>
I'd like to learn some assembly, but I have a question

Is it similar conceptually to the register machine language that they develop in chapter five of SICP
>>
Has anyone tried using git to maintain version control for things that aren't source code?

Would it work on project files for other software?
>>
post your favorite language and one of it's flaws, I'll start:

Rust
none
>>
>>54982043
https://www.rust-lang.org/conduct.html
>>
>>54981975
Template everything
>>
>>54981999
fine for text based files, don't use git for binary files though
>>
>>54982043
Rust has no stable ABI
>>
>>54982052
BTFO
>>
>>54982059
And end up with like 10 template parameters for a simple A* algorithm implementation.

There has to be some guidelines as to what to template and what not to template.
>>
>>54981706
write your own gamestate shit fgt there is no "one size fits all" unless you're doing some really babby shit but then it'd be trivial to write it yourself anyway. if you're trying to avoid learning things at all costs then C++ is not what you should be using
>>
File: pi-approx.webm (3 MB, 964x580) Image search: [Google]
pi-approx.webm
3 MB, 964x580
open Num
open Printf
open Random
open Unix
let spawn f =
let fdin, fdout = pipe () in
match fork () with
| 0 ->
let pid = getpid () in
init (int_of_float (time ()) + pid);
let oc = out_channel_of_descr fdout in
f oc;
exit 0
| pid -> fdin
let work oc =
let rec loop count success =
let x = float 1.0 in
let y = float 1.0 in
let count = succ count in
let success =
if x *. x +. y *. y < 1.0 then succ success else success in
let count, success =
if count mod 20_000_000 = 0 then
begin
Marshal.to_channel oc (count, success) [];
flush oc;
0, 0
end
else
count, success in
loop count success in
loop 0 0
let rec print_int oc n =
if n >= 1000 then
fprintf oc "%a,%03d" print_int (n / 1000) (n mod 1000)
else
fprintf oc "%d" n
let radix = Int 1000
let rec print_num oc n =
if n >=/ radix then
fprintf
oc "%a,%03d"
print_num (quo_num n radix)
(int_of_num (mod_num n radix))
else
fprintf oc "%d" (int_of_num (mod_num n radix))
let main_loop children_count =
let rec loop accu = function
| 0 -> accu
| k -> loop (spawn work :: accu) (pred k) in
let start = gettimeofday () in
let fdins = loop [] children_count in
let rec loop count success =
let rs, _, _ = select fdins [] [] (-1.0) in
let rec take count success = function
| [] -> count, success
| fdin :: css ->
let ic = in_channel_of_descr fdin in
let c, s = Marshal.from_channel ic in
take (count +/ Int c) (success +/ Int s) css in
let count, success = take count success rs in
let pi = approx_num_fix 30 (Int 4 */ success // count) in
let speed =
int_of_float
(float_of_num count /. (gettimeofday () -. start) +. 0.5) in
printf "%a\t%aHz\t%s\n" print_num count print_int speed pi;
loop count success in
loop (Int 0) (Int 0)
let () = main_loop (int_of_string Sys.argv.(1))
>>
File: 1449543340963.jpg (7 KB, 250x241) Image search: [Google]
1449543340963.jpg
7 KB, 250x241
>>54982052
>We are committed to providing a friendly, safe and welcoming environment for all, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, nationality, or other similar characteristic.
>>
>>54982043
Go
literally none
>>
File: ss (2016-05-26 at 03.14.22).jpg (17 KB, 264x338) Image search: [Google]
ss (2016-05-26 at 03.14.22).jpg
17 KB, 264x338
>>54980467
Sauce? I have some books on these Olympiad problems but I can't find this combinatorics one.
>>
>>54981918
Well shit, that's a good question. You just made me throw out everything I thought I knew about porting this lua game to C++.
>>54982112
It's not about avoiding learning things, it's just kinda confusing sometimes when someone says "DURR how do I write X library" and people tell him to stop being a retard and use a pre-written library.
>>
>>54982144
the syntax is literally disgusting and there are no real advantages of it over java except you can be a stupid ass smug hipster about using "not java"
>>
>>54982125
Nice, why are you using this shitty approximation though? Ramanujan came up with nicer.
>>
>>54982180
you should always avoid external dependencies unless it's some stupid standardized shit that you can't be arsed dealing with like decoding mp3 files or something, gamestate stuff is not standardized at all, it depends heavily on the specific game, it's definitely something you should write yourself
>>
>>54982181
and the JVM startup, and the memory usage, and the simpler language, and...
kys, pajeet
>>
>>54982205
Too lazy to implement a good algo
>Ramanujan came up with nicer
gimme link
>>
>>54982217
kys dumbass go sucks fucking ass and is an irrelevant hipster lang
>>
>>54982078

This. This is one of its major pain points and the reason it can not replace C currently. Its verbosity is also somewhat of a major pain point.
>>
>>54981215
You're the kind of faggot he's pointing out, dipshit. Good one reiterating the point he was making, though.
>>
var facts [10001]*big.Int
facts[0] = big.NewInt(1)
big_i := new(big.Int)


this is what gophags actually believe
>>
>>54982223
https://en.wikipedia.org/wiki/Approximations_of_%CF%80#20th_century
There are two in the article, but he has many more. Just look around the internet.
Stephen Wolfram wrote a great article on Ramanujan btw: https://backchannel.com/who-was-ramanujan-83b4d5b05665
>>
File: current year dreamy.jpg (38 KB, 367x390) Image search: [Google]
current year dreamy.jpg
38 KB, 367x390
>>54981357
>not quotient types
>>
File: spigot_BBP.png (32 KB, 735x117) Image search: [Google]
spigot_BBP.png
32 KB, 735x117
>>54982223
>Too lazy to implement a good algo
Literally every other "algorithm" I can think of is easier to implement and better than that monte carlo bullshit (which is a horrible example for monte carlo btw).

Pic related is probably among the best. Extremely fast to implement as well if you do it right.
>>
>>54982227
calm down pajeet, you'll have to learn Go sooner or later
>>
>>54982294
this is what gophags actually believe
>>
>>54982266
The Ramanujan approximation is remarkable in its own right, but practically useless for numeric reasons. So, please, don't implement that, you will enter a world of pain (and probably won't get further than a single step without arbitrary precision libraries and even with it gets pretty fucking shitty after 7 steps or so).
>>
>>54982304
Pajeet, go back to >>>/int/dia
>>
>>54982319
>uses go
>thinks he has the mandate to call others pajeet
stay smug hipster fag
>>
>>54982288
The spigot algorithm is used for computing specific single digits, not for expansions.

>>54982316
>The Ramanujan approximation
What do you mean? There are many, some of which are great for numeric methods.
>>
>>54982350
>uses Java
>calls others pajeet
literally can't make this shit up
did you even pass meme school kid
>>
Vim users, what escape key do you use?
>>
>>54982360
go is a pajeet tier codemonkey language idiot
>>
>>54980873
Funny. At the doctor's to clear out an impaction.

>tfw freshly cleared ears means you can hear the universe expand
>>
>>54982368
capslock
>>
>>54982368
i can't quit vim since i opened it 2 years ago
>>
>>54982369
Go and Java are shit languages
Stop pretending to fit in
>>
>>54982350
>better performance than java
>better resource usage than java
>much simpler
>no OOP bullshit

pajeet, you should face reality before it's too late. Go is really easy to learn anyway, so you won't waste time at all
>>
>>54982408
hahah, I get it, because you can't le quit with let control-c, lol, top bamboozle
>>
>>54982437
see >>54982426

you are literally
>a stupid ass smug hipster about using "not java"
>>
>>54982277
redpill me on quotient types anon
>>
>>54982262
>>54982262
>>54982262
>>
>>54982359
>There are many, some of which are great for numeric methods.
But certainly NOT for someone who just picked up programming. Implementing those series is very difficult (and I don't think any of Ramnujan's original formulas are used to do that, nor have they ever been seriously used).

Also the spigot algorithm is still very good, easy to implement and very fast.
>>
>>54982454
k functional tard, keep bragging about your bloated, "intellectual" mess of a language

>>54982368
esc
>>
>>54982239
it's not verbose at all compared to c/c++
>>
>>54980873

getting ears blasted means i can just hear my tinnitus louder

no thx
>>
File: rust.png (15 KB, 602x255) Image search: [Google]
rust.png
15 KB, 602x255
>>54982482
yes it is it's fucking disgusting
>>
>>54982503
that doesn't even make sense and how can you have such filthy ears in the first place
>>
File: VID_20160608_173720.webm (3 MB, 1280x720) Image search: [Google]
VID_20160608_173720.webm
3 MB, 1280x720
What are some good resources for learning to program microcontrollers? Specifically the PIC32 pictured. I don't really know any C.
>>
>>54982520

my ears are literally pristine 100% of the time but who really gives a shit its an anonymous imageboard nobody needs to know about my ears

tinnitus is from loud noises
>>
>>54982536
>>>/diy/ohm
>>
>>54982536
K&R
http://ww1.microchip.com/downloads/en/DeviceDoc/61156H.pdf
>>
>>54982563
> /ohm/
>>
>>54982536
That's an allsop mouse pad isn't it.
>>
http://www.tiobe.com/tiobe_index
>java/C/C++ in the lead
>rust and go at #46 and #48 among fellow literally who langs
>>
>>54982507
what colorscheme anon? and editor?
>>
>>54982602
there's literally microcontroller talk in there, /dpt/ is "softwareonly babbies", most of us don't do microcontroller shit, same as webshit, >>>/g/wdg is much better for webshit, most of us don't do webshit
>>
>2016
>people still care about popularity contests

future pejeet developers everyone
>>
>>54982637
the editor is atom i got the pic off of github on google image search
>>
I want to use EBML but I don't understand how IDs work.
       Info := 1549a966 container [ card:*; ] {
SegmentUID := 73a4 binary;
SegmentFilename := 7384 utf8;
PrevUID := 3cb923 binary;
PrevFilename := 3c83ab utf8;
NextUID := 3eb923 binary;
NextFilename := 3e83bb utf8;
TimecodeScale := 2ad7b1 uint [ def:1000000; ]
Duration := 4489 float [ range:>0.0; ]
DateUTC := 4461 date;
Title := 7ba9 utf8;
MuxingApp := 4d80 utf8;
WritingApp := 5741 utf8;
}

This is from the mkv format. They seem to have just chosen completely random numbers.

How do I choose correct ids? Are there reserved ids? This makes no sense to me.
>>
File: hipster.jpg (111 KB, 500x618) Image search: [Google]
hipster.jpg
111 KB, 500x618
>>54982642
>my lang is good because it's not mainstream
>>
>>54982536
PIC chips are great but I don't know how you intend to program them without knowing C. Going direct to the assembly is going to be much harder.

You're going to need a PICKIT, breadboard, some wire connectors, a set of resistors (10k for general output connections, 270 ohm for LEDs) and much more complicated circuitry if you want to do anything mechanical.
>>
>>54982674
google "How to choose EBML IDs"
>>
>>54982680
>my lang is good because it's the latest tech fad
>do you see how many upvotes my lang has?
>xD using a dead language???

literally the hipsters of programming.

It's people like you who are in it only for a job and have no creativity elsewhere and think you are required to use whatever the industry uses.

Might as well read some COBOL books while you're at it, it's still popular among banks today.
>>
>>54982719
go is shit and you know it
>>
>>54982680
>my lang is good because it's mainstream
>>>/int/dia
>>
Okay real talk.
I need to learn how to eat up and reorganize a file entirely with bash scripts, and I need to do this within the next 7 hours.
Thing is, I know only the basics of bash.
Help?
>>
>>54982719
Why the fuck would you want to learn programming other than to get a well paying job?
>>
What the hell is recursion? i went to see the definition of "Recursion" on the dictionary and they said to check the word "Recursion" again.
>>
>>54982753
to run your own software company

but then you'd still want to use good langs, not garbage like go and rust
>>
>>54982766
Well...
>>
>>54982752
>I need to learn how to eat up and reorganize a file entirely with bash scripts
learn awk, then? I don't think you should reorganize a file with bash...
depends on what you need to do, though
>>
>>54982766
>i went to see the definition of "Recursion" on the dictionary and they said to check the word "Recursion" again.
for real? which dictionary?
>>
>>54982788
>to run your own software company
Uhh and that won't involve programming?
>>
>>54982766
ATTENTION TROLL
>>
>>54982766
Whoever wrote that dictionary didn't know about well-founded relations.
>>54982798
It's for a CS project. Which I should have turned in 4 minutes ago.
Gotta create a script which runs a program I wrote, and accepts some parameters. The script then takes the output files my program creates and reads certain parts of it, putting them in a different order in one or more output files depending of the parameters the script was ran with.
>>
>>54982788
leave rust out of this
>>
>>54982709
I haven't found anything that answers the question about reserved ids. The spec describes the CRC32 and Void elements with ids c3 and ec. Why are those ids so far apart if they are the only one byte ids? Are they reserved? Am I allowed to use those ids for other content?
>>
File: 1456287024874.png (256 KB, 636x708) Image search: [Google]
1456287024874.png
256 KB, 636x708
Question:

Are block scoping (C) and function scoping (JavaScript) types of lexical scoping? Can you say that closures are bound to function scoping or are they defined individually?
>>
>>54982698
I don't believe this board needs the PICKIT module. I can do everything over USB. I have loads of wire, resistors, LEDs, seven segment displays, transistors, etc. and can get more fairly easily. I've got a good working knowledge of analog and digital electronics but just don't know much about programming.

It is worth noting I've used a PIC16F877 before and have some experience programming for it but all the programming was done in BASIC so I don't think it really counts.
>>
File: 1412338876223.png (311 KB, 599x750) Image search: [Google]
1412338876223.png
311 KB, 599x750
>>54982368
>>54982406
>>54982408
butts
>>
>>54981369
stop crying you fucking kid
>>
>>54982368
I use the escape key
>>
trying to figure out some hilariously bad C code written by chinese devs at a company we're working with
>>
>>54982838
>The script then takes the output files my program creates and reads certain parts of it, putting them in a different order in one or more output files depending of the parameters the script was ran with.
you should be more specific. anyway, I'd learn how regex works in bash ( https://www.linuxjournal.com/content/bash-regular-expressions , also check BASH_REMATCH), both with and without grep (), how variables work, etc.

I can't suggest books, I "learned by doing", sorry. you could ask for help in https://webchat.freenode.net/?channels=bash (IRC, #bash @ freenode) and >>>/g/fglt

just wondering, though... do you know *anything* about bash, and shell in general?
>>
>>54983016
post snippets
>>
>>54982368
/------\
| > |
| < | |
\------/
>>
>>54982813
>>54982823
>>54982838
Not the guy that asked about the definition, but a colleague also asked me how would I explain recursion to someone who is pretty removed from mathematics or programming recursion. I couldn't say anything smart, so my friend proposed that one could say that the recursion is just solving a problem by first solving a subset of the problem first.
>>
>>54982205
>Ramanujan
How do I spell it? "P A J E E T", am I right?
>>
>>54983036
i will in a bit, trust me it's worth the wait
>>
>>54983043
Towers of Hanoi is the classic example.
>>
>>54983057
How dare you?
>>
>>54982876
>Are block scoping (C) and function scoping (JavaScript) types of lexical scoping?
Yes

>Can you say that closures are bound to function scoping
In ES5 they are bound to the current scope chain, yes.
>>
>>54982368
ctrl-[
>>
>>54983057
>insulting Ramanujan
kys
>>
File: non-binary logic.png (91 KB, 880x1360) Image search: [Google]
non-binary logic.png
91 KB, 880x1360
>>54983091
>kys
kys
>>
>>54983057
>thinking "Pajeet" generally refers to Indian people
Lurk more
>>
File: 1429946913352.png (151 KB, 766x664) Image search: [Google]
1429946913352.png
151 KB, 766x664
>>54983111
Indeed.
>>
>>54983034
Yes, I'm a C programmer and had to work under linux ever since I began, so I know basic bash stuff.
How to define variable, how to read, how to do loops and pirouettes...
>>
>>54983111
>>54983136
>samefagging
kys

>>54983156
ah, k. that link I posted should be enough to start, IMO. once again, depends on what you need to do, if it's something complex, or a large file or something, you should either use the tools (grep, sed, uniq, etc), awk, or even do your own script/program
>>
6.
for each digit
3-8
(3, 5, 7) 3 odd numbers

0-9
(1, 3, 5, 7, 9) 5 odd numbers

3*5*5*5 = 375

now they can't repeat so you have to divide with some faktoriel I forgot rly
>>
>>54983057
Oh boy
>>
>>54981273
>>54981369
now this is butthurt

keep thinking F# isn't shit and irrelevant lmfao #43 it's even below haskell which is at #39

http://www.tiobe.com/tiobe_index
>>
>>54983182
>being this retarded
>kys
>imo
>being wrong

I'd like the retards to go and /prog/ to come b-- nevermind.
>>
>>54983285
>/prog/
go implement sleepsort in lisp, you tard
>>
>>54983388
already did that faggot
>>
>>54982876
btw, in JS every function is closure, so it's a bit hard to tell. I guess not function but object scoping would be more correctly
>>
>>54981975
Anybody? There has to be some guidelines out there.
>>
>>54983544
http://en.cppreference.com/w/cpp/language/template_parameters
>>
okay i'm new to C and this has probably been asked before

is it correct to say that gcc does Tco, but whhen i compile using cc, it doesn't?
>>
>>54983631
>gcc does Tco
Only when optimisations are enabled.
>>
Had a phone interview with Apple today. Did pretty well and the interviewer was impressed. Anyone here ever onsite with Apple and have some advice for the process?
>>
File: 1460260578969.jpg (7 KB, 232x217) Image search: [Google]
1460260578969.jpg
7 KB, 232x217
>trying to install IRC library in npm
>npm barking that it can't find python
>why would it need python? oh well
>python barking that it can't find some sort of build system called 'gyp'
>a node library that should just be raw javascript requires me to install a python library just to install the node library
Fuck npm, man. Why are people such dumbasses? Is it that hard to write some javascript code that handles IRC connections, and just upload them to npm? Why the fucking python toolchian? Seriously is that necessary?
>>
>>54983556
I know how templates work anon. I'm asking when to use them. How do i know if something needs to be templated.

What is considered good code?

For example, the standard library always adds an Allocator parameter to their container classes, does this mean whenever you write code that uses containers, you need to add the Allocator parameter and pass it to the containers you're using? Or maybe the container itself should be the parameter with the default being std::vector. Or maybe neither should be. How did the people who wrote the standard library decide on these things?
>>
>>54983631
If you need tco, you're writing shitty C code
>>
Speaking of npm and python,>>54983712, anyone read this?
http://incolumitas.com/2016/06/08/typosquatting-package-managers/
it's quite interesting. Anyone has an idea how to actually stop something like this?
>>
>>54983645
It MIGHT do TCO with the correct optimization flags. Don't trust it.

>>54983718
Sometimes people want to use their own allocators rather than just the internal allocator (like, what normally happens when you call `new T(...)`). The STL can't just fuck these people over, so they allow this optional Allocator template parameter so that IF you want to use a custom allocator you can. However if you don't supply anything it uses a default allocator that just routes to the internal allocator. You don't have to know any of this if you want to use STL containers.
If you're writing your own library you certainly could make them compatible with custom allocators although you're going to have to understand how those work if you want to. If you're just writing libraries for yourself then you don't need to do any of that.
Typically you should use templates when you're writing generic code, e.g. a function that sorts a generic list (a list of any type of data), or a tree structure that contains anything. But only use templates when you need the functionality.
>>
>>54983764
Don't use shitty package managers?
>>
>>54983776
>Don't trust it
If you do TCO properly, you can pretty much guarantee it to happen every time.
>>
>>54982507
why don't you terminate that string on line 453?
>>
>>54983776
is '-O0' a correct optimization flag
>>54983738
why, is it much slower?
either way tail calls are very easy to turn in to loops, i was just curious
>>
>>54982052
What exactly is bad about a coc?
>>
>>54983787
but pip is one of the main advantages of python. it's a dream come true if have a lot of referenced libraries in your code and you don't want to worry about repackaging them or keeping them up to date.
>>
>>54983807
No, just pointless and less clear for C programmers.
>>
>>54983764
I don't think package managers should be executing arbitrary code, I feel like packages would only need to execute arbitrary code in very specific circumstances. That's just my opinion though.

>>54983799
How about indirect recursion? How about long argument lists? How about large return values?

>>54983807
-O0 means "no optimizations" so I really doubt it will do TCO.
I'd personally just turn any obvious tail calls into loops just so that it is compatible across compilers and there is no room for funny business. There's the possibility that it's faster too, sometimes, although I can't give you hard evidence right now.
>>
>>54983836
>How about indirect recursion?
I'm not sure how far GCC takes its TCO, but you probably won't get it here.
>How about long argument lists? How about large return values?
Irrelevant.
>>
>>54982052
>this is the only reason you guys don't use an objectively superior language
>>
>>54983836
>I don't think package managers should be executing arbitrary code
that's true. but he was merely running code in the setup script. i don't think you can protect from anything like that. maybe you can..
>>
>>54981975
>I feel like once you get to the point where you know too much about C++, it becomes harmful to your productivity because you start worrying about things like this instead of just writing code.
Then shut up and just write your goddamn code. It's actually pretty good advice, analysis paralysis is a bitch

>>54983965
How about using a setup configuration file instead of a setup script? Isn't that obvious?
>>
File: Untitled095.png (57 KB, 1920x1080) Image search: [Google]
Untitled095.png
57 KB, 1920x1080
Finishing the "Edit/add record" form
>>
>>54983036

/* string compare function */
#define FastStringCompare2(buffer, cstring) \
( *((const int16 *) (buffer)) == *((const int16 *) (cstring)) )

#define FastStringCompare4(buffer, cstring) \
( *((const int32 *) (buffer)) == *((const int32 *) (cstring)) )

#define FastStringCompare6(buffer, cstring) \
( *((const int32 *) (buffer)) == *((const int32 *) (cstring)) && \
*((const int16 *) ((buffer)+4)) == *((const int16 *) ((cstring)+4)) )

#define FastStringCompare8(buffer, cstring) \
( *((const int64 *) (buffer)) == *((const int64 *) (cstring)) )

>>
>>54983712
Node is micropackages.
>>
>>54984070

Well now, this is brilliant.
>>
>>54984070
what's bad about it?
>>
>>54984125
it's completely unecessary bullshit

> calling macros functions
> writing unnecessary bullshit
> not even trusting your own unnecessary bullshit enough to not do crap like this

if ( FastStringCompare6(uri, signup) && *(uri+6) == 'p' ) // "/signup"
>>
>>54984125
it's only comparing the first character of each string
>>
>>54984173
no, it casts to a pointer to larger types and compares multiple at once.

just use strcmp
>>
>>54984070
Pretty sure strcmp() already does something like this internally, but it does it correctly and for variable sized strings.
>>
>>54980970
>Some of these would be fun for a newbie programmer to do in their learning language.
>programming math questions
They're made so that you can think discretely and understand numbers better so that you don't write O(n!) functions
>>
>>54984173
which is reflected in the function name
>>
>>54984193
no
>>
>>54984188
I know, that's why I posted it.
>>
>>54984157
>> not even trusting your own unnecessary bullshit enough to not do crap like this
>if ( FastStringCompare6(uri, signup) && *(uri+6) == 'p' ) // "/signup"
it's necessary in order to compare the first 7 characters
>>
>>54983823
>"this is a written declaration that we will excommunicate you and slander your reputation on twitter if you hold any non-progressive political opinions regardless of whether they have anything to do with the project"

Contributing to a project with a CoC is professional suicide.
>>
>>54984228
Yeah, I noticed that right afterwards. it's still retarded.
>>
>>54984233
>caring about anything written on twitter

thank god I'm not American
>>
>>54984501
It's not just twitter, they will stalk, harass and bombard your employer via social media and email in an attempt to get you fired and permanently unemployable.
No, it doesn't matter if you have mouths to feed, they want you to never work in this industry ever again.

And the best part is that it always works.
>>
File: Capture.png (2 KB, 392x73) Image search: [Google]
Capture.png
2 KB, 392x73
>>54981141
>you don't even realize what those words mean, do you?
>hur dur
I know exactly what those words mean. I want to turn my 4 TB video server's network share into a single "block device with a FAT32 partition." It's going to be something like this once I figure out how to stop it from following symlinks over and over.
>>
>>54984602
nope, you don't have a clue
>>
File: Untitled49385.png (96 KB, 1920x1080) Image search: [Google]
Untitled49385.png
96 KB, 1920x1080
And now for the complete overview
>>
>>54984621
>I don't know why you want to do this, so I think you don't know what you're talking about
ok, brah.
>>
>>54984639
>so I think
you can't seem to be able to even read
>>
>>54984501
>
i can only imagine you've never applied for a job
>>
File: saika.gif (2 MB, 494x640) Image search: [Google]
saika.gif
2 MB, 494x640
Is it possible to autoplay webms at thumbnail size like you can with gifs?
>>
>>54985165
of course
>>
>>54983182
Only one of those is me
>>
I'm just learning C++ and I was wondering if someone could shit on my naive attempt at good practice. Its a solution for a project euler problem: Reading names from "names.text", alphabetizing them, then giving each name a score as the sum of its letter numbers and multiplying that sum by the names position in the sorted array.

#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <vector>

long long letterScore(char c){
switch(c){
case 'A' : return 1;
...
case 'Z' : return 26;
default : std::cout << "NULL"; return 0;
}
}

int main(){

std::fstream file("names.txt");
std::string raw;
std::getline(file,raw);

std::vector<std::string> name_list;
std::string current;
for(auto it = raw.cbegin(); it != raw.cend(); ++it){
if(*it == '\"')continue;
if(*it == ','){
name_list.push_back(current);
current.clear();
continue;
}
current.push_back(*it);
}
name_list.push_back(current); // Because of the formatting of names.txt this is necessary to include the last name

std::sort(name_list.begin(), name_list.end());

long long grand_total = 0;
long long name_score = 0;
int index;

for(auto n_it = name_list.cbegin(); n_it != name_list.cend(); ++n_it){

current = *n_it;
name_score = 0;

for(auto c_it = current.cbegin(); c_it != current.cend(); ++c_it){
name_score += letterScore(*c_it);
}

index = std::distance(name_list.cbegin(),n_it)+1;

name_score *= index;
grand_total += name_score;

std::cout << current << ' ' << name_score << '\n';
}

std::cout << grand_total;

return 0;
}
>>
>>54985604
>case 'A' : return 1;
> ...
> case 'Z' : return 26;
> default : std::cout << "NULL"; return 0;

the alphabet is always in order in C and C++, and chars are integral so you can just do maths on it directly:

return (c - 'A') + 1;
or
better practice would be to start from 0
return c - 'A';


for(auto it = raw.cbegin(); it != raw.cend(); ++it){
in modern C++ you should just use
for (auto x : raw)
x would be *it
or even better, use
for (const auto& x : raw)
in the second loop you use the index so this won't work
>>
File: evolution_004.png (161 KB, 961x917) Image search: [Google]
evolution_004.png
161 KB, 961x917
I am evolving a population of images.
>>
>>54985774
for what purpose
>>
Will the web app meme ever die or are we doomed?
>>
>>54985794
I believe it will bring me some insight on as to why I'm still a virgin
>>
File: evolution_006.png (221 KB, 1697x939) Image search: [Google]
evolution_006.png
221 KB, 1697x939
>>54985794
1) It tries to imitate a certain image with a set of triangles

2) I do it to get a feel of GAs and their parameters.
>>
>>54985794
satisfying my autz
>>
>>54985707
A char is a small object so passing by value is fine, but in general its better to pass by pointer/ref whenever possible right? The only reason I did't do it was because I couldn't find a way to create a pointer to *it (which is a ref to the char?).
>>
>>54985901
b..but I'm not a virgin, anon...
>>
>>54985979
No. A char is 7 bits.
>>
>>54985984
But you do have autism, right?
>>
>>54985999
Nope, my social skills are quite good.

You see,
>If he is a smarty then he should be an autist!
is a big meme, while in reality there exist both smart non-autists, dumb autists and everything in-between.

There is no fairness in this world.
>>
>>54985979
No, small values should be passed by value
Pretty sure C++ allows optimising const references for values that are small enough, but I wouldn't rely on it

It's much slower for your computer to dereference a pointer than to access memory that's already in cache

>>54985987
kek
>>
>>54986025
No, I just assume everyone here has autism.
>>
>>54985987
ASCII values are 7 bits. A char in C is defined by the implementation and can be found with CHAR_BIT
>>
File: evolution_007.png (102 KB, 1641x927) Image search: [Google]
evolution_007.png
102 KB, 1641x927
>tfw evolved another triangle
>>
>>54986044
No ASCII doesn't use bits, it uses nibs. Also fun fact about python, 12 bits equals a bite. THE MORE YOU KNOW!
>>
>>54986056
https://en.wikipedia.org/wiki/ASCII
[Citation Needed]
>>
File: akari a cute.gif (880 KB, 500x281) Image search: [Google]
akari a cute.gif
880 KB, 500x281
I'm writing a script to autoplay gifs and webms.
Press F12 and paste it into your console!
function autoplay_images() 
{
var imgs = document.getElementsByClassName("fileThumb");
for (var i = 0; i < imgs.length; i++)
{
if (imgs[i].href.indexOf(".gif") > -1) /* GIF */
imgs[i].firstChild.src = imgs[i].href;
if (imgs[i].href.indexOf(".webm") > -1) /* WEBM */
{
var thumb = imgs[i].firstChild;
var webm = document.createElement('video');
webm.setAttribute('src', imgs[i].href);
webm.setAttribute('poster', thumb.src);
webm.setAttribute('style', thumb.style.cssText);
webm.setAttribute('autoplay', 'true');
webm.setAttribute('loop', 'true');
webm.setAttribute('preload', 'auto');
imgs[i].replaceChild(webm, thumb);
}
}
}
autoplay_images();


The only problem is that it disables the play on click default behavior and I'd like to get it back.
How do I do that?
>>
>>54986089
That was some super low quality bait you just responded too
>>
Why the fuck don't any of the Rust developers care more about higher-kinded polymorphism?
>>
>>54986128
They're idiots who only think in terms of what's popular
>>
>>54982144
Except its error handing style is straight out of the 70's, it has a terrible type system, and it's designed with the assumption that developers are too stupid to learn any modern linguistic features.
>>
File: yuuko_jump.webm (433 KB, 960x540) Image search: [Google]
yuuko_jump.webm
433 KB, 960x540
>>54986090
since there is no webms in the thread
>>
>>54985707
>the alphabet is always in order in C
false; why would you make such definitive statements if you don't know what you're talking about?
>>
thank you for reading this sentence. Your contribution to the visual AI experiment is appreciated.
>>
>>54986188
>what is simplicity
>>
File: not portable pt 2.png (206 KB, 686x780) Image search: [Google]
not portable pt 2.png
206 KB, 686x780
>>54986281
not sure if it's pic related or the page after
>>
>>54986296
C is simple.
>>
>>54986296
>what is easiness
simplicity != easiness

Go is designed to be **easy**, but this comes at the expense of a program's simplicity when code is being repeated with minute changes, and tasks that would be easy to accomplish in other languages require significantly more work in Go.
Thread replies: 255
Thread images: 35

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.