/dpt/ — Daily Programming Thread

Previous: What are you working on, Jow Forums?

Attached: vlcsnap-2018-04-08-21h39m18s487.png (1512x1072, 1.04M)

Other urls found in this thread:

network-theory.co.uk/docs/gccintro/gccintro_34.html
pawelurbanek.com/profitable-slack-bot-rails
r-a-d.io/
listen.moe/
github.com/n4n0GH/chan-scraper
youtube.com/watch?v=f5ddAAYasgM
youtube.com/watch?v=0RszchMVvbs
youtube.com/watch?v=CVFscjOsPRA
twitter.com/NSFWRedditGif

first for c++ was a mistake
std::vector CombineData(const std::vector& datas)
{
std::vector combinedData;
const size_t datasSize = datas.size();

if (datasSize > 0)
{
std::vector sizes(datasSize);
const auto datasCbegin = datas.cbegin();
const auto datasCend = datas.cend();
std::transform(datasCbegin, datasCend, sizes.begin(), [](const auto& v) { return v.size(); });
const size_t minSize = *std::min_element(sizes.cbegin(), sizes.cend());

for (size_t idx = 0; idx < minSize; ++idx)
{
// ensure the data has matching x-coords
const double expected = datas[0][idx].first;
if (!std::all_of(datasCbegin, datasCend, [=](const auto& v) { return v[idx].first == expected; }))
{
break;
}

// get the yvals
std::vector yvals(datasSize);
std::transform(datasCbegin, datasCend, yvals.begin(), [=](const auto& v) { return v[idx].second; });

// combine the data
const double sum = std::accumulate(yvals.cbegin(), yvals.cend(), 0.0);
combinedData.push_back({expected, sum});
}
}

return combinedData;
}

also I'm trying to learn how fft werks

Attached: sepples_programmer.jpg (4032x3024, 1.84M)

using dataset = std::vector< std::pair< double, double > >;

dataset CombineData( const std::vector< dataset >& datas )
{
dataset combinedData;
auto datasSize = datas.size();

if( datasSize > 0 )
{
std::vector< size_t > sizes;
sizes.reserve( datasSize );

for( auto& v : datas )
sizes.emplace_back( v.size() )

auto minSize = *std::min_element( sizes.cbegin(), sizes.cend() );

for( size_t i = 0; i < minSize; ++i )
{
double sum = 0.0f;
for( auto& v : datas )
if( v.first != expected )
goto next;
else
sum += v.second;

combinedData.emplace_back( expected, sum );

next:
}
}

return combinedData;
}

yes I completely forgot about `i` but you get my point

Daily reminder that tons of smart and dumb people want to make "better C language" and till this day, none of them succeed doing it

>none of them succeed doing it
That's subjective, unless you assume that better C should be at least as popular as C.

brackets were a mistake, Haskell's type syntax is the way to go.

c is a downgraded bcpl which is already a downgraded cpl. never forget that.

Attached: umaru is one of us.jpg (1024x575, 54K)

Question about C makefiles: How do I define something in the makefile?
I'm trying to get what's in this block of code in the C file (which I hope I've written correctly) to run:
#if defined FORK_IMPL
...
#endif

network-theory.co.uk/docs/gccintro/gccintro_34.html

Hmm, that's exactly what I'm doing, yet it's still not working and giving the error indicating an unsuccessful definition.
Got any clue what's wrong with this?
My testing shows that it is treating the if statements as if statements, as an error put in one of the if blocks will not occur.

C file:
#ifdef FORK_IMPL
...
#elifdef FORK_EXEC_IMPL
...
#else
#error ...
#endif

Makefile:

fgame:
#define FORK_IMPL = 1
gcc -o fgame game.c

egame:
#define FORK_EXECT_IMPL = 1
gcc -o game game.c
gcc -o guess guess.c
gcc -o ttt ttt.c

clean:
-rm -f *.o
-rm -f fgame game guess ttt

Whoops I put the entire thing in one set of code tags, that was meant to be two.
Oh well.

Being new to programming
>work ask for me to look into changing an output report from Openstudio and changing the values from IP to SI.
> after a some time get it to work.
> now need to replace the output separations.
from > 100,000.00
to >100.000,00

can some one help me?
it's in ruby.

have you read the article at all?

gcc -DFORK_IMPL -o fgame game.c
or
gcc -DFORK_EXECT_IMPL -o game game.c

you mean idris taking away the colon bloat

It's an assignment and I was meant to do it by defining macros.

The -D flag defines macros, user.

Planning out autistic weeb shit for an IRC bot because flavortext and personality in commands makes them more fun to use when they otherwise do trivial things. Thinking of what to do for steps 11-13 of The Wired puzzle.

If you had a bot dedicated to sharing images of zettai ryouiki what else would you have it do?

Attached: 5b8f4ca76387f57a4405b0062e30d812d99c41b551871a011f745a47104daeb5.jpg (850x850, 69K)

That's a weird way of doing things, and adds a lot of bloat to my code.
Any idea why #define isn't working in the makefile?

the makefile is not part of the code. defining stuff in the makefile only define them for the makefile context.

You use #define in the .c or .h file, and you use -D when you invoke gcc from the command line.

>IRC bot
kek. everyone has moved to discord and slack.

>lel everyone muvved botnet
speak for self

pawelurbanek.com/profitable-slack-bot-rails

don't isolate yourself, move with the time.

I've been thinking of trying the programming socks meme, but I'm not a trap or in any way feminine

would this still improve my programming ability?

Read cocumentation

Actually programming socks is not only meme. It also warms up your feet, so you could have better focus when programming

No

That actually makes sense

I think I'm going to give this a try, once I can source some nice socks

"Better C" is a contradiction.

Because C is already perfect?

I think the word is 'oxymoron', nyeh.

the tremendous enhancement of one's coding flow by listening to r-a-d.io/ or listen.moe/ has been proven by numerous studies.

No, I meant contradiction.

How so?

>get new job
>everything is written in Java
>call everyone brain-dead Pajeet street shitter
>start to rewrite in C
>fizz buzz proof of concept done in only 5 days
>fired for not doing my job
???

Attached: 1482236145668.png (500x500, 307K)

I made a scraper in python that downloads pic related from any thread from any chan.
I want to include these things next:

* custom download directory
* check for text-links on URL and paste them into txt-file
* circumvent bot detection on websites like ylilauta
* periodic downloads
* specify additional filetypes through sysargs

More ideas are welcome.
github.com/n4n0GH/chan-scraper

Attached: Screenshot_20180525_094952.png (435x229, 13K)

Saying "Better C" is like saying "Better shit".

That's not a contramydicktion.

You're a cum tran dick shin

If they hired you to do Java then your job was to do Java. Not C. You can fuck off and do your hobby C projects on your own time.

I mean yeah, I agree with you in hating on Java, but you sound like an insufferable coworker.

Attached: autism.webm (1920x1080, 1.6M)

just use d bro

chron job into vim that runs a vim script with %s/,/./g

Cute Sauce

I will check it out and give them a listen for a while

Regarding the fabs question from last thread, is it not possible to just zap the sign bit of a floating point number from its address?

>listen.moe/
This gave me autism.

Attached: autism-dance.gif (342x342, 501K)

just use rust bro

Can you show how it would look like in Rust?

which is good for programming.

Attached: 78947.jpg (1200x963, 254K)

So I'm setting up a home server for development and code purposes. But I'm getting annoyed by gitlab being so heavy.

What do you guys use? Can I use a number of tools to build up the same functionality?

Makefiles are not C user, they are a language-agnostic build tool. It just so happens that # starts a comment in a Makefile.

nah
youtube.com/watch?v=f5ddAAYasgM
youtube.com/watch?v=0RszchMVvbs
youtube.com/watch?v=CVFscjOsPRA

It is, that's precisely what the code in some posts was doing.

Good job user

Attached: 33312896_1141543159343841_5194330402650587136_n.jpg (500x500, 75K)

I really hate the new EC2 spot pricing model. Under the new model the price shown is fake and not really a reflection of supply and demand anymore. You can have your bidding price ceiling set to 10 times the on demand price and still have your instance terminated.

Dammit Jim, I'm a programmer, not a biologist!

Attached: Capture.png (629x91, 22K)

But they were using bitmasks to hide the sign bit.
Is there no way to do = 0?
Or, say = 0 to make the exponent negative.
But I guess it isn't possible.

Wait, nevermind, it probably wont work because pointers aren't single bit sized.

You can't address single bits, the smallest addressable amount of data is a byte.

Was making python 3 less ease of use an intended design decision or what

depends on the system

What do you mean?

WRONG

Anime

python 3's biggest mistake was not trying to be more different than 2
instead of trying out different ways of fixing any of 2's problems (subjective I know) they went for a semblance of backwards-comparability without actually being backwards-compatible

Python is finished and bankrupt!

Attached: 1526856306260.png (368x394, 293K)

underrated

Attached: 1520240553274.gif (408x397, 59K)

void* buffer;

buffer_alloc(&buffer);

int buffer_alloc(void* buffer) {
void* temp;

temp = malloc(128);

buffer = temp;

return 0;
}

Why doesn't this work? The address of buf in the original function doesn't change. I'm trying to make my buffer alloc function return an int for future error checking instead of void*.

C is pass-by-value
you've passing the pointer by value
the pointer outside the function doesn't change
you need void**

void buffer_alloc(void **buf)
{
*buf = malloc(128);

return 0;
}

Thanks

Also, you should check the error code.
void buffer_alloc(void** buf)
{
void* temp;

temp = malloc(128);
if (temp == NULL) {
fprintf(stderr, "Something went wrong: %s\n", strerror(errno));
return errno;
}

*buffer = temp;
return 0;
}

Benis

Howso?

Attached: 6d3f8eb57e83c3cd609b37cfe106476c.gif (250x250, 222K)

Yeah will do thanks.

>errno
why is C so terrible?

>void
>return errno
fucking retard

simpler language from a simpler time

Why not pass comparison lambda to min_element instead of constructing a sizes vector?

>side effects
you disgust me user

when you pass a pointer-to-non-const, especially when that function returns void, you know exactly what you're getting into

what anime should i watch to increase my programming skill?

redpill me on libuv /dpt/. is it that much better than rolling your own with select()? I hear select() is trash, but the better options aren't portable.

I would like to have simple question about haskell

Let's say I have this piece of code:
main = do
putStr "Number: "
c

I'm making last.fm API bindings for Kotlin

Attached: PleasedFakeHypsilophodon-max-1mb.gif (240x205, 42K)

no

putStrLn

No he means the opposite.

One way would be to disable "echo" in the terminal, but in Hasklel I dunno.

Maybe I did mistake and here i wrote putStr but in code I have putStrLn, I need to check, jeez I'm such a brainlet.

Pointfree:
getChar >>= (putStrLn . ("Number: " ++) . return)

non-point-free:
getChar >>= (\char -> putStrLn ("Number: " ++ [char]))

Finishing up on "Starting Out With Python, 2nd Edition". I skipped some of the exercises but fucking with logic errors when no one else is around is hard.

The question is, then, what's next? I have a book on Scheme and a 1200 page long text on C++ also sitting on my hard drive. I could also download another book on Python and work on that.

I'm assuming I'm still too much of a codinglet to look at actual projects, though. What do?

Attached: ripme1.jpg (516x491, 43K)

Thank you very much I will try it.

never understood the point of ""point free style."" whats so bad about lambda?

Read K&R.

You should always use the power of function composition and partially applied functions. Lambdas are unnecessary

I've been using Python Requests to make automated http requests for a few months now, but I'm concerned about memory leakage and performance.


Is Wget better?

forgot to add that this is only the case when it's possible to use pointfree style (which is not always the case)

how to stop hating mainstream languages?

Attached: 1493193464821.jpg (500x375, 60K)

ignore him

That's ideology, not an argument. Of course lambdas are unnecessary. I write all my code in the point free SK combination calculus.