Old thread: What are you working on, Sup Forums?
/dpt/ - Daily Programming Thread
Other urls found in this thread:
en.wikipedia.org
wolframalpha.com
wolframalpha.com
glorioustrainwrecks.com
en.m.wikipedia.org
github.com
hackernoon.com
inf.fu-berlin.de
twitter.com
Writing a kernel sans I/O in Haskell for my employer
Deciding whether I should use WolfSSL instead of OpenSSL for my encrypted chat app
What the fuck does it do then?
>Are we luddites user?
No being philosophically conservative has nothing to do with being opposed development. It's just a more careful attitude to things. And in this instance we have plenty of ground to stand on so you're not even being conservative. You're just being enlightened.
>0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1==0.8
>False
Floating point numbers were a mistake.
No they do their job well. You're just not demonstrating use of them doing their job.
Go ahead and come up with a new standard for representing floating point numbers that doesn't have this problem, user.
What are good resources to learn C# and Java, coming from C++?
I'm working on a bookstore application in C that communicates with a text file. I'm currently trying to check the price of a book that exists inside the text file.
I want to iterate through the file but every time I run my readRecords() function; which is supposed to return the value of fscanf, I only receive -1.
In every other aspect of the whole application I get the return value of 5; which is the amount of arguments I want to scan.
How do I fix this?
ttygif renders a bit too fast but it works!
In base 12:
>0.4+0.4+0.4 != 1
Decimal floating point numbers were a mistake.
Isn't significand *2^scale be more efficient than significand*10^scale on binary computers?
Yes of course. You end up with meaningless wasted states with binary encoded decimal, since you need 4 bits (max 16 states) to encode a digit (10 states). It's impossible to have it fit perfectly since no powers of 2 are divisible by 10.
Er, though I should clarify
>It's impossible to have it fit perfectly since no powers of 2 are divisible by 10.
Base 8 and base 16 fit nicely into base 2:
wolframalpha.com
But base 10 cannot fit into base 2 perfectly:
wolframalpha.com
signal(SIGPIPE, SIG_IGN);
What the fuck is this?
You can also use a language with support for ratios like Scheme.
where b is 4 a is 3
(+ 2 (if (> b a) b a))
why does this only add the value to b (making it 6) . really what i mean is why is it ) b a ))? i get the predicate part
(> b a) => t
(if (> b a) b a) => b => 4
(+ 2 4) => 6
Structure your code better when you're still learning.
(+ 2
(if (> b a)
b
a))
If you wanna write it C style:
(+ 2
(if (> b a)
b
a
)
)
((call/cc identity) (call/cc identity))
Nice infinite loop nerd. You implement anything fun with satan's control structure yet?
I'm trying to make a P2P network where data is signed, which is all very well except for the possibility of a peer adopting the ID of a peer who hasn't joined the network yet, and creating keys on the behalf of that peer.
Is there a way I can prevent this?
For technical reasons, it's impractical to have peers ping each other to verify that someone has the IP they claim to have.
Make the ID of someone BE his key.
lol C is autistic as fuck
>//Define a variable int rv = 0
>int rv = 0;
Stopped reading there.
when your cs professor tells you to add more comments
More like
>C
Stopped reading right there
By the way, having a trusted peer who is the only peer that can assign new peers to the network is an option (there has to be a first peer that people connect to anyway), but I don't see any way of preventing people from faking their identity as they connect to that trusted peer.
Aside from pinging of course, but the type of network this is makes it very awkward to do that.
In terms of packet speed and accuracy, it's not unlike the pigeon-based internet described in RFC.
That's impossible.
If it was possible to have a predetermined public key which was then used to produce a private key, ANYONE could make the private key.
Why is programming in Ruby so much fun?
Working on occlusion querying. Right now the querying is really primitive. As you can see there's a little glitch where the chunk the player is in isn't drawn. I'm happy with that glitch as it shows occlusion querying is working. Easy to fix. I have 2 choices, temporarily turn off winding-based culling or just exclude the chunk the player is in from occlusion queries.
The current occlusion querying is also extremely inefficient:
diorama_test_occlusion(d);
glBeginConditionalRender(d->occlusion_query, GL_QUERY_WAIT);
draw_compiled_diorama_solids(d);
glEndConditionalRender();
The current lazy implementation only works on the solid blocks and not water. The usage of GL_QUERY_WAIT also creates execution bubbles in the GPU pipeline. Even then the performance benefits are pretty decent.
No occlusion culling:
OpenGL "FPS": 149.809816
OpenGL Frametime: 6675130
OpenGL "FPS": 149.809816
Shitty trash-tier absolutely terrible baby's first occlusion cull:
OpenGL "FPS": 187.805066
OpenGL Frametime: 5324670
OpenGL "FPS": 187.805066
Stats are for render distance of 4 chunks. Benefits should scale cubically.
The idea is you exchange your public keys with someone just as you exchange names with someone. People do it all the time with encrypted email.
It was designed to be fun.
of course, i keep on thinking of if statements in the style c++ uses
Is this written in sepples?
Give me something fun to program.
Fuck no. C and Scheme.
"git clone" based package manager.
That's some pretty nice progress
What Scheme implementation do you use? I did not find anyone good an wrote everything in Common Lisp (to avoid embedding).
I use chicken. It's compiled and has a nice ffi.
Chicken translates itself to C and then compiles itself. Guile is good but bytecoded. I couldn't find anyone native like Common Lisp implementations.
Why Scheme instead of CL?
What the absolute fuck. Programming was a mistake.
thank god there's javascript in my terminal now
Not him but CL is not good for embedding because of its big footprint (ECL exists, but it's still big). If you are using C, Scheme is the way to go.
It's (+ C Scheme) or full CL.
Yeah it does but it still runs better than interpreted schemes. Also the ffi is really, really nice.
One of my goals is for it to be an educational game desu. Scheme's a pedagogical language.
There's kids programming courses that are minecraft programming but I think I can do better with a game that has an in-game repl and in-game compiler and that was designed to be moddable from the ground up.
htdp or sicp?
htcp
Figured it out; here's the solution in case anyone wanted.
change if (fp != NULL) to if (fp)
>//open file for reading
Stopped reading there.
lmao, but my prof that previously hired people for McCain fries said to comment all your shit even if it's stupid.
idk what I'm doing desu.
imagine using a language that doesn't support parallelism with threads
name one
ocaml
Your mom because she can't multitask but she sure can take multiple threads at a time
Fortran 1
don't (use | care)
rofl xDDDDDDDD lelelelele
did you just?
>C++
>Tuples
Top fucking kek
How do I make this code look better?
>inb4 switch to whatever retarded language you suggest
You're progressing too fast and making everybody else here look bad. Why don't you take a break from this project and relax for a little bit?
>vim
>windows
nyoro?
You should really just not use tuples in c++, even if that means creating structs / classes that only get used a few times.
It's fun how (any) Lisp most basic structure (cons - list) can be horribly implemented in C++-style.
But this is exactly what happen when my code executes and the templates get instantiated. Small classes/structures get created.
My problem though is that someone can use someone else's name as they share a public key.
Which is only a problem if that someone else isn't yet known to whoever they're talking to.
what are you talking about?
gee I wonder what you think those "Lisp most basic structures" get compiled down to...
gee I wonder what you think those "C++ templates" get compiled to...
I wouldn't write something a computer can write for me. It's the same principle you are using C++ over assembly.
What's the most powerful line of code?
public static void main(String[]args) {
This line starts any Java program you can think of.
It can launch missiles, play chess, run a global business, and many more things.
This one [line] can trigger billions of lines, whose power soon adds up.
autism
How come I can't return this implicitly?
fn main(){
let p = "Title name - ";
let book_title = String::from("Title name - Return of the Two Towers.");
let book_name = skip_title(&p, &book_title);
println!("{}", book_name);
}
fn skip_title(prefix: &str, title: &String) -> String {
let to_skip = prefix.chars().count();
let result: String = title.chars().skip(to_skip).collect();
return result; //works
//title.chars().skip(to_skip).collect::();
//won't work?
}
>missiles
>Java
Just Pajeets and their space programs
Oh shit nevermind, I was including a ; at the end
int CALLBACK WinMain(
_In_ HINSTANCE hInstance,
_In_ HINSTANCE hPrevInstance,
_In_ LPSTR lpCmdLine,
_In_ int nCmdShow
);
whats _In_ and _Out_ ????
pajeets can't into ada
penis in your ass
n-no bully
Does Ada use GC?
optimized image
i didnt give you the permission to do that didnt i?
also how did u do it
png optimizer with lossless compression
Working on my rogue like. So far I've got a working game window and map gen. Which is to say I've got the easiest parts out of the way.
Got my occlusion working right! 373 FPS.
int start = 0;
for(int dst = 3;; dst+=2) {
int max_drawn = dst*dst*dst;
int q = dst + 2;
int max_tested = q*q*q;
for(int cursor = start; cursor < max_tested; cursor++) {
if(cursor >= renderorder_size)
break;
triple * cur = renderorder + cursor;
if(cursor >= 27) {
float result = vec4_mul_inner(camera_angle, cur->normed);
if(result render = false;
continue;
}
}
diorama * d = finite_getdiorama(f, cur->x + px_dio, cur->y + py_dio, cur->z + pz_dio);
if(d == &nulldiorama) {
cur->render = false;
continue;
}
if(d->region_starts[FIRST_LIQUID] >= d->vbo_size) {
cur->render = false;
continue;
}
cur->render = true;
}
for(int cursor = start; cursor < max_drawn; cursor++) {
if(cursor >= renderorder_size)
goto end_drawing_solids;
triple * cur = renderorder + cursor;
diorama * d = finite_getdiorama(f, cur->x + px_dio, cur->y + py_dio, cur->z + pz_dio);
if(!(cur->render))
continue;
glDeleteSync(d->solid_fence);
if(cursor >= 27) {
GLuint result = 0;
glGetQueryObjectuiv(d->occlusion_query, GL_QUERY_RESULT, &result);
if(result == 0) {
cur->render = false;
continue;
}
}
diorama_clean(d);
draw_compiled_diorama_solids(d);
d->solid_fence = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
glFlush();
}
start = max_drawn;
for(int cursor = max_drawn; cursor < max_tested; cursor++) {
if(cursor >= renderorder_size)
break;
triple * cur = renderorder + cursor;
if(!(cur->render))
continue;
diorama * d = finite_getdiorama(f, cur->x + px_dio, cur->y + py_dio, cur->z + pz_dio);
diorama_test_occlusion(d);
}
glFlush();
}
end_drawing_solids: ;
But I must.
>using gotos
why
>But I must.
Nice occlusion culling.
>being afraid of a 4 letter word
goto hell
To break out of a nested for loop of course.
I-Is it possible to learn this power?
Yes.
just download one like i did.
pngcrush and pngout
how do i learn "lamb the calculus" if i have only ever used "two ring my sheen"