/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Previous thread:

Attached: 1520721030323.jpg (534x1236, 185K)

Other urls found in this thread:

youtube.com/watch?v=rX0ItVEVjHc
youtu.be/KFV1Hba8SWE
librewolf.github.io/hypernote/
pastebin.com/k5fPra3Q
twitter.com/SFWRedditGifs

I'm working on trying to unrust myself from programming because it's been a while

Use Rust

in rust we trust

Why all the hate for OOP?

Attached: 1542722906696.jpg (1080x1306, 188K)

You know what I meant fucker, although I have never used Rust so maybe it might be worth getting into, although I'd like to practice some languages I already know

>What are you working on, Jow Forums?
rate my AI

Attached: sporty.webm (1280x720, 2.43M)

Working on a udp daemon to fuck with script kiddies.

youtube.com/watch?v=rX0ItVEVjHc

>Nested function calls==OOP

Posting this again because I really do need suggestions on how to improve this layout.

Dinking around with firmware for a custom keyboard I'm in the middle of designing (currently at fab). While I'm waiting for the boards I'm trying to get it all set up (as much as I can without physical hardware anyway).

Here's the programming layout I'm going to be shipping stock on these things. Need to actually use and tweak it, but would love some feedback (or usage if you have a ergodox). There's a few mousekeys that aren't in the layout because the tool can't handle them and I'll have to chunk em in manually.

GENTOOMANPREORDER on gboards.ca for cheap, user programmable keyboards.

Attached: 6007F69F-240A-4EF1-AE92-31ED8A349225.png (1211x1286, 74K)

Comfy

How cheap?

Also, is there a trackpoint?

Why am I so retarded when it comes to choosing what kind of program to make

Are Rust macros more powerful than Lisp macros?

Attached: 1526930511136.png (946x674, 52K)

Do a simple raycasting doom-like demo. Just a simple (but not cube) room with light sources. You may or may not use BSP.

No, that's totally possible in lisp, but no one chooses to do that because a sexp representation of xml loses no information and is more composable.

clicking on the catalog redirects to 4channel.
soon i will leave

Do Rustlets really find HTML embedding impressive?

Does any user here have experience with Fortran (9*)? I have defined a character array to work as a temporary buffer for a line of user-input text.
integer, parameter :: maxTextLen = 50
character (len=maxTextLen) :: tempBuffer


I'd like to make it empty before reading in new data from the user. Which way should I use to empty it?
tempBuffer = ''

or
do i = 1, maxTextLen
tempBuffer(i:i) = ''
end do

I’m selling the boards and electronics for 45$ (without shipping on gboards ), once there’s a decent amount of interest and I nail down the design that will come down (as I can order bulk PCB and spread the shipping). Shipping as much as it is because tracked shipping is a bad time. Compared to other builds this one is entirely SMD based and uses a on-board atmega32u4 (instead of a big old pro micro), saving space and cost. It’s meant to be used caseless (with rubber standoffs) and due to the low number of keys can have switches and caps added inexpensively :)

If you look at products like the UHK I reduce the cost by a factor of over 6! Gods keyboards shouldn’t be expensive to get into imho. This is trying to make them more accessible

I’ve got a ball at the moment, but the interface should be able to handle points or a small optical sensor. It’s in the works and the footprint will be the same so a keyboard from now will be compat with any of the pointers. Just pull it off the headers and pop on the other one

Also have the extra unused pins broken out on the backside. So if you want to hook some random shit up you can!

Attached: 229BB285-3723-4A1D-8874-28D9E2A6B437.jpg (843x497, 194K)

I made this supersimple standalone HTML presentation tool. CSS handles the visual interpretation of single slides and JS is used for keybindings and manipulation.
(You will hate me for this since it literally is just Markup langauge, but hey, at least I used javascript!)

vid
>youtu.be/KFV1Hba8SWE
demo
>librewolf.github.io/hypernote/

45$ is expensive for a keyboard pcb wtf

All that you need to add to that kit is switches and caps. As I said, it’s a little fucky until I can get all the kinks worked out due to volume. Worst case use that descount code and go for the green one, that should save between 10-15$ on her.

I want to add untracked shipping at some point, but then I have things getting lost in the mail :(

How would /dpt/ optimize this beautiful piece?

square(4)

def concatenate_strings(string1, string2)
"#{string1} #{string2}"
end

concatenate_strings("hello", "world")

#expect(concatenate_strings("hello", "world")).to eq("hello world")

Attached: 1543004082288.png (1350x1274, 3.01M)

but why

I’m unironically making an economy plugin for Minecraft because Minecraft modding is what I enjoy doing when I got nothing going on with school. Still learning the basics as I’m in first semester of CS.


I want there to be a command to create discount codes.

The way I’m thinking of doing it is having an array named dicountCodes. First column is the code and 2nd is the discount.

So if I ran something like /discount add DPT 10 it would add DPT with a discount of 10% to the array. And then I can use the array when doing shop functions.

Is there another standard practice for allowing users to create such variables to use in the rest of your program?

why would you want multiple discount codes?
Just have a globally mutable string, and parse accordingly.

It’s for other people to use. Different server owners may want to set things up differently. I don’t play the game. I just like modding

multiple codes just seems dangerous and messy unless you implement a manager for it. Which is why i said just keep one code, and change it when need be.
But I guess i see your point, if they'd ever want tier'd discount codes or something. I'd probably just use a string array and parse for the code & discount.

me unga dunga how learn c++

unga dunga, me unga bunga learn C instead.

Does anyone here use atom and python? What plugin do you use for autocompletion and stuff like that?

unga dunga push nim rock in cave

grug dunga want know how learn c and why learn c instead of c++

grug dunga, learn C because C is statically and weakly typed. This help grug dunga learn what happens under the rock. grug dunga learn how bugs and grubs work underneath rock. Then grug dunga move on to C++. easier time for grug dunga.

grug thank chadunga for help
but grug not know how start learn c even
should grug read clay tablet or go to web academy with berrypickers

berry pickers bird brains
clay tablets always right

grug will build statue in chadunga honour for this aid
may chadunga survive winter and thrive

>should grug read clay tablet or go to web academy with berrypickers
chadunga thinks this depends on grug. If grug has basic knowledge of coding/scripting, grug can use clay and man/doc tablets to make projects and learn. if grug green and new, maybe learn with berrypickers, learn how to hunt, then move on to clay tablets. chadunga suggests doing some projects from /dpt/ roll picture, grug must take gauge of current skills.

Clay tablet of Kunga and Runga have pretty pictures. Me say K&R.

>Kunga and Runga
Hate to break character, but I had to kek at this

I have a c program that checks whether the return value of fputc is EOF, and if it is, it returns with an error. I tried removing the output file while it was written to and it did disappear but my program didn't report any errors, nor did it open a new file with the same name. It just kept doing something with no output file. After this, I tried changing the permissions on the file mid-write. My program just kept writing to the file, but when I re-ran it with the same output file, it did report an error. Is this caused by linux delaying concurrent file modifications until the first is done? If so, why did the file immediately disappear when I deleted it while my program was writing to it?

Bruh, reading that gave me a headache. What are you trying to do? Please be concise. Post code.

I have a C program that is supposed to print an error message if it encounters an error while writing to a file. I'm trying to test it by fucking with the file mid-write. Like I try to delete it or change permissions, but instead of an error message, I get really weird behaviour.
There isn't really a point to posting code because it's not my program that's misbehaving but the file itself. Like I change it to read only, but my program keeps writing to it, which shouldn't be possible.

Most reads/writes are cached. Try to flush buffers and see what happens or use durect read/write instead of fread fwrite.

Ah okay.

> I get really weird behaviour
Yes, that's called undefined behavior.

>Like I change it to read only, but my program keeps writing to it, which shouldn't be possible.
Not really, you're opening a file pointer, not a file descriptor. I suggest using open instead of fopen and try again.

I wouldn't use a method at all.

>it's not my program that's misbehaving but the file itself
kek, /dpt/ just keeps getting better

Why is it convenient from an OS design perspective to treat pid 1 differently from other processes?

Every process has to have a parent process. PID 1 is spawned by the kernel, and therefore has none.

Like lil' tyrone.

Of course, but I mean the way PID 1 is treated specially by the kernel. Panic if it exits, ignores some signals, adopts orphans etc.

implementing CL's defstruct in guile

I guess my second post didn't successfully clear up things either. My problem isn't simply that my program doesn't print the error message but that the file itself keeps growing. I can see it in the file manager.

>Yes, that's called undefined behavior.
fputc is supposed to return EOF when it encounters an error, it's not UB afaik.

>Not really, you're opening a file pointer, not a file descriptor. I suggest using open instead of fopen and try again.
I don't know what the difference is between those but I can't use things outside of the standard library because it's for a uni project.

Anyway, the issue is pretty much solved now. I tried making a file read only while I was dd-ing into it, and dd too just kept going, so I guess it's expected behaviour and I should probably try to generate errors for testing in a different way.

It's not my fault you can't understand such a simple thing.

@68626558
not my fault you don't know how to program faggot hahaha

This is why file locks are a thing. Your program really has no way to know that something else is fucking with the file. Only the file-system can tell it that.

There's no reason that two separate programs should be simultaneously fiddling with a volatile file without an abstract layer of separation. This is why things like Database Managers are a thing.

I briefly tried playing around with Rust a couple years ago. I think I'll be checking it out again when Rust 2018 hits and non lexical lifetimes are in stable, since dealing with annoying edge cases of the borrow checker and not having impl trait was two of my main beefs.

The absolutely biggest issue I had with it though was not being able to pattern match on the contents of refcounted pointers like Rc in the same way as I can do with Box.

I tried porting a compiler from OCaml to Rust and gave up halfway in because it used persistent DAG's to cut down on memory use vs trees where everything is copied, and the issue with Rc meant that I couldn't express the transformation rules concisely with pattern matching. Well, technically I could with If patterns, but these also happened have a bug that broke memory safety that should be fixed with NLL.

Imho, Rust really should add something like active patterns in F# to let you define an API to pattern match smart pointers just like you can with box. Not being to pattern match on the contents of reference types is really a serious handicap to using pattern matching in a nontrivial way.

Post your code fags

Attached: _l.png (2412x1496, 797K)

Add that include folder to your compiler's include path.

You wrote forum in c++?

>panic if it exits
PID 1 has to clean up zombie processes because every other process in the system can trace a chain of parent processes back to it. If it can't perform this task, there's no guarantee any other process is configured to perform it, nor is there any guarantee that the kernel can start another PID 1 process. So logically, the kernel panics because the OS has been put into a state where there is no guarantee of recovery.

>ignores some signals
Again, we don't want PID 1 to die. Ever. There are no processes that ever have a business killing it, so we can safely ignore all of those signals.

>adopts orphans
Who else could? The kernel knows init is designed to wait on literally any child process of it, so logically it's going to throw any orphaned child at it so they'll get waited on properly.

its actually a lot better than it sounds. The wt framework is actually licensed enterprise software which also available free under the terms of the GPL. It has some nice features such as it works as a single application by default but falls back to multi-page mode if no js enabled all on its own, and its not too much harder than any other language if you are familiar with how c++ works.

Attached: 1542957701585.webm (2002x1668, 1.12M)

End this suffering.
static color __attribute__((const)) cielab(color x) {
x /= (color) {95.047f, 100.f, 108.883f, 1.f};
x = _mm_blendv_ps(powps(x, 0x1.555556p-2f), 0x1.F25EDp2f * x + 0x1.1A7B96p-3f, x

the feck is dis

A function that converts XYZ to CIEL*a*b* (D65, IIRC).

Interesting. I bet performance is through the roof.

Attached: slut.jpg (888x568, 52K)

Trait for deallocating a directed acyclic graph in Rust without using any stack memory.
pastebin.com/k5fPra3Q

>> unsafe

let foo = Rc::new("foo");
match foo.as_ref() {
&"foo" => println!("I am a genius!"),
_ => unreachable!("OH NO"),
}

What was the problem again?

god i love rust

I was trying to test the error handling by generating errors. I thought chmodding the file to read only while my program was writing to it would generate an error but it didn't.

Not him, but now match against some Option.

Any C programmers with socket experience here? I'm trying to read udp packets using recvmsg(), however, I keep getting a bad address errno. What am I missing? What kind of flags should I use for recvmsg()? Currently it's 0.

Attached: 1540425914889.jpg (612x612, 98K)

JavaScript rocks!

Attached: js-rocks.png (1000x494, 369K)

let foo = Some(Rc::new("foo"));

match foo.as_ref().map(AsRef::as_ref) {
Some(&"foo") => println!("You appear to be frustrated"),
_ => unreachable!("I have placed a joke on you"),
}

>match foo.as_ref().map(AsRef::as_ref)

Attached: 1523410554910.jpg (461x785, 56K)

Consider the case where you match something like

Integral (Pow a (Mul x x)) x | Integral (Pow a (Pow x 2)) x -> Sqrt (Div Pi (Log a)


Where the fields of each struct are references that form a DAG. I'd like to be able to do that with a single expression instead of multiple layers of pattern matches with as_ref.

Someday you'll be able to write a pattern like Pow(a, box Mul(x, x)) and so forth. Right now I don't think there's any movement on stabilizing this feature, but it's definitely planned.

That would be one possible solution but it strikes me as a special case. Personally I'd prefer a more general solution like active patterns that allows the user to define their own custom pattern matching on any of their own types. But it's better than nothing.

/dpt/-chan, daisuki~

>What are you working on, Jow Forums?

Crafting an app to play opengl compute shaders. implemented an option to set the filtering to nearest (top left on pic) or linear (bottom right).

Attached: s.png (1679x1032, 899K)

What would be the best approach to edit XML files via bash?

notepad.exe

sed

I just got into programming tonight. Is LPTHW supposed to be vague.

wtf when did it become 4channel?

today i think

It's supposed to be teaching you wrong. The hard way refers to relearning later.

Lisp is the most powerful programming language.

I know, but it happened within a few hours. I hit refresh and it went from Jow Forums to 4channel.

you could have prevented this

kek. Anybody else notice the front page? Also /b/ and other adult boards are missing from the bottom, but are still reachable. what's happening? Jow Forums needs to be clean to sell ads on?

It was a couple of hours ago. Welcome to Channel 4.

did nobody read any of the fucking announcements

Ah gotcha.

New name, new place. None of the controversy.

>reading announcements

nerd

I bet you post on qa too

Is there a way to get rainbow parentheses in DrRacket? The built in highlighting sucks nuts

fuck you don't mention hidden board

yes, it even has its own themes. it shall be somewhere in the options.

imagine having to use a syntax highlighter specifically for your parenthesis just to try to navigate the (((Lisp))) jungle.