/dpt/ - Daily Programming Thread

old thread What are you working on, Sup Forums?

Other urls found in this thread:

lpaste.net/164078
lpaste.net/164079
lpaste.net/164080
lpaste.net/164081
lpaste.net/164082
lpaste.net/164083
azure.github.io/azure-storage-python/ref/azure.storage.blob.baseblobservice.html
twitter.com/NSFWRedditVideo

>Creating threads before the bump limit
Delete this shit and kill yourself.

"No."

fuck everything about that textbook

Hey /dpt/, I've been thinking about making a little language that compiles to brainfuck.
Now, is it an ok idea to make an "assembly" that "assembles" to brainfuck, to make the compiler easier?

If you're too retarded for that book I'd hate to see you read Knuth.

I'm learning about WPF, so far so good.

Can I have multiple return statements in case like this?

Yes, why wouldn't you?

why not?
why ask when you can just test it?

Yeah it don't care

sure.

also, make any but the first "else if"

or use switch/case

there is no reason to, he's using a return

This program has errors I don't understand, so I'm going down the list checking things off.

You're in over your head kiddo

does in.get() remove a character from the stream?
If so, your if statements are consuming too much input.

Honestly regret taking this class, it's not at all what I thought it would be. I'm no programmer.

java.lang.NumberFormatException: For input string:

Why?
I have a string made of numbers.

might change that later or add another line to one or more of the cases

good practice is good practice even in an edge case.

>>> stackoverflow

You have been visited by the crossdressing C programmer of Shimoshina Academy!

Good performance, triple indirection, and tail call optimization will come to you, but only if you post "Keep overflowing the stack, Hime!" in this thread.

Yeah, I think so.
Like, I said I have a hard time following this program and how it's making "Tokenizer" objects and how it accesses them.
It's supposed to be a calculator, and I'm trying to take into the account of the different cases of if I wanted to find:
20 >= 9
vs
20 >> 9
So if it ever encounters an inequality it needs to read the next character. I used in.get just because of the above method.

Ignore him. None of us were born with the ability to write fizzbuzz. We learnt through classes, articles, and shitposting on here. Keep at it.

LWJGL isn't working for the HelloWorld class provided on their website.

it's giving me this error (I already upgraded to a new version of Eclipse that support Java 8)
Exception in thread "main" java.lang.UnsupportedClassVersionError: src/HelloWorld : Unsupported major.minor version 52.0

Is there some sort of .peek() function? One that will look at what the next character is, but not remove it from the stream.

Anyone have the picture of that crazy / anime Japanese C programming book; where the character / title was "Thinking about malloc"?

>Trapfag is so butthurt that he didn't get to post his degeneracy in the OP, he spams his stupid Sup Forums-tier shit in this thread

Do your self a favor and get into MVVM as fast as possible if you're going to get a job with it.

I've never been into design patterns, but I'll definitely take a look.

I've done 4-5 years of WPF work, its pretty popular and doesn't really hurt for the most part.

You taking a compiler course? It only gets worse. glhf.

trying to teach myself mql4 (some bastard child of C++ used for trading currency).

this first attempt of mine is shit and obviously incorrect and riddled with fuck ups but im going over some tutorials and i will try again.

see

That's nice, I'm actually aiming to get a job position of C# and WPF, btw, do you have any kind of resources that can recommend? Specially to git good, and translating my PS mockups to WPF.

I was hoping that I could just pop it off, then push it back on, but I can't even find where it's initializing these objects called "opStack" and "postFixStack", I ctrl+f and I can only find where they're getting functions called on them.
Thanks. I suck at programming (I'm a math major), but I'll never give up! I can take the banter.

MVVM is a must then - it decouples the UI from the backend code, allowing you to do whatever the hell you want to the front end without breaking anything.

You don't need a fancy framework for it, its just how you structure the files, however, dependency injection does make it a lot easier - so if you don't know what that is i'd start there as well.

Most of the people that did fancy UI tweaks with WPF used "Blend" to get started and imported it into their project as well.

>Making a new thread without DaT BOI
>Like he won't be Coming

you must be 18 or older to post here

ungetc() pushes c back to stream, cast to unsigned char, where it is available for subseā€
quent read operations. Pushed-back characters will be returned in reverse order; only one
pushback is guaranteed.

Thank you

This has to be the stupidest forced meme in a long time, who finds this shit funny?

This is, in general, the biggest forced meme ever.

Isn't impossible to get more than one return or am I misunderstanding? I thought once the line reaches a return command the function will return and skip all other lines unless there is something like a finally?
I could be wrong, but I thought it was impossible to get more than one return. I would think it would return with whatever return is first executed if there are multiple possible ones.

>Isn't impossible to get more than one return or am I misunderstanding?
When the function / program returns, it returns. That stack frame for that function (excepting statically declared variables) stops executing / existing when it returns.

>I thought once the line reaches a return command the function will return and skip all other lines
Exactly. Maybe this will clear it up: those are POINTS at which it will return.

How come Lua doesn't print zero with cos or sin?
E.g.
> print(math.cos(math.rad(0)))
1
> print(math.cos(math.rad(90)))
6.1232339957368e-17
> print(math.cos(math.rad(180)))
-1
> print(math.cos(math.rad(270)))
-1.836970198721e-16
> print(math.sin(math.rad(0)))
0
> print(math.sin(math.rad(90)))
1
> print(math.sin(math.rad(180)))
1.2246467991474e-16
> print(math.sin(math.rad(270)))
-1

I need it to print zero and not an arbitrarily low number.

because they have to use approximations of pi, which is an irrational number.

you can just round it if you want

Thanks.

>thought once the line reaches a return command the function will return and skip all other lines
Yes, that's exactly what I want it to do.

Okay, thanks.

6.1235254352345e-17
That's a mere 6 times machine epsilon. That's basically zero.

Where could I find what you're working on? Is it from nand2tetris?

gettimeofday() or clock_gettime() for a game engine on Linux?

I know, but I want it to be zero. I can't seem to figure out a way to properly round it because there is only math.floor and math.ceil.

clock_gettime(CLOCK_MONOTONIC,&timeobj)

What about CLOCK_MONOTONIC_COARSE?
Does a game engine need precise time? exactly how coarse is CLOCK_MONOTONIC_COARSE?

Floats aren't exact. If you're doing equality checks with floats you're doing it wrong. If you just want to print 0 then you just print a finite number of decimal places so it prints 0.000000000000000

How about time(NULL)?

I have never heard of CLOCK_MONOTONIC_COARSE.
>Linux 2.6
Oh fuck I feel old now.

Check its resolution with clock_getres. If it's more than a few hundred ns I wouldn't bother.

>Time in seconds
>For a game loop.

>For a game loop.

This was not made clear.

Also note that CLOCK_MONOTONIC_COARSE is a Linux only thing so if you wanna have your game run on nonfree OSX or cuckoldry BSD you can't use it.

Nah, it was because I wanted to easily generate a set of numbers {(0,1), (1,0), (-1,0), (0, -1)} and I thought that the simplest way would be to use cos and sin. I found some function to properly round. I have this
#!/usr/bin/lua

function round(num)
if num >= 0 then return math.floor(num+.5)
else return math.ceil(num-.5) end
end

for i = 0, 270, 90 do
print(round(math.cos(math.rad(i))) .. "," ..
round(math.sin(math.rad(i))))
end

This outputs:
$ ./test.lua
1,0
0,1
-1,0
-0,-1

It's from a Data Algorithms class at my uni.
It's a big project itself (as in it's a lot of files), but the students are only supposed to implement a few of the operators in evaluator.cpp.h and tokenizer.cpp.h
You can check it out if you're curious:
lpaste.net/164078 - the driver
lpaste.net/164079 - evaluator.cpp.h
lpaste.net/164080 - tokenizer.cpp.h
lpaste.net/164081 - token.h
lpaste.net/164082 - evaluator.h
lpaste.net/164083 - tokenizer.h

I tried commenting out what I implemented, but it doesn't show up too well on that website.

Millsecond or lower is a decent precision for controlling tickrate. 60 fps requires a frame update time of around .0016 seconds

That's seriously overkill just do a remainder and a switch case.

Reading C Primer Plus 6th edition, and on chapter 12, my god, I find scope to be so simple but Stephen Prata spends so much time explaining it.

No. Millisecond most definitely is not. I switched from a millisecond timer to a nanosecond timer to find that everything was smooth. Millisecond timers produce jittery awful games.

Anyone here know how streams work in python? Trying to stream a blob from Azure to the filesystem.

get_blob_to_file is attempting to put it in memory (exit code 137 - getting killed due to memory). I figured get_blob_to_stream would solve that but its a bit over my head.

method:

self.blob_service.get_blob_to_stream(container_name='container', blob_name=blob_name, {STREAM})

Would I use something along the lines of

with io.open('file.extension', 'w') as file: and pass in file?

It's an important topic.

oh good, fucked that up.

Hey, how does that book compare to other's OP?

I've heard Sedgewick / Wayne was better and that's what I've been reading. Should I switch?

...

Great book.
He's just making sure *all* of the readers get it, I assume. I'm sure people got chapter 15 real quick and easy but I know I didn't. (I think that's the one with all the string functions? or is that 9?)

I've only every gotten through the sorts senpai, dont really know

me on the left

I read Sedgewick
Pretty based and gives practical examples

I think Wayne also did a online course which you can probably find on coursea or the Uni (was it Princeton?)

I'm using a long on a shitty calculator.

why does a long doesn't give me negative numbers?

On a scale from 1 to Java, how much of the examples in his text are in Java? Looking at the description it seems like most, but I am not really a Java person.

How do C variables work in assembly?
If I declare a variable in C, and then reference it later, how?

It really depends on genre.

I've found that Millisecond timers perform adequately for most common indy games (Platformer / Rpg).

If you're getting jitter it's from not interpolating between two physics steps to get a approximate position at render time.

It's not Java specific, you could easily convert it to c++

in memory there's an area for floats, and another for integers. so when you declare an int, the compiler allocates space in the integer memory section. it keeps track of the memory location of that int. then if you want to access it you just find the memory location.

>It keeps track of the memory location of that int.
this is what I'm asking

In a register or on the stack.

That's not how it works at all.

I get it, nevermind, thank you anons

It's there any calculator that holds a historial of operations?

That's my big million dollar idea sempai.

>Keep overflowing the stack, Hime!
Keep overflowing the stack, Hime!

>How do C variables work in assembly?
It depends on the variable.
>If I declare a variable in C, and then reference it later, how?
If you're talking about global variables, then it would be declared with external linkage, and its name will be a symbol that refers to where your variable resides in memory.
For example:
long a = 10;
.global _start
.extern a

_start:
movq $60, %rax
movq a, %rdi
syscall
When this C file and assembly file are linked together, the program will return 10.

If you're talking about local variables, they reside on the runtime stack or exist only in registers.

can anybody think of an easy way to get the dates of every monday and saturday in a year in a vba script (excel)?

for example this month would be:
5.2 - 5.7
5.9 - 5.14
5.16 - 5.21
5.23 - 5.28
5.30 - 6.4

I have a method that works, but it feels like a dirty workaround and I think there's probably already something in excel that would do the job better, but I'm not sure where to look for it.

I'm using get_blob_to_stream from: azure.github.io/azure-storage-python/ref/azure.storage.blob.baseblobservice.html

via:

with io.open(file_path, 'w') as file:
self.blob_service.get_blob_to_stream(container_name='container', blob_name=blob_name, stream=file)

but it still isn't writing anything to the file (it creates it, 0 bytes. Process is getting killed for taking to much memory - does anyone know what i'm doing wrong?

>that feel when you can't get through a knuth lecture because he won't stop stuttering

old man knuth pls

>all those extra lines of code and a third else which will never actually be used.

so rustled.

What is the best fixed-width bitmap font?

Another stream question here

How would i get the pointer to ammend the file instead of erasing it in C#?

Any kind of quick thing to make the pointer search for the end of the file?

>An int is a number without a decimal
>The face below might as well be XD

This was engineered to trigger us, genderwar when

what the literal fuck does the left code do?

Fast inverse square root

...

Q_rsqrt(x) quickly calculates an approximation to 1/(x^0.5). Useful for lighting calculations (back when lighting was done on the CPU).

quicker than this?

>program for classes
>do nothing at home
>graduate
>program for work
>do nothing at home
>die