/dpt/ - Daily Programming Thread

Old thread: What are you working on, Jow Forums?

Attached: 1557660740589.jpg (800x600, 80K)

Other urls found in this thread:

python.org/dev/peps/pep-0544/
python.org/dev/peps/pep-0526/
google.github.io/pytype/errors.html#invalid-annotation.
coolcodings.wordpress.com/2015/07/06/how-to-store-arrays-in-the-database-with-sqlite3-blob/
makeuseof.com/tag/beginner-programming-projects/
twitter.com/SFWRedditGifs

cute OP

i want to learn about compression
where do i learn about compression

You stole that image from me

It's called "information theory". I did two semesters on that. However since the other students already knew about compression, we did redundancy encoding instead. Say you have a space probe and you get only one try at transmitting data, you want to encode it redundantly so that it can be error corrected when it arrives on Earth. It was quite interesting, but mathematically very complex.

Anyway, to get you started, I suggest you look up "Huffman coding" on Wikipedia.

posting here is always a mistake. most people are mean and no information is ascertained. end up just raging quit some comment and referring to search engine results anyway. the pedo posters are amusing yet concerning.

thanks

Feel free to fuck off then

yeah, go back to your rust dilation blogs on reddit please, this board is for real languages and men with intact penises

I found "Data Compression: The Complete Reference" to be a good primer on different algorithms and techniques when I was writing my thesis in uni, though it doesn't cover the implementation at all and there are a shitload of tricks needed to make your compression fast. You can also read blogs by people who do compression stuff like cbloom or fgiesen.

Attached: ec8b4e198eab9b50c500d3927456e2f2[1].jpg (290x284, 20K)

I don't know why you're making so many assumptions about me in one post. Why did you suddenly conclude I was a Rust tranny?

>Data Compression: The Complete Reference
found a copy immediately
what's up with programming books and being pisseasy to pirate

I'm depressed

Are you seriously asking why books about computers are disproportionally available on the internet?

more asking why the people who write them, who are assumedly also good at computers, don't immediately get them taken down, when they're the second search result

Go watch some cute anime or some shit.

Attached: 60222946_p0.png (856x673, 480K)

Because it's futile?

publishers don't know that

I tried to make a qr code parser and I'm literally too much of a brainlet for this error correction stuff

Well you asked why the people who *write* the books, not the people who *publish* the books, don't try to get it taken down.

I suppose you can't just jump into the subject matter. You have to find the right course or book, and then it takes a while. But it's just math, so it's doable. You just have to have the right inclination of the learning curve to do it.

where do cs fags/Q&As hang out? here or /sci/mg?
both?

I'm young babby starting to learn JS for future courses I plan to take. What little projects should I take on to further my skill? Little things people would consider easy.

...

o shit. Thanks user

It's a solved provlem, right? I wish there was a library I could plug the ECC bits into and get the corrected output.

To what level of CS are you talking about? You're going to find people who have CS degrees here, but you're unlikely to find anyone doing any serious CS research or talking about very advanced CS topics.

My guess is there should be dozens of open source projects out there that have solved this problem one way or the other. I mean you practically can't take a five minute walk without stumbling over some QR codes anymore.

after shilling for pytype in the last thread, I added annotations to everything I could in my source file
every variable is annotated except for the ones in for/with blocks, because I ran into issues with that
I was using the right syntax according to the PEP, but was getting an issue about something not being a constant

Attached: Screenshot_2019-05-14 PEP 526 -- Syntax for Variable Annotations.png (665x412, 20K)

i thought type annotations did literally fucking nothing

I mean, you're right, they literally don't do anything
the interpreter completely ignores them IIRC
they're "hints" which is why they aren't enforced
pytype on the other hand is actually good
>static analysis
>enforcement of provided annotations (they actually do what they're supposed to)

Attached: Screenshot_2019-05-14 pytype.png (578x490, 37K)

if i learn
bash scripting
html
css
javascript
c
am i set for life? where do i even begin

Attached: 1446285802101.jpg (331x331, 52K)

>webshit
>bash
>C
>set for life
no

>html
>css
>javascript
You don't need to learn any of this shit unless you're a turbo-pleb.

that might actually make me mildly like python instead of hating it
how fast is it?

I won't lie to you, it isn't great, but it it isn't horrible
I'm not really sure if I could be a good judge of how fast it is since I've only used it for my memescripts and not a full/big project
it has bugs, so beware, but it does cross-file inference

I posted it in the last thread, but python's type system is becoming less shitty
>python.org/dev/peps/pep-0544/
>PEP 544 -- Protocols: Structural subtyping (static duck typing)

HTML, CSS, JavaScript -> web development. There's a separate thread about that on Jow Forums.
Bash scripting may be useful for server administration, but even that is mostly done with Perl and Python these days.
C is for fast low level and embedded programming.

Most real world problems seem to be solved in C++ or Java. There's "special" languages that confine you to a single OS and environment, like C# on Windows and Swift for Applefags.

which language should I use to teach my brother programming?

>Perl
What is this, 2005?
Also, shell scripting is still an extremely useful skill when operating on any Unix-like system.

C# is multiplatform via .NET core though

one thing about pytype though
python.org/dev/peps/pep-0526/
although PEP 526 allows for it, the "must be constant" error happens when this syntax
x: int = 0

or this
x: int
x = 0

is used instead of
x = 0 # type: int

so it's still kinda ugly and I hope they work on adding/fixing that
$ pytype script.py
Computing dependencies
Analyzing 1 sources with 0 local dependencies
ninja: Entering directory `/home/owner/.pytype'
[1/1] check script
FAILED: /home/owner/.pytype/pyi/script.pyi
pytype-single --imports_info /home/owner/.pytype/imports/script.imports --module-name script -V 3.7 -o /home/owner/.pytype/pyi/script.pyi --analyze-annotated --nofail --quick /home/owner/script.py
File "/home/owner/script.py", line 222, in : Invalid type annotation '' for board [invalid-annotation]
Must be constant

For more details, see google.github.io/pytype/errors.html#invalid-annotation.
ninja: build stopped: subcommand failed.

I don't think mypy has this issue, and it's also a static type checker, but pytype was cool because it automatically inferred types, and I didn't have to go gradually add them like I would've with mypy

Just in theory or in practice?
Like what's the Linux IDE and compiler called?

>What are you working on, Jow Forums?
Researching AVCC vs. Annex B h264 encoding formats.

Attached: 1501116933992.jpg (564x811, 55K)

I wish. There's zbar, zxing and a c++ port of zxing and they're all old as fuck, dead projects and have incomplete qr code support. Interesting stuff like structured append just doesn't work.

in practice, the .NET core sdk, which includes the runtime and CLI tools is available for windows, linux and macOS
why the fuck would you need an IDE to develop with a language in practice?

I'm a beginner with R
I have a "parallel lines regression" where the q1,q2,q3 are dummy variables for the quarters of the year.
lm(y ~ t + q1 + q2 + q3, data=shit)
If I want to make residuals plots, resid(), for a certain quarter, is there a simple way to only include every 4th observation or would it be best to just cut out the other quarters from the spreadsheet?

>trying to access certain bits in C
>every method that supposedly works online doesn't
>comparing it with my own ways just doesn't work either

What the fuck is going on?
I literally might just kill myself

How are you trying to do it? Also, is endianess a factor in any way (e.g. reading bytes from a socket/file)?

Sorry, user. Apologies for being late. Can we start writing JavaScript now?

Attached: ed57de8d5760bd09d24458c560aa116c.jpg (720x1061, 63K)

Disgusting abomination endorses JavaScript. No surprises there.

So if I have say, 0x10101010 I'm trying to take that and & it with 0x03 which should give me the last 3 bits, but it doesn't.
I just get 0x00000000
Not reading from a file or anything, just locally.
Pressed for time and a brainlet, just can't be doing with this.

install Elm

>last 3 bits
Two bits*

I just found about c(TRUE,FALSE,FALSE,FALSE) which seems to work well for what I wanted.

Hmm, just to make sure, can you post the code doing it?
There is an annoying "gotcha" in C (but compilers do provide extra warnings) where a bunch of the bitwise operations have a surprisingly low precedence, leading to unexpected results.
e.g. if you see
if (n & 0x3 == 0x0)
you'd expect it to be
if ((n & 0x3) == 0x0)
but it's actually
if (n & (0x3 == 0x0))

>0x10101010
That's hexademical. In binary that number is 0b10000000100000001000000010000

Is the tour of C++ updated for C++17 yet?

Attached: 5442097.jpg (721x960, 69K)

this, you would want
int n2 = n & 0xFFF

This doesn't work at all
coolcodings.wordpress.com/2015/07/06/how-to-store-arrays-in-the-database-with-sqlite3-blob/

>Let`s say we have a short array that need to be stored.

>short array[] = {-256, -6128, 127};

>Since sqlite3_bind_blob store the data as it is and it process the data in byte format, we can simply call the sqlite3_bind_blob as,

>sqlite3_bind_blob(stmt, 2, array, 6, NULL);

>To read the stored array from the database you can use sqlite3_column_blob function.

>short *myArray = (short*)sqlite3_column_blob(stmt, 2);

Wat do. The "array" I get is empty with length of 2.

Attached: 1421534938546.jpg (960x616, 61K)

Yes. The second edition covers C++17.

could it be because I use C or does pointers work exactly the same in C++?

How the fuck does your array have a length? Post all of your code. If I have to go to coolcodings wordpress then I can't be assed.

include
int power(int m, int n);
/* test power function */
main()
{
int i;
for (i = 0; i < 10; ++i)
printf("%d %d %d\n", i, power(2,i), power(-3,i));
return 0;
}
/* power: raise base to n-th power; n >= 0 */
int power(int base, int n)
{
int i, p;
p = 1;
for (i = 1; i

Is it possible to "live-edit" C code like in Clojure/lisp ?

> i still don't get why is "m" declared
It's not declared. It's nothing.

The variable names in pre declarations are optional and mean nothing. You can move the actual power function above main and get rid of the predeclaration.

you mean hot-swap/hot-reload?
I'm sure some solution exists.

Nice projecting. I've hated that cancer ever since they flooded /a/ and Jow Forums many years ago.

The names of the arguments of a prototype are meaningless from a language standpoint. They don't have to match with the names you give in the function definition. In fact, you can do it like
int power(int, int);
But they can give you extra information about how to call the function, so they're almost always added.

You could always inject into the process and modify the opcodes using a language like C.

Attached: sseccus.png (870x712, 64K)

I've heard of people doing shit where they continuously load/deload dynamic libraries to achieve something similar to that, but it's almost certainly not worth the effort.

you would need a C interpreter for that.

Just use the TempleOS HolyC shell.

Is pic related a good guide for c++ I know my basic concepts and have used a little bit of c in the past. Or is there some other source that would be more efficient

Attached: ShowCover.aspx.jpg (500x630, 86K)

>powershell has switch statements that work on strings
i want this

no
anything pre-2011 and anything too close to 2011 is worthless

Attached: date.png (239x26, 832)

What would you recommend then?

void main()
{
import std.stdio: writeln;
switch("dlang")
{
case "dlang": "already has this".writeln; break;
default: "uninstall c shit".writeln;
}
}

Powershell can be cool if you want it to be. Great for penetration testing on Windows boxes. Reverse shells, AD queries, Injecting binaries directly into memory, impersonating other users. It doesn't get much better than that. Too bad PS vectors are being blocked more and more by AV

Attached: scanmem.png (1600x1200, 1.09M)

read section 2.1 from CSAPP top to bottom

The book I'm currently writing. I made sure to write it in a post-2011 style.

i don't really know, I just bumbled my way to understanding C++ via the blogs on isocpp.org, random books (effective modern C++ is pretty good), and asking /dpt/
afaik there's no one comprehensive resource, and there's a lotta misinfo out there

i should probably add that effective modern c++ is made for someone who already knows pre-2011 c++, so it's not really a beginner's resource

Guys, can you help me out?

I'm trying to plot two dataframes in one figure using Pandas boxplots. I want to have the boxplots side be side, but instead they're always stacked.

This is what I've been doing:

ax = dataset0.plot(kind='box',rot=75,color='red')
dataset1.plot(kind='box',rot=75,color='grey',ax=ax)


It ends up looking like pic related...

Attached: Capture.jpg (373x339, 16K)

...when what I want is this (pic related).

Attached: HgPFB.png (424x280, 5K)

Welcome to the 20th century.

Is there anything simple I can do to adjust it correctly, without changing the way the data is stored first?

Erm, 21st century. Hehe.

Here's several ideas:
makeuseof.com/tag/beginner-programming-projects/

>neural networks
So does anyone even understand how this shit works?

I suggest Acchi Kocchi and Drifters.
Really got my spirits up to the point where I'm willing to read C/C++ books, and that is saying a lot.

gradient descent

It's a race as to who can get the first robot to wipe out all of humanity in the instant it is smart enough to understand that none of us deserves to exist.

I wish that moment to arrive soon

Can't it wipe us out with cute robot waifus instead?

>the group who make the superior being don't deserve life
where's the logic in this? It's like the scientists who want to kill the guy who figures out FTL travel.

the problem is modern academics are retarded outside of their specialised area, e.g. look at how totally retarded 99% of non-history profs are when it comes to history or politics

You wouldn't like haskell anymore if you had to use it at work

A truly superior AI would figure out a way to reason with even the most unreasonable person and progress humanity that much further. That's why i really don't buy all these grey goo doomsday shit.