/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Previous thread:

Other urls found in this thread:

blog.xinhong.me/post/sublime-text-vs-vscode-vs-atom-performance-dec-2016/
archive.rebeccablacktech.com/g/thread/S58009006#p58009536
learnopengl.com/#!Getting-started/Hello-Window
alecb.me/blog/stack-language-ocaml
github.com/baklava151/VirtMachine
google.com/search?q=make a unique algorithm&ie=utf-8&oe=utf-8#q=make a unique algorithm c#
jsfiddle.net/mzt2w4z2/
twitter.com/SFWRedditGifs

hmmmm

blog.xinhong.me/post/sublime-text-vs-vscode-vs-atom-performance-dec-2016/

FP > OOP

multi paradigm is best

>multi-culturalism is best
no

Look mommy, I can write this for-each in 2 lines instead of 3!

how does it feel to be unemployed?

pretty good

how does it feel to be employed?

Fell for the socks meme, I don't feel like a better programmer

Pretty rich.

Moved here so user will find it...

I want to place a cool programming related tattoo on my chest. I don't know what though, do you guys have any ideas? I want girls to be interested in it when I take off my shirt before I shag them or when I'm just at the beach/pool? I thought about the Java symbol but I'm not too sure. Pls help

archive.rebeccablacktech.com/g/thread/S58009006#p58009536

Don't be gay, user.

...

Imagine needing to fit in on an anonymous imageboard this badly

Detecting URLs in text. Is there a better way than this?
private boolean isLink(String copiedText) {
try {
URL url = new URL(copiedText);
} catch (MalformedURLException e) {
return false;
}
return true;
}

The symbol you are looking for is lambda.

>Implying Multi monitor doesn't actually increase productivity

Poorfag detected.

testing out ActivePresenter some more. webms are so easy to make now.

>not λπω

Trying to learn OpenGL for like the fifth time this week. I got everything up and running and am following this tutorial -> learnopengl.com/#!Getting-started/Hello-Window

I'm about a third into the actual code, but when I run it, I get this monstrosity of an error message...
[General] ERROR: Setting as the first responder for window , but it is in a different window ((null))! This would eventually crash when the view is freed. The first responder will be set to nil.
(
0 AppKit 0x00007fffbde95114 -[NSWindow _validateFirstResponder:] + 566
1 AppKit 0x00007fffbd6117ff -[NSWindow _setFirstResponder:] + 31
2 AppKit 0x00007fffbd6b9a22 -[NSWindow _realMakeFirstResponder:] + 406
3 AppKit 0x00007fffbd6b9838 -[NSWindow makeFirstResponder:] + 123
4 libglfw3.3.dylib 0x00000001001118c0 _glfwPlatformCreateWindow + 631
5 libglfw3.3.dylib 0x000000010010d474 glfwCreateWindow + 487
6 OpenGL_Practice 0x0000000100001033 main + 179
7 libdyld.dylib 0x00007fffd5025255 start + 1
8 ??? 0x0000000000000001 0x0 + 1
)


I have no idea what it means, nor how I can avoid this... Any ideas?

OCaml does it better.

...

maki tattoo

If you use operating systems that are terrible at window management like, ironically, Windows.

I have a multi monitor setup and use i3 bitch.

no

the better encoding is to just have pop/push/swap/etc as functions, then compose with (.)

Mechanical keyboard, free, multi monitor, no Apple products.

No Apple for me.

it's right there in the error message m8.

What's wrong with Windows' window management?

Get rid of the forward compat hint, it won't work on Apple macOS (tm).

literally whats wrong with WWM?

>needing (.)
alecb.me/blog/stack-language-ocaml

>what's wrong with windows management?
>windows

I have no idea what you're trying to convey with this post.

>it's another blanket "it's bad because it's windows" post

sasuga

>let start k = k []
>let push stack x k = k (x :: stack)
>let pop (_ :: stack') k = k stack'
>let add (a :: b :: stack') k = k (a + b :: stack')
>let stop (x :: _) = x

in Haskell this is just

start k = k []
push stack x k = k (x : stack)
pop (_ : stack') k = k stack'
add (a : b : stack') k = k (a + b : stack')
stop = head

Almost the same. OCaml doesn't generate gigabytes of data per second.

>>>OCaml does it better
>it's not THAT much worse

bits = shift_in();
uint8_t tmp_bits = bits;
uint8_t tmp_mask = bits & ~curr_offset;
tmp_mask >>= curr_offset;
tmp_bits

>I have no argument, I'm just a linux fag.

Delete this.

got pretty much all the logic for the poker hand rank done.


for i in range(10000):
cards = deck()
p1 = []
board = []

for i in range(2):
deal(p1, cards)

for i in range(5):
deal(board, cards)

sflush(p1, board)

['Qc', '7d']
['Kc', '10c', 'Ac', 'Ah', 'Jc']
royal flush
['9h', 'Qd']
['5h', '7h', '6d', '6h', '8h']
straight flush


i think the math is about right. i simulated 30,000 hands ealirer. it took about 6 seconds and found quite a few straight flushes and a few royal flushes. i'll have to actually look at poker odds and test my engine to see if it aligns.

Keeping sucking bill gates' tiny dick, at least linus' is big

>A swede who's getting cucked at home by a somali has a bigger dick than an American magnate

KEK

How typical of a code monkey to prioritize code prettiness over efficiency.

>Fuck you for not having any problems with Windows, fuck you for not wanting to do everything through consoles!!!!

he's finnish

>>>the ocaml version is better!
>>why?
>*anger*

>implying you have to do everything through console

classic winbaby banter

for i in xrange(10000):
cards = deck()
p1,board = [],[]

for _ in range(2):
deal(p1, cards)

for _ in range(5):
deal(board, cards)

sflush(p1, board)

>fuck windows because I use linux

classic linfux banter

I need to remove duplicates from several lists that I'm filling with data from a SQL database in C#. Google search/MSDN says I can instantiate a new empty list and just fill it with the old one using .Distinct().ToList();, but where can I read about novice algorithms for this kind of thing? Would it be time to break open CLRS or Sedgwick? I don't want to use it without being able to do at least a version of it myself.

>being autistic

It's better because it's more efficient and essentially the same code if you're not autistic.

There's simply no benefit to using Haskell.

>being autistic

Yo people, I'm working a checkers game for a school project, and right now i'm stuck at trying to import and image with JavaFX.
public void titleView(Pane pane)
{
Image img = new Image("file:test.png");

ImageView title = new ImageView(img);
title.setImage(img);
title.setLayoutX(569);
title.setLayoutY(146);
title.fitHeightProperty().add(100);
title.fitWidthProperty().add(100);
title.setVisible(true);

pane.getChildren().add(title);

System.out.println("success!!!");
}
What i'm looking to do, is being able to package the test.png with the jar files when i make it a runnable program, all the variations of filenames/filepaths leads to me getting a null pointer exception. I can't for the life of me figure out where to put the image and how to refer to it in order to use it. Anyone got experience doing that?

>being autistic

Here are your (You)'s.

>confusing a language with its implementation

if i'm initializing multiple variables should i always do like that?

python is only language i know so i really don't understand best code practices.

github.com/baklava151/VirtMachine
I'd have more done, but Mount and Blade Warband sucked me in

...

not really, but its faster IMO

also, if using python2, you should use xrange in big for loops, because its faster

...

here's (You)rs

i blame him for what's happened

only started coding once python3 was already out.

when i was 'trying' to build my bit torrent client i ran into a few problems but most of it was just syntax stuff. also some other stuff i coded they changed a lot of libraries for instace like urllib.quote.parse or something to that effect used to just be urrlib.parse so it's like naming of things or something?

>its faster

what makes you think so?

well, in the first case i meant *faster to write,

in the second one , xrange is faster than range

google.com/search?q=make a unique algorithm&ie=utf-8&oe=utf-8#q=make a unique algorithm c#

distinct() and the algorithm in question in general is about 4 lines long and in O(n)

if you want to waste time memorizing and poorly re-implementing algorithms maybe for interviews stick to sorts, those are the real boring ones

>well, in the first case i meant *faster to write,
oh ok

I'm running Linux so I guess that. What libraries should I start getting familiar with?

>if you want to waste time memorizing and poorly re-implementing algorithms maybe for interviews stick to sorts, those are the real boring ones
Cool. I didn't want to go full pajeet and just blindly use distinct() because SO/the internet said so but I'll just use it and deal.

>distinct() and the algorithm in question in general is about 4 lines long and in O(n)
Is it really a linear search?

yes there is. after 5 lines of code you start to see real differences. you're generalizing over something less complex than hello world

Use a Set, they guarantee no duplicates (as long as you don't care about order)

There's no need to use lower-level logic to do inefficiently what data structures can do for you efficiently.

C# has a HashSet, which is the closest it comes to Python's set (which I think is what you're referencing). Like I said, I'm just using distinct() and dealing with it since it does the job and I'm not hitting numbers of items that would require putting things into a HashSet yet.

How do I match a list using guards in Haskell?

Say I have a function multAll that needs to multiply all numbers in the list.
Using pattern matching it would be

multAll [] = 1
multAll (h:t) = h * multAll t

but I have no idea how to write it using guards.

This thread is pathetic. It is not about programming. It's just a bunch of computers illiterates and first semesters memeing about whatever they just learned.

A quick search shows that most arguments used here are not original and have been copied from some trendy tech blog or other shit site.

The only real programming questions I have seen so far are from beginners(it's fine to be a beginner btw).

This entire site is shit and I don't know why anyone would regularly come here.

A shitty zombie game desu.

If I get rid of the Forward_Copmat thing, then the window won't show up at all... Here's the error message:

[General] ERROR: Setting as the first responder for window
, but it is in a different window ((null))! This would
eventually crash when the view is freed. The first responder will be set to nil.
(
0 AppKit 0x00007fffbde95114 -[NSWindow _validateFirstResponder:] + 566
1 AppKit 0x00007fffbd6117ff -[NSWindow _setFirstResponder:] + 31
2 AppKit 0x00007fffbd6b9a22 -[NSWindow _realMakeFirstResponder:] + 406
3 AppKit 0x00007fffbd6b9838 -[NSWindow makeFirstResponder:] + 123
4 libglfw3.3.dylib 0x00000001001118c0 _glfwPlatformCreateWindow + 631
5 libglfw3.3.dylib 0x000000010010d474 glfwCreateWindow + 487
6 OpenGL_Practice 0x0000000100001034 main + 164
7 libdyld.dylib 0x00007fffd5025255 start + 1
8 ??? 0x0000000000000001 0x0 + 1
)
Failed to create GLFW Window

What did you write this in? I'm looking to get started on writing graphical programs and this looks like something fun to try.

It's cropped weirdly, desu desu.

null, or (==[]), as well as head and tail

is there a standard function that takes a printf string that converts it but does not print it?

sprintf

thanks

JavaScript using the HTML5 canvas, pls no bully.

Haskell

jsfiddle.net/mzt2w4z2/

what's wrong with comparing strings?

Got it to compile but doesn't work properly, says the pattern is non-exhaustive. Does it not match on empty list or what?
multAll (h:t)
| (h:t) == [] = 1
| otherwise = h * multAll t

cause niggers

muh string pool

What are some good Javascript tutorials? I barely remember any Java.

>250 lines just for that

all strings are equal

(h:t) doesn't match an empty list

>jsfiddle.net/mzt2w4z2/

Kek.

multAll xs | null xs = 1
| otherwise = head xs * multAll (tail xs)