/dpt/ — Daily Programming Thread

Previous >what are you working on, Jow Forums?

Attached: vlcsnap-2018-03-19-03h08m08s069.png (1280x720, 976K)

Other urls found in this thread:

youtube.com/watch?v=ACSTDof8QL0
google.ca/search?q=change vim paren colors
libcello.org/
github.com/spullara/mustache.java.
twitter.com/NSFWRedditImage

I'm sorry, but you seem to have posted the wrong op picture.

?

Why are you guys so obsessed with japanese cartoons?
Just let it go already

i want to fug nenecchi

whats the most redpilled programming language?

Attached: 1478387598018.jpg (1024x819, 187K)

So I have a collection of large PNG images that I have to share regularily but since they're 100-200 MB each due to high res, I wanted to downscale them to, say, a maximum width/height of 2k for sharing purposes. Can someone just double check on what I'm doing to make sure I don't end up with fucked up proportions?
image = Image.open(os.path.join(root, file))
(width, height, ) = image.size
(new_width, new_height, ) = (width, height, )

if width > 2000:
new_width = 2000
new_height = math.ceil(height * (2000 / width))
elif height > 2000:
new_width = math.ceil(width * (2000 / height))
new_height = 2000

image.resize((new_width, new_height, )).save(os.path.join(OUT_PATH, file))

no, I didn't :^)

anime website

the one you've settled on after using at least a dozen others

compress them retard

Doing polymorphism in C is really retarded.
Most of the memory required by the object is consumed with function pointer

Posted this before at bump limit
Been trying to find a decently efficient solution for this algorithm with no success. Looks NP complete to me. My shitty brute force algorithm takes ages on my craptop.

>you are given a list of numbers within the range 1-20 and an integer k.
>find the maximum possible size of S, where S is a set of pairwise-disjoint subsets of the list, and every element of S sums to k.

Is ther a good library in Java for doing advanced String interpolation?

Something like:
"There are {count(var)} keys:
{printlist(keys)}"


The strings would be dynamic, which is why I can't just declare a couple of vars before hand.

Already batched them through optipng but I cannot zip then, they have to be uploaded as is.

>pairwise-disjoint subsets of the list
uhhhhhhhhhhhhhh
does this mean tuples of 2 numbers taken from the list

not possible but you can do something like
("There are {%count} keys:
{%printlist}", var, keys)

It's just a fancy word for tuples of n numbers taken from the list and there should be no overlap between the tuples.
So from the list [1, 2, 3, 3, 4] you can take out (1, 2, 4) and (3, 3)

Wait, does that apply a function to the variable?

This would be so much easier in Python or Ruby.

Alright I think I get it, I'll try making my own shitty bruteforce algorithm

no its a function that returns a string and i just left out a name
the function would be
String format(String fmt, Object... values)

>polymorphism
If you're trying to call a function and you don't know which one you want to call, you haven't done your analysis correctly.

Retard

just use one pointer to a table of function pointers
embedding the function pointers in the struct itself is only necessary if you plan on rebinding methods.

Assembly. Learn that and you'll see how fucking inefficient the code most people write is.
It also gives you a perspective on which features and concepts in high-level languages are actually useful and which ones are actually just unnecessary crud that is more trouble than it's worth.

Also, the most Jewish programming language is (((Common Lisp)))

"C_Cpp.default.intelliSenseMode": "clang-x64",
"C_Cpp.intelliSenseEngine": "Default",
"C_Cpp.clang_format_style": "Google",


VS Code
Why linter no linting?

Attached: Screen Shot 2018-07-09 at 6.12.40 p.m..png (624x129, 21K)

public class MyProgram {

private class SomethingString {
}

public static void main(String[] args) {
SomethingString str = new SomethingString();
}
}

On This case SomethingString must always be a static class?

Exercise 3-1 of the K&R book asks to write a function that copies string s into string t, while converting any instances of "\n", "\t", "\a", etc. into their single char (non-visible) representation. In any case, am I allowed to increment i in the switch? Given that s[i] == '\\' HAS to be evaluated first, I would think that this is allowed. However I'm not sure.
void escape_reverse(char s[], char t[]) {
int i = 0, j, g;
for (i = 0, j = 0; s[i] != '\0'; ++i) {
switch ( (s[i++] == '\\') ? s[i] : -1) {
case 'n':
t[j++] = '\n';
break;
case 't':
t[j++] = '\t';
break;
case 'v':
t[j++] = '\v';
break;
case 'b':
t[j++] = '\b';
break;
case 'r':
t[j++] = '\r';
break;
case 'f':
t[j++] = '\f';
break;
case 'a':
t[j++] = '\a';
break;
default:
t[j++] = s[i];
break;
}

}
t[j] = '\0';
}

>what are you working on, Jow Forums?
Killing myself.

Whenever I have to deal with HTML, JS and CSS I really miss the time I used to write Delphi/Borland C++ for a living.

Attached: DP8HAPGUMAAQV4F.jpg (1200x886, 91K)

As a side note, the function works on my machine, however I did not know if this was because I got lucky in how the compiler decided to handle the conditional expression.

>can't handle rust
go back to python you pussy, you are not fit to be programmer. Klabnik was right, only 1% of people like me are fit to program and we prefer rust naturally. Enjoy your fucking buffer overflows shitters.

Been messing around with the dynamic memory subsystem of my pet OS.
The biggest changes are:
1. The page allocator now allocates its own memory
2. I introduced a fine-grained userland allocator (based on liballoc), which allows faster and more granular memory allocation (i. e. Does not allocate 4K pages for every little malloc).
There is a small caveat to point 2, that is, the kernel still uses the page-level allocator internally, and indeed some syscalls return coarse-allocated memory areas, which must be handled by *_coarse primitives, bypassing liballoc.

probably javascript. its the language that the web is written in, after all! that's what my intro to programming professor said in first semester. :) :) :)

void foo(struct foo_data *d, struct foo_ops *f)
{
f->bar(d, f);
}

foo_data contains only the raw data (fields).
foo_ops are he function pointers (methods).
This is even more powerful than C++ or Java style polymorphism because you can easily swap in a different set of behaviors whenever you want (effectively changing the 'base class').

Damn that sounds cool. Godspeed.

How do you write pointers, /dpt/?
A) int *foo/int *const foo
B) int* foo/int* const foo
C) int * foo/int * const foo

I use A, but I see B pretty regularly, too.

Kotlin and groovy use a syntax very similar to that
"There are ${count(var)} keys:
${printlist(keys)}"

Attached: 1422546788638.jpg (680x400, 50K)

Why are Java programmers generally so dense?

Thank you!

I prefer Idris, Haskell in a pinch

const T *v in C and T const* v in C++.

I keep seeing you around here lately. You're pretty good. Keep it up and you may find an invite to the /dpt/ private channel in your inbox.

I use B since it's clearer that int is a pointer, the type doesn't get mixed with the id.

>/dpt/ private channel
uwu

Generally speaking, in C, if it compiles it's allowed. What you're doing isn't dependent on any compiler-specific extensions to the language

It's pretty fucky, but sadly C was never really designed with polymorphism in mind. I kinda wish a compiler would come along that was willing to throw backwards/sideways compatibility to the wind for the sake of adding some features like that.

If it's a situation where you can get away with using generic types instead, and you're using GCC/a compiler with the GNU 11 extensions, you can use _Generic() and/or typeof().

Attached: tumblr_p5ssfnGqBZ1vp4m0do1_500.jpg (500x694, 57K)

foo: *mut T/foo: *const T

>>/dpt/ private channel
>uwu
I feel bad now, there's no such channel (well, there might be a discord but it's bound to be garbage). I just wanted to cheer you up user. Also
>uwu
What's this?

var dickp: ^TDick;

>I feel bad now, there's no such channel
well what the fuck, let's make one

people say rust's syntax is shit but this level of specificity and general lack of edge cases in its type system is actually pretty nice

Attached: 1528470160361.jpg (817x880, 305K)

Have you tried Idris or Agda?

How many images do you have of that character?

B, because it's a pointer to an int. While I will accept & maintain code written by A's, C is completely unacceptable and there's no logical reason to declare pointers like that

R8 for each road going towards destination:
if road_allows_big_rig:
push road to map
set map[road][length] = road.length
set map[road][delta_towards] =
squareRoot((destination.X - road.X)^2 + (destination.Y - road.Y)^2)

for each road in map:
for each other_road going towards destination,
where (other_road.coordinates / ((pi*(road.length/2))^2 * scale) as circle):
if road.coordinates in circle:
if other_road.delta_towards < road.delta_towards:
map[road][roads_in_front] += other_road;
else if other_road.delta_towards > road.delta_towards:
map[road][roads_behind] += other_road;
if destination in circle:
map[other_road][leads_to_destination] = true;

for each road in map where roads_behind == null, road_counter, route_counter:
start:
if (road.leads_to_destination):
set routes[route_counter][path] += destination;
set routes[route_counter][distance] =
{
distance = 0;
for each road in routes[route_counter]:
distance += routes[route_counter][road].length
return distance;
}
route_counter++;
road_counter = 0;
continue;
else if road_counter == 0:
set routes[route_counter][path] = road;
else:
shortest_road;
for front_road of road[roads_in_front]:
if road[roads_in_front][front_road].index == 0:
shortest_road = front_road;
else:
if shortest_road > roads_in_front:
shortest_road = front_road;
routes[route_counter][path] += shortest_road;
road = shortest_road;
road_counter++;
goto start;

B

I've finally (mostly) completed How to Design Programs. Neat book: I think it's perfect for someone computer-savvy who took maybe one programming class in their life. Probably not ideal for a true beginner for self-learning, and it's a lot less "magical" than what I perceived from SICP (although, it builds up to SICP's stuff by eventually incorporating a lot of math and even teaching you how to make a basic interpreter). I do like that it makes clear the different types of recursion, but accumulators probably shouldn't be such a late (and apparently optional) topic, considering their usefulness.

Anyway, off to learn more Racket.

mental illnes

How is Racket as a Scheme?

Any Angular webfags in here? What's your preferred syntax for subscribing to an Observable?
A)
this.service.Get().subscribe(ret => {
this.value = ret;
}, err => {
console.log(err);
}, () => {
this.SortValues();
});

B)
this.service.Get().subscribe(
ret => {
this.value = ret;
},
err => {
console.log(err);
},
() => {
this.SortValues();
});

C)
// Other?

no one wants you here

Finished my vim theme "DevMT" inspired by psychadelic art. Pls rate and suggest improvements.

Attached: DevMT.png (738x420, 48K)

I'm not too certain, and I'm definitely not qualified to give a great answer. But from what I've gathered, it hews more towards the R6RS side of things (indeed, one of the members of the PLT group had input on R6RS and was highly positive to it). So, between that and just taking a look at what's in its standard library/modules, it's not small and certainly doesn't try to be.

Racket does a couple of "nonstandard" things: lists are immutable by default, whereas they're mutable in Scheme. And, as mentioned, it incorporates a lot of extra stuff: an interesting one is pattern matching.

Performance-wise, Racket is pretty good, being closely behind Chez/Gambit. And personally, I think Racket's documentation is pretty great.

The biggest thing is that, if you create Racket programs with the Racket mindset, it can be a little awkward going to a a more implementation-agnostic Scheme style. You can write R6RS Scheme (by using "#lang r6rs" and then crafting the file as you would normally), but Racket otherwise doesn't *force* you to do things the Scheme way, for better or worse.

itrs shit at least make parens different color for constraxcst

it is a number with 3 digits and I'm not willing to give any more detail than that

I think the argument for the third option is that you can say int x, or you can say int const x but you can't say intx or int constx, so having the * directly before the variable name without a space is inconsistent with other type qualifiers. Seems frivolous, but it kinda makes sense.

Not a webfag but A looks cleaner to me.

Attached: 1524662845386.jpg (1024x1139, 312K)

Attached: dailyprog-teletext-blink.gif (640x480, 30K)

I went and did life stuff but that isn't auto tune, that's her real voice, haven't you heard good live singers? Lana Del Rey 10 years ago sounded like she was auto tuning during live concerts, here's proof.
youtube.com/watch?v=ACSTDof8QL0

She has an amazing voice.

Attached: 1528411958038.jpg (475x731, 41K)

>itrs
>contraxcst
what is that?

I mean goof on the guy for his typos, but he made a good point. Why the shit are the parens the same colour as everything else?

> Why the shit are the parens the same colour as everything else?
because i don't know how to change that in vim?

If I'm scraping a website, and the website doesn't want me to do that, how can I keep it from knowing I'm a script?

just do shit very slowly

google.ca/search?q=change vim paren colors

use chrome's user agent

I had been using a two minute delay and I got caught, guess I'll increase it further.

I was using a Firefox one, which I assume has the same effect.

trying to think how to do lines 10-13 with linked lists and no iterators.

Attached: rec-fft-clrs-pseudocode.jpg (848x586, 80K)

keep it at 2 minutes and have it do other random stuff while waiting that a human would do.

You used this font on purpose?

Is this homework?

No, it was an accident.

hobby/free time

I'm studying for the AWS exams so I can make more money. Is there a better use of my time or? I plan to do the microsoft certs afterwards.

Attached: Screenshot_20180708-121258.jpg (1280x720, 393K)

Could you give an example or maybe point me in the direction of a resource that could teach me how to make a script act like that? Maybe just like, open random links in random intervals?

AWS certs are great.
Making 140k in Toronto because of AWS.

It's no SF Bay, but mortgage isn't nearly as fucked either.

Not the same user, but if you're using Selenium, you can just create functions to "do random shit". Have a function that will scroll around, another that might open a new tab and click on things. It wouldn't be too hard, just try to mimic what a normal human would do.

I was just using Python on its own, but I'll look into Selenium, seems like what I need. Thank you!

Of course. There are also wrappers(?) (might be libraries) for a couple of other languages like C# and Java if you're more familiar with those.

Has anyone here tried to program in RISC-V assembly? If you have, what do you like/dislike?

Attached: riscv-logo.png (265x90, 16K)

Attached: nock.jpg (900x1200, 87K)

Attached: C_dpt.jpg (1280x720, 582K)

I hope one day Dennis Ritchie rises from the grave and kills Bjarne Stroustrop

c = 2000 / max(width, height, 2000)
(new_width, new_height) = (round(c*width), round(c*height))

libcello.org/

It sounds like you want a template engine like github.com/spullara/mustache.java.

>list of numbers within the range 1-20
Convert this into a map of value => count
[1,1,3,5,5,5,5,1,2,1]
becomes
{1: 4, 2: 1, 3: 1, 5: 4}
This will speedup operating on the input; not sure about the rest of the problem tho

>Delphi
Web still can't really compete with Delphi, Access and VB.

Hmm yeah but I've just been mostly wondering if scaling down that way while keeping the ratio makes sense in the context of keeping the proportions but I guess it does.

>Klabnik was right, only 1% of people like me are fit to program and we prefer rust naturally.
I doubt a literal Communist would say it.

>I've finally (mostly) completed How to Design Programs.
Fuck yeah, my shilling has paid off.

The code scales images down to no more than 2000x2000 and doesn't touch smaller images.

lacks seam carving

You don't need seam carving for proportionate scaling.

tried all that but no difference.

Here's the vim file and a test file just to demonstrate.

Attached: DevMT2.png (1232x582, 127K)