/dpt/ - Daily Programming Thread

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

Other urls found in this thread:

strawpoll.me/11125373
msdn.microsoft.com/en-us/library/cc668191.aspx#Y684
automatetheboringstuff.com/chapter11/
stackoverflow.com/questions/8255929/running-webdriver-chrome-with-selenium
github.com/Sup
robmiles.com/c-yellow-book/
projecteuler.net/problem=40
udemy.com/code-your-first-game
twitter.com/NSFWRedditVideo

First for D

When you go to university for CS, is it required for you to be familiar with Discrete Mathematics, Graph Theory, etc. or do they teach those subjects from ground-up?

Too early you dumbass

no

Possibly going to intern at EA, have only heard bad things about them but I think it'll be worth it, right? Would be in internet interfacing stuff, which seems cool.

It's required for us to learn it at least; they taught discrete "from the ground up" per se but it was a cut-off course and a lot of people failed, so being a non-idiot helps

They teach those subjects.

Well it depends on country/school, but in general they assume you know high school level stuff, which doesn't directly involve discrete math and graph theory. They'll probably have some courses that continue on your high school math, like calculus. But Discrete and Graph Theory are separate subjects so they teach those from the ground up.

Why are there two /dpt/s?

Thanks! I consider myself not to be too dumb, so I think I'll manage.

What's the best library for D to do some basic opengl graphics? derelictsfml are just some shitty C bindings and derelictglfw is just a PITA that doesn't work (for whatever reason). i only want to draw very simple 2d shapes, high-level is preferred

Wrap sdl in high level functions.

strawpoll.me/11125373

have you remapped caps lock to ctrl? it seems really bad for ctrl+c and ctrl+v but i'll remap function keys as copy/paste anyway. i'm kind of on the fence about using caps lock as ctrl or if i should just use the ordinary ctrl

Is it possible to use the address operator on a function that returns a char pointer so that the function that comes after it can take a char ** pointer?

eg.
char *func3(char **str);
/* */
char *done = func3(&func2(func1(some_source)));

Why would you do that? You shouldn't be pressing caps lock regularly, since using shift for single letters is faster. Literally why?

I wouldn't

i mean using the caps lock key as if it was a ctrl key

allies against the fad/meme languages

Oh, that does make sense I guess...

bjarne and stallman use pic related or one like it

D is not a meme

What's a meme language?

Haskell lisp etc.

Reading msdn.microsoft.com/en-us/library/cc668191.aspx#Y684
What's happening when the article says to put

inspectors = this.Application.Inspectors;
inspectors.NewInspector +=
new Outlook.InspectorsEvents_NewInspectorEventHandler(Inspectors_NewInspector);


in _Startup? I know that the inspector's purpose is to pull up the topmost open window (which for the example would be clicking "New Email," but why are we adding it to new Outlook.InspectorEvents... and setting it to inspectors.NewInspector?

How do I make a DFA from a regex in C?
I'd like it to be extensible, like being able to add some extensions like POSIX character classes.
I have no idea where to start.

*and THEN setting it to

>What's a vegetable?
>"Tomato, avocado, etc."

You didn't define what a meme language is, and those aren't meme languages.

It's adding an event callback. When the New Inspectors event triggers, InspectorsEvents_NewInspectorEventHandler will get executed.

It's just a fancy way of saying "When X happens, execute method Y".

Doesn't need defining, meme languages are just meme languages

hey /dpt/, how would you make a script to click checkboxes on chrome? I do it like a fucking retard. I open the page I need a lot of things clicked and then run this python script using pyautogui to find a checkbox and click them.

Like I said, like a fucking retard.

I know there's a way of doing it better using javascript to click the elements, how do I do that?

import pyautogui
import time
while True:
for i in range(0,10):
o = pyautogui.locateOnScreen('checkbox.png')
if o == None:
print('wow')
break
ox, oy =pyautogui.center(o)
pyautogui.click(ox, oy)
r = pyautogui.locateOnScreen('r.png')
rx, ry = pyautogui.center(r)
pyautogui.click(rx, ry)
pyautogui.press('enter')
time.sleep(2)

When NewInspector is fired, you call your own method "Inspectors_NewInspector()".

No one knows.

If anyone says X is/is not a meme language, just say they're wrong and there's no more conversation.

it's a language that's unsuitable for productive work (e.g. haskell, lisp) but it gets used by memers

Doesn't sound like a bad way to do it, honestly. You could use Selenium in Python and just look for any checkboxes in a similar fashion to the JS thing you want to do.

automatetheboringstuff.com/chapter11/

A language that you can't get jobs for in your own town. For example, you can get Java and Python jobs anywhere, but you have to move to another country to get a job writing Haskell.

I will soon have a OCaml job. It's fucking nice.

Yes, but you literally had to move to the other side of the planet for it, so it's a meme.

why is he doing firefox in the example? can you do just the same but replace 'firefox' with 'chrome'?


my thing works but it's so so slow, that's why I want to make something better

No I will stay in my country.

Not using a code generator.

No, that's not possible. OCaml is definitely a meme so you had to move to a totally different planet to find a job like that.

A E S T H E T I C

Don't be jealous user.

I'm not jealous at all. I'm safe and comfortable in my home here on Earth while you're out traveling through the cold, empty void to some other galaxy.

Is it me or all languages suck ass?

I know a little bit of Python what real language should I learn?

Is Haskell a waste of time?

Are pajeets actually good at code?

There are space hookers in the void user. Don't be jealous.

>can you do just the same but replace 'firefox' with 'chrome'?
stackoverflow.com/questions/8255929/running-webdriver-chrome-with-selenium

>my thing works but it's so so slow
Make sure you set pyautogui.PAUSE to 1 so there's only that 1 second delay between commands and use time.sleep() for any lengthy pauses you need. So at the top you can add
import pyautogui as p
p.PAUSE = 1


I dunno if this helps but for a script I have at work, I did
# import lib as "p" as above
def locate(img):
btn = p.locateOnScreen(img)
btnX, btnY = p.center(btn)
clk(btnX,btnY,l)

C#

No but they can put together simple stuff for pennies. Sometimes that's what you need, sometimes it's not.

...

You travel back in time a few days before Dennis Ritchie invents all of programming, but only get to say 5 words to him. What do you say?

oops didnt realize it was nude

C is a meme language

>deleting your post's image because you realise it violates the rules
you can stay user, i like you

templates please, that is all.

C# if you want something enterprise-friendly that's also enjoyable to write (unlike Java, C++).

Playing around with the Sup Forums API: github.com/Sup Forums/4chan-API

fuck header files, nigger

Shit I wanted to watch your picture.

What is the best resource for learning c#?

This one is pretty solid.

Link to free PDF on page:
robmiles.com/c-yellow-book/

It sort depends on what industry you're in, or what you really want to do with it, because some books are geared towards certain ends.

The book I learned on back in the day, Murach's, is very database focused, so I can't recommend it in general.

robmiles.com/c-yellow-book/

MSDN

A Discrete Math undergraduate course will usually be just set theory and relations.

thanks anons, I'll check these out.

I use linux. Can I use Mono and everything will be nice?

You should be fine, Monodevelop is fairly solid. I've got a buddy that uses Fedora (I think), and he came from Python and is now using C# in Monodevelop for everything.

Just note that the best C# dev experience is with VS, even if you're developing cross-platform programs, and you may consider loading up a Win10 VM for it.

Obviously, you can use whatever text editor + shell compilation strategy you want, if you want to stick with emacs or vim or whatever.

objects contain data and functions

*objects encapsulate data and functions

gets the point across better

*objects encapsulate data WITH functions

i suck at time travel

> meme language

here guys, I figure it out. This is all that you need to paste in the console:
document.querySelectorAll('input[type=checkbox]').forEach(el => el.checked = true)


one fucking line, so much time saved

you're a meme dpt-er, so your opinion has no value around here
thanks
>>>/rebbit/

How to do this problem in O(1)? Iterative solution is easy.

projecteuler.net/problem=40

>only finished 3 out of 5 problems on the hackerrank challenge for an internship i'm applying for
the first question i'm 90% sure was a troll question too. It wanted you to return a boolean of if there's any pair of values in two arrays that could be added to equal a set goal value, in O(n) time

user...

meant for

project euler problems, though they can be programmed, can usually be done using math in O(1)

Christ. You're a fucking bright one aren't you? Did you ever think to get the max values out of the 2 arrays and add them together?

that doesn't even have anything to do with the problem

that's not the solution. you need the pair to add up to an exact goal value, they shouldn't exceed it

shit
Well use a hash set then.

post your solution please

d n = champernowne !! (n-1)
where champernowne = concat $ map show [1..]

main = map d [10^i | i read [x]) -- convert to list of digits
& product -- product those digits
& print

> main
210
it :: ()

O(n)

am i the only one who's figured out a solution

remember that k*n i still O(n)

Mine literally just does what it says in the question, concatenates all those numbers and multiplies the 1st, 10th, 100th val. What does yours do?

Improved a bit on my pong game yay

static bool ContainsSum(int[] ArrayA, int[] ArrayB, int Check)
{
System.Collections.Hashtable Table = new System.Collections.Hashtable(ArrayA.Length + ArrayB.Length);
int counter = 0;
for (int i = 0; i < ArrayA.Length; ++i, ++counter)
Table.Add(ArrayA[i], counter);
for (int i = 0; i < ArrayB.Length; ++i, ++counter)
Table.Add(ArrayB[i], counter);
counter = 0;
for (int i = 0; i < ArrayA.Length; ++i, ++counter)
if (Table[Check - ArrayA[i]] != null)
if ((int)(Table[Check - ArrayA[i]]) != counter)
return true;
for (int i = 0; i < ArrayB.Length; ++i, ++counter)
if (Table[Check - ArrayA[i]] != null)
if ((int)(Table[Check - ArrayB[i]]) != counter)
return true;
return false;
}

Well, it depends. Are you sure you absolutely need to open the page in a web browser? Can't you intercept the requests and see what it does underneath, then simulate the requests in (insert your preferred language with networking support here)?

What do you want to do?

no i just wanted to search history for a certain website, and then check all the instances so only that website is removed from history while the rest of the history is intact. figured it out here

Are you playing or an AI?

the same thing
but I want to see the solution in your language
assuming it isn't haskell

Does it look like it's an AI playing Devilboy?

Maybe? Does func3 dereferences it, or does is it used as a array or char*?

Also, if func2 returns a dynamically-allocated char*, this would result in a memory leak.

that;s a lot easier to do in javascript I would say

>udemy.com/code-your-first-game

how do I create a file in haskell without doing
writeFile "file" []

>Implying anyone completing that course can program something afterwards

Isn't this n^3?

Does anyone here know about the localization process used for video games?
My question is if built-in function words are still English when Japanese programmers program, or if they are translated? If so, then does the code itself need to be translated during the localization process, or does the code remain the same and just the strings/dialogue are replaced with English?

>for loops going from 0 to the array lengths
Why the fuck would that be O(n^3)?
Also the last for needs ArrayB in the null check.

Don't your searches within those loops use O(n)?

It's widely recommended to program in English, no matter what country you're from.

It all depends on the developers.