/dpt/ - Daily Programming Thread

Old thread: Other thread deleted because of stupid Norwegian shit, I assume.
What are you working on, Sup Forums?

Other urls found in this thread:

howtogeek.com/107965/how-to-add-any-application-shortcut-to-windows-explorers-context-menu/
youtube.com/watch?v=8U18EuNN2D0
youtube.com/watch?v=dnMpP-rpJjY
twitter.com/NSFWRedditGif

typechecking

This is the one true thread
Post the code.

That is code

Writing unsafe code that triggers type theorists

use std::mem::transmute;
use std::mem::size_of;

pub fn reverse_bits(b: u8) -> u8 {
((b & 0x01) 3) |
((b & 0x40) >> 5) | ((b & 0x80) >> 7)
}

pub fn bit_reverse(value: A) -> A {
unsafe {
let ptr = transmute::(&value);
for i in 0..size_of::() {
let j = i as isize;
*ptr.offset(j) = reverse_bits(*ptr.offset(j));
}
}
value
}

I mean something I can copy and paste.

Threadly reminder that dlang-chan is not dead; she's going to have her GC tumor removed (eventually); and she's super duper cute and easy to prototype in! Say something nice about her, /dpt/!

what for?

I'll save it for later and maybe borrow some syntax.

don't be a dick

>He doesn't borrow lifetimes instead

...

I'm genuinely amazed that anyone defends languages in which you can write a function of type (forall a. a -> a) that is not the identity function.

Everytime you write an unsafe code, a kitten dies

Every time you write unsafe code, a windows pc gets owned.

That would be most languages really, but not all of them are retarded enough to let you do it without being extremely roundabout.

Then most languages are terrible and shouldn't be defended.

How the fuck am I supposed to concat two strings in CL?

I agree, but obviously something which has such a function in the standard library is worse than something which lets you define it if you prove a contradiction.

Or get it's length.

(concatenate 'string string0 string1)
or
(string-append string0 string1)

string1~string2

Explain to me why i shouldn't write K&R style function signatures to save horizonal screen space?

Because horizonal line space isn't a concern?

You should write K&R style because it's A E S T H E T I C, but line length isn't a concern.

What's the best way to start learning Java for someone who already knows some Python and took a basic CS course?

Read a book?

>Other thread deleted because of stupid Norwegian shit,
HA HA HA HA HA
We should ban Norwegians at all.

Which book(s) specifically would you recommend?

There are many resources out there that will tell you, user. Stop being lazy.

You aren't determined if you have to ask.
Use your brain faggot.

The only language feature that you really need to be able to do this is the ability to cast arbitrary pointer types to a byte pointer. As much as this might break a lot of safety for you, it's pretty damn useful if you are trying to serialize/de-serialize data associated with some arbitrary byte stream, like a file or a network socket. I don't think I'd be able to parse DNP3 traffic for my research code if I couldn't arbitrarily cast UINT8* to struct SomePacketHeader* and vice versa.

@60362221
>I don't think I'd be able to
I agree.

are you saying #GirlsWhoCode is a fake hashtag?

Does anyone know anything about COM on Windows?
I want to extend the Windows explorer context menu, adding an item that will have dynamic sub-menus and labels (depending on the selected file/files/folders), much like pic related. The big exception is that I only want this to show up when my application is running since this local service will have to query another local server.

MSDN says I need to implement a COM object but finding documentation for it is impossible, the word "COM" itself is expected to be ".com" on most search engines and anything I do find is all about calling methods on existing COM objects, which isn't helpful since I need to write my own.

I just want to write something that when it's running adds a sub-menu to the context menu, if anyone knows how to do this please guide me in the right direction, if I can avoid COM that'd be great, if not let me know where to look to implement what I need. I'm going insane with this.
>Windows

Please respond.

Is there anything like avyjump for vim? Preferrably without having to use any extensions.

Looking for a way to print a string in hex that works in both Python 2 and 3.

These work in their respective version:

Python 2: print ( "DPT".encode ( "hex" ) )

Python 3: print ( bytes ( [ ord ( c ) for c in "DPT" ] ).hex ( ) )

Fucking Guido, man. Changes the behavior of built-in functions.

there is an entire free course on the java website that will teach you the basics. it's also a good oop course in general.

howtogeek.com/107965/how-to-add-any-application-shortcut-to-windows-explorers-context-menu/

>good oop course
>good
>oop
what did he mean by this?

Thanks but that only covers static items and persists even when the application isn't running, I need the menu item to only exist while the application is running, and only display actions it can perform (dynamic entries).

This shouldn't be difficult but the problem is finding the documentation.

finally got my new computer!

i7
asus ddr 4 thing
gtx 1060ti something
8gigs ram ( lol almost fell for the 16gig meme)
and windows home ( fuck my inability to focus on a single learning curve )

that of course was before. also got an xbx one so not much gaming on the pc.

imma work on some woreframe shill whem i get it up. gonna hang out and read tol i get a headachem i expect a post or two.

Not programming.

shut up henry

om jk talk to your hearta content. have sone water and a snack.

>what are you working on
Making a Firefox plugin that queries a convultional neural network that detects porn and blocks it.

Going to call it jewish tricks blocker

/dpt/-chan, daisuki~

Ask your much beloved programming literate anything (IAMA)

Thank you for using an anime image.

Oyasuminasai, Akari-chan. Writing an HTML parser is harder than I thought. Any thoughts other than not being retarded?

import html.parser

I want progress report on akari-bbs

B-But that doesn't help me at all!

Which mongolian puppet show is that from?

This question

apparently it's all the rage to write ransomware at the moment
I'm working on my own
and already have the shitpostings for Sup Forums ready so I only have to copy paste it afterwards

WAIT

I had same idea just for kicks and then put it all on github. Problem is I have no idea how delivery system would work... Encrypting /home folder should be easy enough without special permissions but rest. hmmm

%opt

html_parser :> scope.
engage.
- parsehtml html. = result.
result >- terminal.
send 0.
halt.

To the guy who was developing a VM with that Qt IDE or something, beat this.

You may mock me, but the way the network packets are structured, there's not really any other way to properly serialize it. Hell, one of the weird things in it is that there's a CRC every 16 bytes, starting at the header immediately following the data link header. This CRC is allowed to be in the middle of a header or object field. So you have to split up the application payload, copy it into a contiguous array without the CRC fields, and then start pulling off headers one at a time, since the header to use next is dependent on what the last header is. It's completely impossible to encapsulate a packet within a single type definition. Perhaps you could do the whole thing without defining any types at all and just operating on bytes, but that would be even more annoying. Cast byte pointer to a packed struct pointer containing some miscellaneous object header, and it's easier to figure out what the hell you're doing.

@60364274
I didn't even bother reading your post. Just letting you know.

Fair enough. And I'm well convinced that you never have and never will parse a binary network protocol. You'd change your mind rather quickly about things like transmute and reinterpret_cast if you did.

@60364319
Did I say you could reply to me?

I do not require your permission to reply to you.

@60364340
I didn't give you permission to reply to me.
All subhumans have to receive explicit permission before responding to anything I say.

Stop responding to bait.

>trying this hard on the net
just be yourself user

>just be yourself user
What's that supposed to mean?

Blow it out your ass.

Hello I want to be an autist like the rest of you but i'm beginning to lose patience with it all.
How many of you use an IDE when doing C coding?
I've been using gcc and command prompts for the last month and frankly i'm sick of it, especially after using the C IDE for nios for uni. Would I be a pleb if I started using an IDE? Maybe I'm not as well suited to be as cool as you all are.

@60364378
I don't recall giving your mentally ill kind permission to reply to my posts.

i mean stop trying to be alpha on the net, we can already tell what you are, im sure you're likable enough without putting on acts for us lol

Set up a build system. Nobody actually compiles shit by hand.
Even a plain makefile is more than enough.

Excuse me as I reiterate myself:
youtube.com/watch?v=8U18EuNN2D0

Yep create makefile and just bind command "make && ./a.out" to something like ctrl + b
and in make just put
all:
gcc **.c

You really dont need IDE for C, stdlib is small enough...

Think about why that makes no sense.

@60364410
Right now. You have my permission.

WOW this sounds very helpful.
Yes I hated having to retype the command every time I got a compiling error.
Thank you very much.

I guess I only make sense to the intelligent

c is an obsolete programming language. it's technology from the past for the programming techniques of the past.

youtube.com/watch?v=dnMpP-rpJjY

What do you consider to be "intelligent"?

>c is an obsolete programming language
For something to be obsolete, something has to make it obsolete.
Nothing makes C obsolete.
Therefore, C is not obsolete.

haha yeah I tried reading that book, maybe I should try it again.
Are there any cooler languages I should be learning that you'd recommend?

>Nothing makes C obsolete.
False.

Alright, time to bother to go to sleep now.

just note on **.c if you are using bash you have to enable globstar its recursive glob. So it will match all .c files in all child dirs
shopt -s globstar

Do you care to name a language that obsoletes C?
If you say C++ or Rust, you clearly have no idea what you're talking about.

>Nothing makes C obsolete.
sure, this is why C is no more used outside of kernel development.

I suppose you are one of those who want to write device drivers in javascript or java?

>Do you care to name a language that obsoletes C?
Take your previous statement which was "For something to be obsolete, something has to make it obsolete."
Then replace "something" with "C".

You're fucking stupid. Never mind the fact that basically every important library is written in C.

What is an "important library"?

device drivers is mostly kernel development

modern libraries are not.

Apparently all the ones that aren't written in C++.

A library which is important.
For example, off the top of my head:
libcurl
libavcodec and friends (ffmpeg)
openssl
zlib
libjpg
libpng
libvpx
(Basically every image, music, and video codec library, if you're following the pattern)

Now what the hell is a "modern library"?

But how do you determine if it's "important"? And what time frame is this valid in?

I forgot some other big players from windowing:
SDL
GLFW

It's used by a lot of other pieces of software.
>And what time frame is this valid in?
Right now.

Most if not all AAA game engines, crypto libs, web servers, video/audio codecs, operating systems are written in C. Entire internet works thanks to C. So thats important. But ofc jquery makes C obsolete according to you pajeets, or some rust/haskell lib noone will ever use in real world applications

>AAA game engines
sepples
The others are true though.

Yeah i noticed after i wrote that... I was thinking c++