/dpt/ - Daily Programming Thread

Previous thread: What are you working on, Sup Forums?

Other urls found in this thread:

h-schmidt.net/FloatConverter/IEEE754.html
en.cppreference.com/w/cpp/utility/hash
pastebin.com/vqB3Dy7T
pics.r18.com/digital/video/1{0}/1{0}pl.jpg
pics.dmm.com/mono/movie/n/now_printing/now_printing.jpg
pics.r18.com/digital/video/1STAR00486/1STAR00486pl.jpg
pics.r18.com/digital/video/1star00486/1star00486pl.jpg
r18.com/common/search/searchword=
twitter.com/NSFWRedditVideo

Lisp is the most powerful programming language. Mathematics is evil and wrong.

give me a fucking tool i can use to truncate a decimal number so that it has the minimum number of digits required for the compiler to uniquely identify the 32-bit floating-point number closest to the decimal number entered.

h-schmidt.net/FloatConverter/IEEE754.html

btw use the +1 -1 buttons on the right to get the closest number you're looking for.

/dpt/ - Dead programming thread

This isn't /dpt/, look at the OP image

What does it have to do with programming?

Lmao there isn't even a predicate for an empty vector.

I'm working on some functions for making graphs (the vertex and edge kind, not f(x) = ... kind), as part of another project.

What is the correct way to construct a hash function for an unordered_map in C++?

what is null
dumbass

en.cppreference.com/w/cpp/utility/hash

Thanks buddy

How do I read a specific column of text from file, in C?
Like
Bytes: 01001011 Symbol: &
Bytes: 01110101 Symbol: W
...


I need to get &, W, and so on. How?

sscanf

>c
Stop using unsafe code, user

How stupid would it be to get around POSIX shell's inherent lack of variable scope by devising a pushdown automata as a sort of stack to create stack frames and, naturally, maintain continuity in all the scopes above the one I'm currently in?

I hear javascript doesn't have any sort of lexical variable scope either, should I try doing this in javascript first?

Oh, thank you.

C++/Qt Widgets
upload limit is 3mb so i couldn't show you all the features.

Do it in Common Lisp. It has lexical and dynamic scope.

What's wrong with a text file?

How much of this is actually qml?

custom progressbar is the best thing i've ever made. look at how beautiful it is.
none of it is qml. i didn't use qt quick.
i don't even know desu, wasn't trying to make anything useful.
it has statistics though.

>Eats for 1 hour straight, no breaks
>Swims for 8 hours straight, no breaks
lol hax

I am doing something.
How would I go about getting the coordinates out of those?

what language

Java.

nice theme but the scroll bars are annoying

i dont get what you are trying to do . Post the full class code, so i can help you out.

That's pretty cool user

pastebin.com/vqB3Dy7T

So your "xy" stands for some value in row X, and value in column Y right? You need to loop through your 2d arrays using double for loops. Sorry I'm on my phone, so something like this.

for(rows here){
If(value at row == x){
Stop we found our x.
Save x row value.
for(collumns value){
If (value at collumn == y){
Stop found our y
Save y to some variable
Now you know which row and collumn to has xy

>tfw to smart to understand file serialization in c#
pliz help im a newb

also why is working with files so cancer
i hate it

>Interface transposes the x and y axis when it applies changes to the model in the background
>similarly when using the undo or redo to change the model and sync the interface to the model it transposes them back
>everything else that converses directly with the model had it's shit fucked up

Two wrongs don't make a right but they make it hell of a time figuring out what's wrong.


My question to you /dpt/ is if undo is ctrl + z, should I make redo ctrl + y, or shift + ctrl +y?

If you're still here can you post the source code?

the fuck is that

Redo should be both ctrl shift z and ctrl y. It's always annoying when using a program and doing one only to find out it's the other.

Ctrl + y. Keep them paired with x and y

An user made a spambot

It's not a spam bot. He did that by hand. How do u even bot, against a captcha? even if he uses a Sup Forums pass, there is anti spam/post limit in Sup Forums already.

I think you are right, I'll make it both. No that my program will have so many shortcuts that I'll be missing some of them.

Look at the post times . He probably did something similar to delayclose

I just looked at the time stamps. That's pretty interesting. I dont know how he's doing it, I thought it was impossibe

>I thought it was impossibe
lmao go check
for the impossible

There's a bot that spams /gw2g/ threads for months now, mods have admitted to rangebanning nearly 170 ranges in an attempt to stop it, but it's still going full ham.

hey /dpt/ I have a php job interview tomorrow. What are your tips to get employed?

I can't rely on autismbux forever.

That's pretty quality

Very nice

write a fizzbuzz on the whiteboard

>tfw you almost fell for the programming job meme

for($x=1;$x

>practice basic programming interview questions
>practice basic PHP interview questions
>just b urself
>good luck

Sorry, you couldn't close your code tag properly, so we cannot trust you with a job.

PyPleb here.

Why am i only getting pic related instead of the actually cover image, that i get from inputing the URL manually into my browser.


import urllib.request

url_template = "pics.r18.com/digital/video/1{0}/1{0}pl.jpg"
user_input = input("Enter a movie ID (eg. STAR00486) :")
url = url_template.format(user_input)
print(url)
urllib.request.urlretrieve(url, "{0}.jpg".format(user_input))

They probably test for user agent

can you use headers with urllib.request?

that makes me perfect for a php job!

>Python
Who fucking knows. Literally any decent library in any other language would let you set this stuff. Python is a flaming pile of trash though so don't expect anything. People who programming to do don't use Python. Python is for nongrammers who have to make a computer do something without knowing a fucking thing about what computers do.

It pisses me off how simple this HAS to be, but i end up going in circles with conflicts out the ass no matter what i try.

Cookies, sessions and login probably.

When I go to pics.r18.com/digital/video/1{0}/1{0}pl.jpg I get redirected to pics.dmm.com/mono/movie/n/now_printing/now_printing.jpg which is precisely this Now Printing icon. You've clicked the "I am at least 18yo" in your browser haven't ya? It probably created a cookie you'll need to send along in the Python script.

>Literally any decent library in any other language would let you set this stuff.
And urllib perfectly lets you do it. It's ok not to like Python-sensei fampai, but if you want to criticize him, try having actual arguments.

Yes. Use add_header("User-Agent", whatever the fuck).

I meant pics.r18.com/digital/video/1STAR00486/1STAR00486pl.jpg

Just tested it and it works fine:

import urllib.request

urllib.request.urlretrieve("pics.r18.com/digital/video/pppd00383/pppd00383pl.jpg", "test.jpg")

So my guess is that your generated URL is wrong

I still get a printing icon from that URL in my browser.

Me too that's the point

>It probably created a cookie you'll need to send along in the Python script.

Shit, that's way beyond me.

Any hints on how to progress?

Dunno. I don't go on r18 so I took 's word as to where the image lives.

Yeah, so did I but see . The URL just seems wrong

weird, any idea what's wrong with my generated URL?

As an example i'm trying to retreive the cover for STAR-486

The "real" URL is pics.r18.com/digital/video/1star00486/1star00486pl.jpg

So just try to make your movie ID small caps (lower() in Python)

Ok got it now.
*/1STAR00486/1STAR00486pl.jpg
doesn't work, but
*/1star00486/1star00486pl.jpg
does work

Yeah, that was it.

But now i noticed that their site seems to generate a random Char before the movie ID like the 1 in 1star486.

Is there a way to make sure my script takes that into account?

Rate my true unix $wc, losers
import std.stdio;
import std.string;

void main(string[] args)
{
if (args.length > 1)
{
calculate_words_in_files(args[1 .. $]).writeln();
}
else
{
int word_count;
string input;
while ((input = stdin.readln()) !is null)
{
word_count += input.split().length;
}
writeln(word_count);
}
}

int calculate_words_in_files(in string[] file_paths)
{
import std.file;

int word_count;
foreach (file_path; file_paths)
{
auto current_file = File(file_path, "r");
string current_line;
while (!(current_file.eof()))
{
word_count += current_file.readln().split().length;
}
current_file.close();
}
return word_count;
}

user0@primary:~/devel/proj/test-d$ echo abcdef ghijkl | ./wrdc
2
user0@primary:~/devel/proj/test-d$ ./wrdc wrdc.d
69

It's fucking shit.

Why?

It's written in deadlang.
I don't like your bracing style
There is code duplication
It's very inefficient

>It's written in deadlang.
More active than ur mum's git repo, loser
>I don't like your bracing style
Suck my cock too
>There is code duplication
I'll give you that
>It's very inefficient
I won't give you that that

Why do you waste your time writing primitive programs in a dead language?

That an answer to my question

0 for using a dead language but +10 for using a cute akarin image so 10/10

>dead language
More alive than your penis in the heat, loser

what do you mean by this

> input.split().length;
> for each word in each input line the code creates an instance of String on heap and copies the word from the input line to the new instance only for it to be counted and then take up space until the GC collects it
So... this is the power of D....wow

Uh? Why would GC run in the first place if you are not running short of memory?

That's my point, these totally unnecessary objects will be taking up space for an unspecified amount of time. Or, and you'll be running short on memory if you count big enough files, because of all the garbage split().length generates.

If it is truly random just would have to bruteforce it. Otherwise you can retrieve the right id from the search: r18.com/common/search/searchword=

So instead of deleting the garbage each time it's created you kill them periodically

>.readln().split()
disgusting

#include
#include

int word_count(FILE *f) {
int c, prev = 1, count = 0;
while ((c = getc(f)) != EOF) {
if (isspace(c)) {
prev = 1;
}
else if (prev) {
prev = 0;
count++;
}
}
return count;
}

int main(int argc, char *argv[]) {
int count = 0;
if (argc == 1)
count += word_count(stdin);
for (int i = 1; i < argc; i++) {
FILE *f = fopen(argv[i], "r");
if (f == NULL) {
fprintf(stderr, "Error opening file '%s'\n", argv[i])
continue;
}
count += word_count(f);
fclose(f);
}
printf("%d\n", count);
}

Right, I know how GC work. The problem is, you don't need to generate any garbage at all here, see .

>doesn't compile

This is fully standard C89 fyi, it's normal that dmd does not want to eat it since it's not shit.

>This is fully standard C89 fyi
So did C break backwards compatibility? How sad

>This is fully standard C89
You're missing a semicolon on fprintf.

Rite, missing semicolon. That was difficult to figure out wasn't it?

So doesn't compile then. Why are you dumping your shit here?

>D-sucker bitching about backwards compatibility
So ironic

Gosh, D-fags are so pathetic.

(samefag)
Are you just mad that you can't even write a program that compiles?

Woah! Good job, now i want to learn qt too

I'm not but here's a fixed version just for you retard.
#include
#include

int word_count(FILE *f) {
int c, prev = 1, count = 0;
while ((c = getc(f)) != EOF) {
if (isspace(c)) {
prev = 1;
}
else if (prev) {
prev = 0;
count++;
}
}
return count;
}

int main(int argc, char *argv[]) {
int count = 0;
if (argc == 1)
count += word_count(stdin);
for (int i = 1; i < argc; i++) {
FILE *f = fopen(argv[i], "r");
if (f == NULL) {
fprintf(stderr, "Error opening file '%s'\n", argv[i]);
continue;
}
count += word_count(f);
fclose(f);
}
printf("%d\n", count);
}

Now can we get back to 's point?

A missing semicolon is better than the inability to implement a trivial program without shitting all your memory with unnecessary objects.