/dpt/ - Daily Programming Thread

Daily Programming Thread

What are you working on, anonymous ?

# New & Revised /dpt/ Code of Conduct #
We want to ensure that the /dpt/ community, while large and diverse, remains
welcoming and respectful to all participants. To that end, we have a few
ground rules that we ask people to adhere to.

- *Be friendly and patient.*

- *Be welcoming.* We strive to be a community that welcomes and supports
people of all backgrounds and identities. This includes, but is not limited
to members of any race, ethnicity, culture, national origin, colour,
immigration status, social and economic class, educational level, sex,
sexual orientation, gender identity and expression, age, size, family
status, political belief, religion, and mental and physical ability.

- *Be respectful.* Not all of us will agree all the time, but disagreement
is no excuse for poor behavior and poor manners. We might all experience
some frustration now and then, but we cannot allow that frustration to turn
into a personal attack. It’s important to remember that a community where
people feel uncomfortable or threatened is not a productive one. Members of
the /dpt/ community should be respectful when dealing with other members as
well as with people outside the /dpt/ community.

- *When we disagree, try to understand why.* Disagreements, both social and
technical, happen all the time and /dpt/ is no exception. It is important
that we resolve disagreements and differing views constructively. Remember
that we’re different. The strength of /dpt/ comes from its varied community,
people from a wide range of backgrounds. Different people have different
perspectives on issues. Being unable to understand why someone holds a
viewpoint doesn’t mean that they’re wrong. Don’t forget that it is human to
err and blaming each other doesn’t get us anywhere. Instead, focus on
helping to resolve issues and learning from mistakes.

Other urls found in this thread:

en.wikipedia.org/wiki/?:
software.intel.com/en-us/articles/api-without-secrets-introduction-to-vulkan-preface
youtube.com/watch?v=VipvF26XRNY
pastebin.com/X7KnSphx
cplusplus.com/reference/ctime/localtime/
cplusplus.com/reference/chrono/
youtube-mp3.org/
rg3.github.io/youtube-dl/
youtube.com/watch?v=N4mEzFDjqtA
gotw.ca/gotw/042.htm
twitter.com/NSFWRedditImage

fuck off faggots

...

is the construct (condition)?this:else from c or c++?

fucking idiot, i know you're being sarcastic, but you're causing real SJW fags to come here who don't realize that you're joking

en.wikipedia.org/wiki/?:

thanks

>Being unable to understand why someone holds a viewpoint doesn’t mean that they’re wrong.
if they're wrong, it means they're wrong. being a delusional arrogant smug faggot doesn't help your case.

Report and do not post in this thread.

I hope the OP is an ironing

first for we should nuke pajeets from programming jobs.

Why do people hate javascript so much?

only C and Java is taught in indian computer schools

you have to be at least 18 years old to use this site

because python is superior in every way

it's fucking shit, even python is better

does she like programming in C?

it's a trap

not possible

you have to be white to post in this thread

even better, post more

Kalindra chan is a trap you new fag gay boi.

xD

/dpt/-chan, daisuki~

Ask your much beloved programming literate anything.

;; space counter in r10
;; upper counter in r11
;; lower counter in r12

XOR r10, r10
XOR r11, r11
XOR r12, r12
MOV rdx, strAddress
.loop:
MOVZX eax, byte [rdx]
INC rdx
TEST rax, rax
JZ .nullChar
CMP rax, 32
JNE .upperAndLower
INC r10
JMP .loop
.upperAndLower:
AND rax, 32
SETNZ r13
SETZ r14
ADD r12, r13
ADD r11, r14
JMP .loop
.nullChar:
...


looks like lazy copy/pastes

C has them since the beginning but conditional expressions existed way before.

At the beginning, javascript was a glue language for web designers, its semantics and syntax were crappy but decent enough for quickly scripting a web browser. Since then, it has been imposed everywhere and it's now being used for everything. WebAssembly could free us from javascript.

>programming literate
doesnt seem like it

quit posting anime on /gee/ u faglord

why?

unironically

>programming literate

>looks like lazy copy/pastes

ha nice one

anyone know anything about optimizing GLSL code? especially for mobile devices which don't have good run-time compilers

if you're using s=sign(x), should you use abs(x) or is it better to do x*s

since the implementation might not have good abs i'm guessing x*s is better?

>looks like lazy copy/pastes
it's obviously for scope and readability

Just doing some things left over from the previous week with work. (Pays well so im not bothered).
A little bit of coding in cellnode (a company invested language) to tie up environmental variable integration with the recent updates of the operating systems of our micro controllers at our plant. (Spill overflow). I work at a hydro electric powerstation in New Zealand.

>software.intel.com/en-us/articles/api-without-secrets-introduction-to-vulkan-preface
>TL;DR
i want to make a mobile game that targets the latest high-end devices with new features like geometry shaders and transform feedback. should i use modern opengl or should i go full vulkan?

I don't really know about the performance characteristics of floating point operations in GPUs, buts abs() should be a REALLY cheap function.
It can be implemented by clearing a single bit.

yeah good point i didn't think of that, it should be really cheap just like sign

You should use opengl ES because vulkan is not for people making games vulkan is for people making graphics APIs.

yeah vulkan looks really complex i just saw an intel ad on stackoverflow which made me curious about it

Trying to learn Isabelle/HOL and ISAR and proof methods

I'm thinking about creating a program similar to a standard php cms but without the dynamic bullshit. What I have in mind is a static page, that upon creating a post, gets read by the program appends the necessary html and that's it. I haven't started to implement it yet physically but I kinda have the system in place in my head. What so you think?

How do I write a function in python that returns the different ways I can calculate the number N using sums of differenet increasing sequence of numbers?
FOr example calling function(5) would return number 3, because I can write 5 as 1+4, 2+3 or 5

Where to start if I want to get into python?
I did some code modification in blender engine but the actual knowledge with the language is 0.
I know the general programming logics and stuff.

Would anybody here be able to write me a script in python or point me in the right direction, I want it to be keyed rot but with two keys one for if the word is odd and one for if it's even

Along with Python, should C be learnt as that was what Python was made in? Also is codeblocks acceptable to use as a beginner?

By that logic, you should also learn assembly.

would be nice

>not learning assembly as first language

If you want to go the hard route learn C. After C pretty much every language you will be able to pick up quickly.
If you want to go the easy route, learn Python first. But be warned going from Python to other languages isn't as simple as it would be if you took the time to learn C first.

how long is the sequence? Does it increase at a constant rate?

How do I into concurrent programming in C++?

What are some good books?

What are some exercise problems (preferably coding up a concurrent solution to a problem) I could do?

>tfw want to learn assembly so i can reverse engineer/decompile programs to create patches/exploits, but theres too many other things i want to do

one day..

youtube.com/watch?v=VipvF26XRNY
27:00

FUCK YEAH

even on flat screens, with a wide fov i think the standard rectilinear projection looks fucking disgusting, so it's great that this issue is starting to get recognized and we're even getting hardware support for alternate projections

...

...

>CLIonly linuxbabbies
kys

I want to return a struct of the form
let a = A::new();

X {
the_a: a,
other_stuff: a.do_it()
}

But whether I wrap the A, the A and the X, or just the X in an RC or in a Box, or even if I add a lifetime (trying to coerce the A to live as long as the X, not the other way around), I always get an error of the form
...but borrowed value is only valid for the block suffix following statement 0


How do I fix this?

Yesterday I posted my idea of writing a download manager. After giving it some thought, I want to create a web based remote file manager instead. That's much more flexible for my purposes.
So now my idea is to basically write a glorified file manager found in Chromium and Firefox. I looked at ownCloud, but that's overkill for my purposes. The extra features I want to implement are:
- Removing files
- Uploading files
- Download files by url
Eventually I want to add:
- Moving files
- Compress/extract files
All as a website without the need to use JavaScript (+1 in the freedom dimension) written in Go licensed under the AGPLv3.
Does /dpt/ know of any other useful features?

no. and even that, python has been implemented in python (pypy), java (jython), c# (iron python), javascript (skulpt, pyjs), c++ (pyston, nuitka, pyjion), ruby (typhon), ...

I'm very inexperienced at programming but I was following the programming challenges thing and made an ascii clock.
pastebin.com/X7KnSphx

I couldn't get the time function to work properly (it was only displaying 01:3:8 as, for some odd reason, it consistently gave time back as 1 hour, 4199813 minutes and 2686868 seconds even though I practically copy-pasted the code from a working example) so the clock is plagiarised from cplusplus.com/reference/ctime/localtime/

Also, I added that, every time the clock skips a second, the thread sleeps for less time so it keeps time better the longer it runs.
This is so that, as long as it takes less than a second to print the ascii, the clock keeps ticking at one second per second regardless of how slow your computer is.
On the other hand, it means that it eats up more CPU the less the thread sleeps: without sleeping, it was using 25% on my CPU.

If you're not happy with the thread sleeping for varying amounts of time and want to keep it consistent, change int waittime = 1000; to how many milliseconds you want and double-slash out the if(timeinfo->tm_sec > sec+1) waittime-=10; line.

The ascii numbers I made myself some three years ago whilst trying to make a panic countdown.

Go bully all you like: I need to learn how to be not shit.

># New & Revised /dpt/ Code of Conduct #
>Code of Conduct
Jesus Christ! How horrible!

Fuck off

Looks pretty ok to me me senpai.
Try to get rid of the sleep function though. Use a high precision timer instead. This will also help you get rid of the windows dependency.
cplusplus.com/reference/chrono/

How do I write scripts?
I want to make a script where you can input a custom created playlist from youtube and it would go through the playlist and download convert all videos from the playlist to mp3 and download it to your computer using this website
youtube-mp3.org/
Where do I start?

rg3.github.io/youtube-dl/

kill yourself retard

It desn't matter how long the sequence is, it can only contain the number N, so "function(7)" would return 5 because you can write 7 as 1+2+4, 3+4, 5+2, 6+1 and 7

...

sweet

Use the c++ headers instead of c headers. Ctime instead of time, etc.

Learn to use const.

For the love of god use an auto formatter, your style is all over the place and many of the new lines seem arbitrary.

Use std::array instead of c style arrays. Std::array knows its own size so you don't need to use pass around the size c style or use magic numbers.

Factor some of those magic numbers out into constants, like that 7 in main.

Comment the purpose of your functions at least.

Look into using enhanced for loops.

I'll look into using Chrono but it won't entirely get rid of the dependency: there's still the system("cls") in there.
I've had a look for better ways to clear the console but they've gone beyond my understanding.

>c++ headers instead of c headers
Will do. I only used it because I couldn't figure out why my code wasn't working but the example was.
The example was using C headers so I left them alone.

>Learn to use const
That'll be like "final" in Java?
I don't see why it's necessary but okay.

>use an auto formatter
I'll look for one.

>enhanced for loops
>std::array
I'll have to familiarise myself with those, then.

>Comment the purpose of your functions at least
I will next time: I was concerned it'd be the mark of an autist to comment on something as amateurish as this.

why do you fags keep making the same stupid fucking op? you want people to leave? fine i'll fucking leave.

bb xoxo

why does my phantomjs code work when I just let it crash the terminal when it finishes, but when I add phantom.exit() at the end it doesn't crash the terminal but the code doesn't work, even before it executes it?

Where to start if I want to get into python? Any recommended tutorials or tutorial lists?

youtube.com/watch?v=N4mEzFDjqtA

>less than an hour
wow man thats fast

When did you last pair program, /dpt/?

never
the entire concept seems weird, like having 2 people work on the same art piece at the same time.

>tfw no qt to pair program with ;_;

Oh I misunderstood the question. I thought you were given a sequence of increasing numbers and had to find sets that sum to your number of choice.

So if it can be any increasing set, it's probably reducible to some nested factorial type thing.

I thought about it for a while and have a manual algorithm down. Now it's just about automating it. Is this what CS homework looks like?

My search pattern:
1 2 3 4 5 6 7 8 9 10 11 12
###################################

12

1 11
1 2 9
1 2 3 6
1 2 4 5
1 3 8
1 4 7
1 5 6

2 10
2 3 7
2 4 6

3 9
3 4 5

4 8

5 7


>I'm not a robot

Have you ever worked on any software development project involving a team before? That's what it is.

But what people claim the "advantage" of pair programming is is that two different minds who understand the same code apply their reasoning processes to it at the same time. When they arrive at different conclusions, they discover this quickly and discuss it.

;_;

That's not what team programming is. It's literally 2 programmers using the same computer.

Wouldn't it be logical for the X object to own the A andd not just borrow it? Also that's Rust right?

I didn't say programming on a team was pair programming. I said "2 people working on the same art piece at the same time" could easily be a description of programming on a team.

>When they arrive at different conclusions, they discover this quickly and discuss it.

As if any Sup Forums autist could accomplish this without turning into a REEE-ing puddle of tears.

When my prof asks "Do a binary search on an empty array"

Does he mean:

array = null (and properly handle any exception errors)

or

array = {0} (array only has one zero in it

or

array = {0,0,...,0} (evey nmbr in array is 0 regardless of array size)

Damn this shit is ambiguous

Do you consider programming a craft?

>Is this what CS homework looks like?
Unless he goes to a good school, no.
I've seen a solution for this problem with predefined lengths of sums (n = 12, k = 3, answers = , , etc.) and the inclusion of 0. That can be modified so zeros are removed and all the solutions for all sequences of length k from 1 to n (for number n) can be put into a set and then summed once complete.

Instantiated array with no elements.

>"Do a binary search on an empty array"
For any of those interpretations how and why would you do a binary search through it?

array = []

Depends on how you define "craft". I define it as something where the optimal answer is so far beyond the capability of a human that we apply various subjective rules on a regular basis in order to judge and approximate it. From that perspective, yes.

>and then summed
Well just the cardinality of the set.

>null
That's no array
>{0}
That one's not empty
>{}
This is empty. Maybe Java requires new int[0].

You made me curious... Hey Sup Forums, is int[0] a valid type in C/C++? Not asking for user, just for me

if length = 0 return

gotw.ca/gotw/042.htm
>The answer is Yes. Zero-length arrays are perfectly okay, kosher, and fat-free etc...

Sweet! Thank you user, see pic related

I do this quite a lot with my friend. We often cooperate with teamviewer; I think it's fun and adds a lot of motivation to the development of the project.

So does that mean anything involving math is a craft?

I recently started to learn C, coming from Java background, and I'm trying to implement a bare-bones printf function, handling %s, %c, %d and %f. This is what I have so far.
#define NUL '\0'
(...)

void printf_(const char *string, ...)
{
va_list var_arg;
va_start(var_arg, string);
while (*string != NUL)
{
if (*string == '%' && *++string != NUL)
{
switch (*string)
{
case 's' :
print_str(va_arg(var_arg, char*));
break;
case 'c' :
putchar(va_arg(var_arg, char));
break;
case 'd' :
print_int(va_arg(var_arg, int));
break;
default:
break;
}
string++;
}
else
{
putchar(*string++);
}
}
va_end(var_arg);
}

static void print_str(const char *string)
{
while (*string != NUL)
{
putchar(*string);
string++;
}
}

static void print_int(int i)
{
if (i < 0)
{
putchar('-');
print_unsigned_int(i * -1);
}
else
{
print_unsigned_int(i);
}
}

static void print_unsigned_int(unsigned int i)
{
unsigned int q = i / 10;
if (q != 0)
{
print_int(q);
}
putchar('0' + i % 10);
}

Is my code any good? Any tips on how to implement printing floating point values?

>#define NUL '\0'