/dpt/ - Daily Programming Thread

old thread: What are you working on, Sup Forums?

Other urls found in this thread:

stackoverflow.com/questions/14306048/controling-volume-mixer
informatimago.com/linux/emacs-on-user-mode-linux.html
en.cppreference.com/w/cpp/language/if#If_Statements_with_Initializer
twitter.com/SFWRedditGifs

...

Rust lives!

>literally spent half an hour discussing what "rounding up to the nearest 10th" means
sausage Sup Forums

Reminder that Sup Forums can't return the closest multiple of 10 without using a string yet.

I'm trying to learn Hadoop and a bunch of related stuff (pig, spark). Any suggestions? What are some based books?

big data is a meme, use sql instead

Fuck you and your negatives and fp numbers, my answer worked perfectly.

int round10(int x) {
if (x >= 0) x = 10;
else x = 0;
return x;
}

was it really that hard?

If I want to choose different applications in windows and set their volume, how do I need to go about this? I thought about using c# but I never really used it (only python and what I was forced tgo learn for javaScript in university). The only thing I found was this:
stackoverflow.com/questions/14306048/controling-volume-mixer
which not only I do totally not understand, but also doesnt seem to work. (it sets the program's volume to 50, mutes it but the sound stays at 100% unmuted.)

I thought to start I should understand the Windows Core Audio Library used in the stackoverflow answer. The documentation sucks though. Where do I find some sort of reasonable documentation? Do you guys have a better idea how to go about this? Is C# even a good choice for that?

Deciding between making a reddit app or a C++ minecraft clone.

curl www.reddit.com
done

as in an android app with a specific feature I've wanted for a while.

what feature?

is it feasible to scrawl the entire posting history of a board on Sup Forums. I want to do it on a site like warosu just to test the script. I want later sort these posts to threads and sort them into replies count.

ok but why

That would be too hard for a retarded frogposter.

there's no central site that has the entire posting history of Sup Forums, but you can pretty easily scrape the current state of Sup Forums and store it for a while. Its pretty easy if you use the json api (hint: add .json to the end of urls).

I did this for a while and built a markov comment generator, which produced gems like "What the fuck did you say about me, you stupid frog poster?"

le gem

This angers the mongoloid:

int round(int x) {
return (x / 10 + !!(x % 10 && x > 0)) * 10;
}


Reminder that the original did specify rounding up, and did not specify that the numbers should be floats.

why does my android emulator freeze sometimes when i reload an app

Soon I will have no reason to ever leave Emacs.

informatimago.com/linux/emacs-on-user-mode-linux.html

This.

Still the same thing: a stack-based VM for embeddable scripting languages. It can be programmed directly in a (somewhat) Forth-like language, but it provides a C JIT compilation API to be used by user ESLs. The core idea is to enable easy interop between multiple domain-specific scripting languages within the same host application through the shared argument stack. It provides native support for an object system that is lightweight but highly customizable and extensible (through the use of meta-objects), so objects can be directly shared between different ESLs with potentially different object systems.

Here's the definition of some basic constructs within the stack language itself:
defun # >> compile-call end
>>
# get setmac

defun peek >> dup >
defmacro get setmac

defmacro ' >> compile-literal end

defmacro !call call end

defmacro ! >> get # !call end

defmacro !>> >> end

defmacro ## >> compile-literal ' compile compile-call end

defmacro if
## not
# ?jump
end

defmacro endif
# resolve:
end

defmacro else
# jump
swap
# resolve:
end

defmacro while
# label:
end

defmacro do
## not # ?jump
end

defmacro repeat
swap
# jump # to-label
# resolve:
end

defmacro /*
while
>> ' */ = not
do repeat
end

/* now we can add C-style comments! */

defmacro {
## {}
## dup
>> compile-literal >> drop
## swap
end

defmacro ;
## swap
## setf
## dup
>> compile-literal >> drop
## swap
end

defmacro }
## swap
## setf
end

Employed C++ programmer here

hello /dpt/

I want to learn C and start a prijec, but I am to dumb to figure out how all of this make shit works.

can you help me?

with love
user

Employed Java programmer here

Got a new dev board, so I can finally port my Cortex M0 code to an M4F. I have to set up the toolchain first, and I'm still thinking about a nice way to replace libgcc with my own code. Macros aren't that sexy, inline functions are kinda ugly

how about you read a book called "the c programming language"

Neither of your solutions work on floats. The problem just said number, it didn't specify integer so it's only reasonable to assume it must work for floats too.
int roundUp(float fnum)
{
if(float d = fnum%10; d < 1 && d > 0)++fnum;
int num = fnum;
while (num % 10) ++num;
return num;
}


There's a proper solution.

Stop wasting your time on this board and start reading then

What part of the C89 standard lets me pull off magic like this?
I found out you can cast an initializer list as a anonymous struct pointer literal instead of creating one separately.

nanosleep((struct timespec[]) {{ 0, (wait - delta) * 1000 }}, NULL);

Do the latter. Multiplayer-only should be enough. No one wants to play singleplayer and those shitty realms. The community badly wants a slim client that also runs on other platforms than win10.

That's not a cast, it's something weird.

Is it possible to code a program to run in ring 0/kernel in c++? Or would I have to do it in/learn windows driver?

>Neither of your solutions work on floats
It's impossible to tell at this point if you're an enormous retard, or a retard pretending to be more retarded than he really is. The solution for a float is more trivial than the one for an int, and it doesn't look like your clusterfuck (which isn't even valid C):
float round(float x) {
return ceil(x / 10) * 10;
}

Working on babbies first """kernel""" on a RPI1 B
Interrupts are pretty much working now and I think I am going to work on turning on the MMU next
Unfortunately, I feel like I keep getting mentally stuck on some portions and I would like to figure this
out without going to look at MINIX or Linux source code for examples even if my implementations aren't as good.

>I'll get there someday...

>which isn't even valid C

It's C++.

In the time it would take me to remember what header ceil is in, I probably would have failed to finish in 30 seconds.

As I said, it's impossible to deduce your true level of retardation; just that it's pretty high in any case.

Monte Carlo simulations for forecasting costs.

>hurr durr my solution doesn't work but anyone who corrects my is the retard

Nice work, user

I tried to do this, but ARM was 2weird4me
How do you load it?

I have a python script and i want to print the output on a website, wordpress for example, how would i go about doing this?

>t. butthurt lying retard

Go back to shitting the streets, Rajeet.

I don't get it, why is java still commonly used if C and it's derivatives out perform it?

Lying? It's literally what would have happened. Call me a retard if you want but at least my solution worked.

Not that user, but the ARM on the RPi1 is a bit weird. The kernel is loaded from the SD card by a bootloader in the proprietary Broadcom parts. So it's basically compiling a binary file, loading it onto the SD card and booting the Pi.
The Cortex-M series are more like an Arduino, you have programmers that can load binaries into the on-chip flash.

marketing and 20 years of pressuring colleges to teach it
colleges are basically split between the oracle and microsoft due to their meddling in the 1990s

Remember, folks: if you insistently pretend to be this retarded, you most likely are retarded.

it's easier

this is a c99 compound literal
not legal c89

thanks

I have a small utility that setups up the GPIO pins on the rpi for JTAG and then load in directly into memory for now
but the linker script is setup correctly to allow me to just compile it and drop it on the SD card and it will boot.

On ARM being weird I felt that once I learned enough of how ARM worked it made much more sense then all the legacy baggage
that comes with x86

heres the jtag setup on the rpi1, for the rpi2/3 you just need to change the peripheral base address

.syntax unified

.globl _start

.equ GPFSEL0, 0x20200000
.equ GPFSEL2, 0x20200008
.equ GPPUD, 0x20200094
.equ GPPUDCLK0, 0x20200098

.section .data

.section .rodata

.section .text
_start:
mov sp, #0x8000

// disable all pull ups/downs
ldr r0, =GPPUD
mov r1, #0
str r1, [r0]
bl _delay
ldr r0, =GPPUDCLK0
ldr r1, =0x0B400010
str r1, [r0]
bl _delay
eor r1, r1
str r1, [r0]


// define alt5 function on gpio4 (JTAG TDI)
ldr r0, =GPFSEL0
ldr r1, [r0]
bic r1, r1, #0x7000
orr r1, r1, #0x2000
str r1, [r0]

// define alt4 functions for gpio pins 22, 24, 25, 27
ldr r0, =GPFSEL2
ldr r1, [r0]
ldr r2, =0x00E3F1C0
bic r1, r1, r2
ldr r2, =0x0061B0C0
orr r1, r1, r2
str r1, [r0]
b _wait

_wait:
b _wait

_delay:
mov r2, #300
1:
subs r2, #1
nopne
bne 1b
bx lr

garbage collection
platform independent
better standard libraries

>garbage collection
And by that you mean it collects all the garbage programmers.

I've never done GUI development, but I need to make a really simple 2bit image editor to make graphics for an embedded project with a strict format requirement. I was thinking of just making a tool for converting indexed images, but for various reasons I think a standalone editor would have a lot of advantages.

Any recommendations for a simple GUI framework that could be used to quickly build a barebones drawing application?

>a simple GUI framework that could be used to quickly build a barebones drawing application
HTML5. I'm not even joking. You don't have to install anything and even braindead webdevlets can do it.

why you guys still use obsolete languages instead of converting to python?

That's actually not a bad idea. I think I'll look into it.

Is that all you can do, call anyone who offers you criticism retarded?

I don't think you understood the original problem. You have a time limit and no compiler to help you and it's obviously asking for an actual implementation and not just pseudocode. If you're going to include functions with no implementation you're solution might as well be:
output round_up_to_nearest_ten(input);


So if I were to use ceil I'd have to waste time thinking of what header it's in, and most likely been wrong and assumed math instead of cmath, which I just had to look up to check. Or I'd have had to implement a ceiling function myself. Which thinking about now is trivial to do but it's something I've never done and would have taken more time than just doing the first thing that came to my head.

It's not a perfect solution, it's a 30 second whiteboard solution. But at least it works which is more than I can say for yours.

Kid, you are literally retarded. No amount of "I was merely pretending" is going to help you.

this is called the "smartass" answer and I'd give you another question if you did this to me

please recommend minimalist text editor with nice dark theme and lots of different built in language support

ides are powerful big boys and all but sometimes a nigga just want to bool without having to sit through twelve loading screens

I'm not pretending. If I'm doing something wrong, please explain to me what. Unlike you I can take and learn from criticism.

sublime?

Pig is dead, with spark you just need to know some java, scala or python to make the API calls.

I trust those dubs. ty user

But you are literally and unironically retarded. I know this because you literally come here every day to "pretend" to be one, but one has to be a genuine moron to be perpetually entertained by people calling him a retard. Yesterday you were telling cool stories about how you can traverse a BST by incrementing a pointer. Today it's this. I can't wait for tomorrow.

choosing a correct language is not a skill c or c++ programmers have yet developed

...

You have me mistaken with a different user. But I'll humor you, please explain to this retard what was wrong with my solution. I genuinely want to learn more and if you have real advice or criticism I'll take it. If your response is just "lol retard" then I'll assume you're just projecting because you feel bad that your solution didn't work.

There aren't really any programming languages besides c or c++ that are usable on really low level devices sadly.

VSCode

>choosing a correct language
There's only one thing that Java is the "correct language" for: corporate code-monkeyism, where it serves the purpose of dragging the programmers down to a lowest common denominator easily-replaceable, easily-outsourceable level.

>real advice or criticism
Try writing code that compiles. Either way, I know you are that retard from yesterday. Keep "pretending", user.

It does compile. I assume you're not a C++ programmer, so it understandable to not be familiar with modern C++, but there's nothing invalid about the code.

There is no reason to use Python over Java, for any reason.

>modern C++
>if(float d = fnum%10; d < 1 && d > 0)

Is there a hash function that runs most efficiently on a CPU instead of a GPU/FPGA/ASIC?

Maybe if it used absurd amounts of branching.

>what header ceil is in
Unless working on complex numbers, all math operations in ISO C are generally in math.h

I am trying to create a process structure, in C, using fork() to make a tree and using parameters to determine the number of branches of each child process.

For example input 3 2 1 1, would output a tree like pic related.

I tried something like this:
int main (int argc, char *argv[]){
for(i=1;i

Yes, and?

en.cppreference.com/w/cpp/language/if#If_Statements_with_Initializer

main = putStrLn "Haskell is fun!!!!"

>the absolute state of sepples
Even if it compiles, it's still absolute shit. I already showed you what an acceptable solution looks like. It doesn't take any loops. Why are you so obsessed with convincing me that you're a monumental retard?

Your solution here is obviously much better, but like I said, I don't think it's in the spirit of the problem to use functions with no experimentation. I'll explain my thought process.

My mind first went to integers, as yours obviously did too, and I came up with the same solution as another user.

int roundUp(int num)
{
while (num % 10) ++num;
return num;
}

Then I realized it didn't specify integers and my solution wouldn't work with floats if the floats integer value was a multiple of 10. So I implemented the first solution that came to my head, which seemed reasonable given the time limit.

It's obvious you had a similar process yourself. Thinking in terms of integers and coming up with an unnecessarily complex, and incorrect, solution seen . That's obvious because is much simpler and works perfectly for integers through implicit conversion.

How can I know how long a child process execuated?

>using basic standard library functions is haram
float round(float x) {
x /= 10;
int xi = (int)x;
return (xi + !!(x - xi && xi > 0)) * 10;
}

Basically the same as the int code. It just implements ceil.

>unnecessarily complex, and incorrect
So you're not pretending. You are literally retarded, huh? Come back when you find an input for which it's "incorrect" or when you have a less "complex" solution.

You can measure it internally. Unless you're blocking on that process finishing that's the simplest way.

So will I need a thread in the child to keep track of that?

Does this work in if else statements/conditions/whatever we call these now that they're different?

It's not valid C and it's not valid C++11. I stopped giving a fuck about C++ after C++11, so it might be some brilliant new sepples@ feature.

Is there some resource that completely explains how linking works? I don't understand, among other things, how the assembler/linker know what addresses to generate for intermodular calls if shared aren't aren't always loaded at the same position in memory.

Well normally for a process you have a well defined start and end. If you don't you could (in a language with RAII/consteuction/destruction features usually, I'll be writing as if you're doing C++) create a global static object and have the constructor take the start time and the destructor take the end time and then send the difference between the two to the main process in some manner of your preference.
It doesn't capture everything. But it should capture most of the stuff you care about.

>shared
*shared objects

>So you're not pretending. You are literally retarded, huh? Come back when you find an input for which it's "incorrect" or when you have a less "complex" solution.

Any float value that, when implicitly converted to an int, loses significant digits and is a multiple of 10.

Example:
int round(int x) {
return (x / 10 + !!(x % 10 && x > 0)) * 10;
}
int main{
round(10.7);
round(-30.6);

return 0;
}

The more simple solution is what you wrote here:

That will work perfectly for ints and floats and is much simpler.

It doesn't fix that, it's not possible. It pretends to fix that and then any modern OS re-does the work at startup. The useful work linkers do is static linking. I don't actually know what the name for this process is though. Dynamic loading is too general. Startup dynamic loading perhaps?

Rust