/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Last thread:

Attached: 1447484727492.png (1200x1800, 1.3M)

Other urls found in this thread:

youtube.com/watch?v=0GYvLyfa0Lg&t=134s
postgresql.org/docs/11/functions-xml.html
notes.shichao.io/lkd/ch6/#the-linux-kernels-implementation
twitter.com/SFWRedditImages

Thank you for using an anime image

Attached: 1549655959572.png (596x720, 436K)

these waifus are awful

that's because Haskell isn't there

Attached: 1542523277131.png (850x1200, 938K)

much better

God I want to take JavaScript out on a date to a trendy cafe.

I've been programming for a few years but I never bothered really learning anything about time complexity. Is there a go-to book about it?

Perl is the cutest. Too bad she's obsolete.

No, because it's not a very difficult concept in itself. You'll proably find a lot of resources in most good algorithms books because they'll talk about how to prove or reasonably bound running times of certain classes of algorithms. I don't know why you quoted me though.

I need to capture and record a serial data stream that moves a little bit faster than my storage medium. The ones always have between two and ten zeroes between them. Is there a way (besides leave off two zeroes from every group) to compress this data cheaply? Should I look into RLE algorithms or Lz77?

>139cm 31kg
just imagine

I'd do japanese things to ruby with many other men in a circle

Re-asking for this question, I basically wanted to make a /dev/fizzbuzz char device that's seekable but I can't figure it out.

Can any of you mathfags please tell me if this is possible without generating a fizzbuzz and counting the bytes. My only thought is to just guess and refine.

Attached: 1550905209391.jpg (1280x720, 109K)

>Favorate language has best antro (C#)
This is great, these things never line up for me

Beginner programming student here. Today one of my classmates was complaining that he couldn't figure out why this didn't compile:

#include

void isfortytwo(int x);
void isfortytwo(int x);

int main()
{
std::cout

how the fuck do you reset something every 5 seconds

You mean like f(n) should return the nth char of 12fizz45buzz... In constant time or
what?

Yeah basically but with the newlines too. It doesn't have be a closed formula but is there any better way than just basically brute force?

Set a timer for 5 seconds. When the timer is finished, do thing. Repeat.
The nature of what a timer might work depends on the event loop of your program.

s/what/how/

Java is 22
C++ is 34
Python is 25
Ruby is 22
PHP is 24
C# is 17 (legal age in NY)
JavaScript is 23
Perl is 32
C is 49 (a milf, I guess)
Visual Basic is 28
R is 19
Scala is 15 disgustang
I cannot read what it says for shell. I don't speak moon.
Action Script is 19.

This shit is gay.

if this helps
15x+1 .. 15x+15
15x+1, 15x+2, Fizz, 15x+4, Buzz, Fizz, 15x+7, 15x+8, Fizz, Buzz, 15x+11, Fizz, 15x+13, 15x+14, FizzBuzz

why isn't there a gravestone where ActionScript is?

Wow it's almost like that pic is 6 years old.

Shell is "unknown"

>I cannot read what it says for shell. I don't speak moon.
It's age, star sign, blood type: unknown.

The number of digits in each pure number will mostly stay the same except when you go up an order of magnitude, e.g. 1s -> 10s -> 100s
Should be log10(15x)
At the very least I think you could calculate it for each of those brackets, you can probably get log time. Maybe.

I can't see a nice way of doing it, since 10^n isn't divisible by 3. Best I think you can do is
>A function to get approximate which term, t, you are on based on fact that term t has floor(log(n)) degits, and every 3 and 5th term has 3 and every 15th has 6.
>Calculate how many many chars are in the first t terms (should be relatively easy)
>Check how close to input you are, then adjust by calculating any remaining terms in full.

I kinda get it, the idea I'm thinking is now to make a pregenerated table of offsets with the correct line number. Few from the 2-6 digit numbers and several from the long numbers and go from there. Say I had 2^14 entries.

Assuming nobody ever needs more than 4GiB of fizzbuzz, so 32-bit offset. The time-space tradeoff should make seeking reasonable right?

Not an answer, but ignoring fizzbuzz and newlines, so it's just 1234567891011121314..., The formula for the nth degit is

a(n) = (10^((n + (10^i - 10)/9) mod i - i + 1) * ceiling((9n + 10^i - 1)/(9i) - 1)) mod 10

With

i = ceiling( W(log(10)/10^(1/9) (n - 1/9))/log(10) + 1/9 )

Reminder that if your language doesn't allow you to do this, it's not a real language and has limited use in real applications.

Attached: Screenshot_2019-02-27_21-23-50.png (516x70, 8K)

C# 8 and Scala are fine imho.

C# is a slut and anything that you do with her, John Skeet will already have done with her before you.

i don't think you need nearly that many entries, i think you only need 1 entry for every time you change digits, including the previous sum and which part of the fizzbuzz cycle you're on

I don't understand why that needs typeof or that ({ }) thing.
Wouldn't
#define container_of(ptr, type, member) \
(type *)((char *)(ptr) - offsetof(type, member))
work just as well?

I just found out .net core is still a piece of unfinished shit

Attached: 1534712975210.jpg (1200x1153, 48K)

I wish there was a cute scheme waifu.

There's like a million of them.

Attached: 1548911708055.png (760x720, 439K)

It's typesafe, unlike your version.

If you have a lot of stuff in a Python module, which is the preferred way?
import mod

mod.c1
mod.c2

from mod import c1, c2
c1
c2

from mod import *
c1
c2

Google style guide says first but it can be tiresome if you're deep into a project and have to do shit like project.something.mod1.c1, especially when in an actual project identifiers will be much longer.

made some decent progress today, only got to work for about an hour though

>expecting anything more from microsoft
c'mon now

You threw type safety out of the window the moment you decided to cast pointers.
I'm not aware of any additional kinds of type errors that the extension version is going to pick up.

>Unfinished
What's missing?

The best practice is probably
import my.big.module.name as name
unless name is excessively long, in which case you can use
import my.big.module.name as n.

Actually, now I can see what it actually does.
It'll eliminate this:
struct s {
int a;
float b;
};

float *f;
struct s *s = container_of(f, struct s, a);

Do modern versions of Python warn you when you import * conflicting names from two different modules? If not, don't do that.

Just import the entire namespace under an alias, cjshd.jjjs.ksjchjs.jsjhd as jj, then use jj.func1, that way conflicts of multiple jsjhd are resolved by deving g it as jj1 and jj2 for example.

Python doesn't warn you of anything, it will assume whatever you are doing is on purpose. Some ideas propably has this feature though.

please be more specific

>Some ideas propably has this feature though.
What?

The assignment isn't cast, and ptr being the wrong type will be caught at compilation time.

What. I'm sure pycharm does it.

Oh, IDEs. Sorry, I failed to interpret the typo.

>
Alright... I implemented a semispace GC and it's about 20% slower than the naive mark-and-sweep. If all objects are immediately destroyed, though, it's faster. I think I'll leave it in the repository as an alternative GC, since it's also about 1/3 the amount of code, so it's "hackable," as people like to say... Still, it's not as slow as I thought it would be. I think if it were generational, even with one generation like Chicken, it would be closer...

What's the proper way to consume an api with token authentication (in C#)?

>Move around password using SecureString
>Send login request and get token
>Send token in subsequent requests
Where do I store the token? Just as plain text somewhere in a temporary file if I don't want to have to log in every time I launch the application? If I don't care about staying logged in when the application restarts do I the token in just a string, or should it also be in a SecureString? I'm not sure how secure you need to be with a token.

Why do you even need to write a GC to begin with?

I want to take any girl, real or fictional, on a date anywhere ever

I'm writing a code generator for SQL queries. Basically, I have to parse an XML for a specific elements. If the className (an attribute) is equal to a a table name, then I write a specific SQL query for it.

Problem is that this unstructured piece of shit XML is like 18k lines long and it has given me the biggest goddamn headache ever.

You might want to index the XML file in a first pass. Get the higher level tags, maybe grab a single piece of data, but I'd expect it to have a large number of the same types of values.

web API, private program or a program to be published?

Program that will be used by a hand full of poeple in a company to access the companies web api from home so they can work even on sick days / holidays.

What XML library you use?

post what you like to work to youtube.com/watch?v=0GYvLyfa0Lg&t=134s

What about using something like this? Specifically 9.14.3.3
postgresql.org/docs/11/functions-xml.html

I'm writing an interpreter for my graduate thesis and one of my stated goals is competitive performance

Except it doesn't work that way. Whichever module imports the version first is the one that gets used because python doesn't do tree dependencies.

The answer is to make the users login each time and create a token on every run.
Worrying about security when dealing with authenticated requests is really pointless since anyone with access to the computer can view the memory or disassemble the program to see how it is done.
If you really want to store the auth, use DPAPI (maybe PGP is the linux alt?) This makes it harder to access than plain text but not compeletly secure.
You can also ask them to provide a password to de/encrypt the token instead of inputting creds on every run.

>so they can work even on sick days / holidays
the ride never ends

wondering why i installed void linux

no warnings for implicit conversions

If you want to get payed you need to be willing to actualy work.

ruby a cute, isn;t ruby a meme though? i met some guy at a programming club who came in to mentor us his job was converting ruby projects into php

I'm just going to make them log in every time.

Trying to implement a Reliable Total & Casual ordered broadcast in Java for a school assigment, but having trouble.
Been trying a centralized approach and also a distributed approach(ISIS-algorithm), but debugging this is hell.
Kill me.

Attached: 32349869_387301475097424_4080939987489521664_n.jpg (720x513, 21K)

Yeah; it's totally dead. It's a cute language though.

Is getting a job in programming without a degree possible or should I just learn web dev? I don't have a job right now and need to learn one of these fuckin things.

ruby is like another python but obviously python won. A lot of the ruby code out there is Rails, Rails was a fad in webdev and it's mostly dead now so I guess some people are jumping ship.

I've never used Ruby, but...
There are still (capable) people who turn to Rails when they need a straightforward web app that fits the Rails formula.
Elements of Ruby have found new life in other languages like Elixir and Crystal.

I wouldnt say its dead. Plenty of rails programs out there and still a good amount of jobs. Definantly dieng. Although, a JIT is in the works which I think could revive the language.

[spoiler]I'm doing a personal project on my wage hours[/spoiler]

The JIT approach they're taking isn't very elegant but I guess if it works, it works

make sure you read your contract if you're an americuck or work for an international company, it's not uncommon for them to have a clause in the contract that says something like "any [programming] project you make while employed by the company belongs to them"

this is worse than any sepples i've ever read

I agree with you which is why I said it could. I really hope it works tho. I hate having to learn the new javascript framework of the week ever week.

thanks for the concern, friend.

Here's how it's used.
notes.shichao.io/lkd/ch6/#the-linux-kernels-implementation

fuk u dats my waifu uwu

That only matters if they find out. My company has this bullshit thing where any code you work on, doesn't matter if it's in work hours, belong to the company.

God, I fucking love this haskell tiddie monster

good call

this is bait, but change the return type of your function definition (line 3) and remove the duplicate line after it.

Also you can use std::boolalpha to make your true/false output more human friendly.

Example:
std::cout std::boolalpha

If you're debugging your entire program, stop. It's pointless simply because there's way too much to keep track of. If debugging requires some manual input from you, stop even more.

Ensure your structure is clean and doesn't mix functionality.
Write test cases. Debug those.
Use mock objects liberally to hide complexity and allow testing of functionality in isolation.

With that you can debug small parts, avoid a lot of pointless tedium and also only have to focus on these small parts.

The creation of debuggers is literally what caused the modern explosion of shitty software, people know just write any shit without thinking with the stance that if there's something wrong the debugger will find it eventually and thrill fix it then. Debuggers should be completely disabled outside of tests.

I don't know what to make

What's a good programming language to learn if you are a woman?

Haskell will accentuate your feminine features.

Hey, I'm in school now and learning to code, but my exposure to other languages besides Java is pretty limited. I'm not gonna pick up a language on my own in the middle of a semester, so what would be a quick and simple way to learn what each of the basic differences are?

On the same subject, but is the best method to learning anything related to CS? Like, what are the different job opertunities for different skill sets? What makes someone a good Dev vs sys admin? I feel real overwhelmed trying to enter this world, but real excited about all the opportunities. Plz Jow Forums, help a poor neet niggah learn.

>if you want to get paid you need to be willing to actually work
>even when you're contractually supposed to not be working

Attached: 1549921025340.png (500x545, 130K)

Anglos are so mentally broken that they will unironically defend shit like this. It's even worse in programming. You don't want to do 40 hours of unpaid over time?