/dpt/ - Daily Programming Thread

Previous thread: On Topic Edition

What are you working on, Sup Forums?

Other urls found in this thread:

youtube.com/watch?v=R3JI4fJPtk0
youtube.com/watch?v=Du6acZ-PZQ8
pastebin.com/jvvS3mNG
reddit.com/r/githelp
stackoverflow.com/questions/5178125/how-to-place-object-files-in-separate-subdirectory
github.com/deeepaaa/rana
twitter.com/SFWRedditVideos

First for there is literally nothing wrong with VB.NET.

It seems our threads keep getting deleted whenever someone starts making political chatter. Why would the mods not simply delete the offending posts?

Except for the fact that C# is better than it in every way...

Obligatory Pajeet:
youtube.com/watch?v=R3JI4fJPtk0

The thread was probably barely 10% on topic, and when you "only delete the offending posts" you end up with people posting about the topic again. I don't remember what the OP image was, but that could've been it too.

Or better, actually ban the samefagging cunts shitting up the thread with off topic shit so that we don't have to deal with them.

They'll shit up this thread too, in time, just watch.

Naiive implementation of lambda calculus
Fails when you repeat variable names (much simpler to write)

gee at least it's not one of those " le kali loonix xDD vs scammer" videos

VB6 was far better and a proper Basic. VB.NET is just C# with a different syntax.

they should just ban the assblasted samefagging anti alt right faggot

This. It's mostly his fault that the thread went off the rails.

daily reminder that coding isnt the same as programing

This one is better:
youtube.com/watch?v=Du6acZ-PZQ8

Hi, I'm a newbie and I really need help, I have signed into my server via WinSCP and I want to edit: /etc/ssh/sshd_config and add the following 'AllowUsers' but it won't let me edit the document.

Can someone please help?

Please help!

Here's another one that uses de brujin indices and has a REPL

you logged in as a regular user but that file is owned by root.
login as root or just ssh into the root account via putty to edit the config file via vim or another terminal text editor.

for instance

>eval (\0) 9
9

>eval (\0 0) 9
9 9

>eval (\0 0) (\0 0)
(\0 0) (\0 0)
-- if the previous two stages are equal it will stop, this is an infinite loop

I think the parser might hang sometimes, found that kind of complicated

I'm trying to implement conway's game of life in curses but I'm having a problem with the following check
if input_state[y][xl] == 1:
It's meant to check if the square to the left of the current square I'm at has life in it (1 is life in the array, 0 is no life). The thing it doesn't evaluate as true when it should. I tested it out by halting the program when the if statement was true, and it only ever happened if I had three cells in the configuration shown on the right.
Any idea what is going wrong?
I know the array is correctly storing the data and that xl, xr, yu, and yl are correct.
I'm new to programming so feel free to shittalk/provide criticism.

Are there any alternatives for ctags, or is it still the bee's knees when it comes to code lookup/navigation? How does cscope compare?

Whoops, I meant

eval = snd . head . dropWhile (not . uncurry (==)) . (zip tail) . iterate beta

Font pls

It might help to have your complete program, rather than just a snippet. Can you post a pastebin?

Fira mono
pastebin.com/jvvS3mNG
There's some commented stuff from me trying to test what wasn't working.

Thanks a lot, I managed to edit it!

Really appreciated.

I added 'AllowUsers' then what I think is my username, is your username the bit that goes in front of @ before you sign in on putty?

I've started learning Java a month ago. I already have a grasp of things but not enough obviously for anything of impact. How long would you suggest one should learn/practice Java before he can say he knows something ?

Okay, after some running through your code, I think I discovered your problem... you're overwriting your input array in your main loop. Basically... don't do this:

output_state = list(input_state)

In fact, create a brand new array and copy shit over manually. Because what you did there was actually to create a new array that had all of the pointers to those internal arrays. To demonstrate a similar case in a REPL...

rubyist@Overmind:~/scratch$ python3
Python 3.5.2 (default, Jul 5 2016, 12:43:10)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> ary = [ [1,2,3], [4,5,6], [7,8,9] ]
>>> cpy = list(ary)
>>> cpy
[[1, 2, 3], [4, 5, 6], [7, 8, 9]]
>>> cpy[0][0] = 20
>>> cpy
[[20, 2, 3], [4, 5, 6], [7, 8, 9]]
>>> ary
[[20, 2, 3], [4, 5, 6], [7, 8, 9]]

Thanks, that would explain the problem. I thought list() avoided pointing to the old list which is why I used it in the first place.
>In fact, create a brand new array and copy shit over manually
What is the best way to do this? Just run two for loops?

My hex editor now highlights the edited bytes.

>just run two for loops
That would be the simplest way, I'd think. Not sure what the most efficient way would be though. My knowledge of the internals of Python is a bit more sparse than my knowledge of the internals of say, Ruby.

Thanks for your help

pretty

first for Maki butt

That seems rather useful... although why are the rows 15 wide instead of 16?

Hex editors are already a pain with a good GUI, I can't even imagine how painful they are without one. Going the radare2 route to make your program unusable?

i am bored.
Anyone has the images with the programming challenges, so i can do something i havent done already 5 times?

Retard here,
do I need to be good at math to programming?

no

No, but I think people who tend to be good at one may also excel at the other.

I wrote a simple calculator

The amount of bytes per row is dynamic, depending on width of the terminal.
I might think about an option to force it to 16 bytes per row (or any number the user wants) but that isn't a priority.

It's feels very usable right now, I don't know what you are doing with your hex editor but the only thing you really need to do is navigate the file and change bytes, no?
Don't know how this can't be achieved with a cli.

/* print a cross */
.global main
main:
push %rbx
push %rbp
mov %rsp, %rbp
sub $16, %rsp

cmp $2, %edi
jne .Lfail
mov 8(%rsi), %rdi
call atoi
test %eax, %eax
jle .Lfail
mov $3, %edi
mov %eax, %ebx
mul %edi
add $7, %eax
mul %ebx
shr $1, %eax
mov %eax, (%rbp)
mov %eax, %edi
call malloc

test %rax, %rax
jz .Lfail
mov %rax, 8(%rbp)
mov %rax, %rdi
mov $32, %esi
mov (%rbp), %edx
call memset

mov 8(%rbp), %rdi
xor %esi, %esi
.Lloop:
mov %ebx, %eax
sub %esi, %eax
jz .Lend
dec %eax

mov %eax, %ecx
mov %esi, %edx
cmp %esi, %eax
cmovge %eax, %edx
cmovge %esi, %ecx
sub %ecx, %edx
mov $42, %al
add %rcx, %rdi
stosb
add %rdx, %rdi
dec %rdi
stosb
mov $10, %al
stosb
inc %esi
jmp .Lloop
.Lend:
mov 8(%rbp), %rbx
mov %rbx, %rsi
sub %rbx, %rdi
mov %edi, %edx
xor %edi, %edi
inc %edi
call write

mov %rbx, %rdi
call free

xor %eax, %eax
mov %rbp, %rsp
pop %rbp
pop %rbx
ret
.Lfail:
call abort

FUCKING USE INTEL SYNTAX OF GET THE FUCK OUT.

Just add `-masm=intel` for gcc

moar?

>at&t
into the trash it goes

I like at&t's better. The percents. They are cute.

...

will this work for asm compilation in gcc?
I only used this flat when translating C -> ASM

I meant of maki butt

I know what the fuck you meant, but I don't have any.

...

I've been learning python and javascript for the last year now. I do my own small projects, but I'm interested in actually coding with other people.

What's a great entry way towards this?

reddit.com/r/githelp

inb4 >reddit no fucks given

writing codes of conduct on github

Fuck off.

wrong website buddy

I have a root directory, a couple of source files in the /src sub-directory and a couple of headers in the /incl sub-directory. My Makefile is in the root one, and I already know how to make stuff with sources and headers neatly packed away in their own folders, but I'm bound to have a bunch of intermediate files pop up, like something.o or parser.tab.o, and I want them to be stored away in some kind of temp folder until I need to build my topmost target so that the only things in the root are the target and the Makefile. How do I tell Makefile to build into a subdirectory of the directory that contains the Makefile?

No

By cd-ing into it? Or you can use CMake instead.

Report me then.

Looking for big mouth faggots to suck me off

>CMake
Disgusting.

stackoverflow.com/questions/5178125/how-to-place-object-files-in-separate-subdirectory

Do yourself a favor and stop messing around with custom makefiles. Just run cmake or autotools or whatever instead and let it take care of the tons and tons of magic you need in a build tool.

c++
I am writing a little library with some functions that have like 4-5 params to set before starting, being the good person i am i made a struct with those params.
As of now the struct is the same across all the functions, even if some functions don't use all the parameters inside it.
Should i write a different param struct for every different function?

>What are you working on, Sup Forums?
Implementing bitorrent protocol in c#. Finished the bencoding library and almost finished generation of metadata for .torrent files.

Trying to implement a protocol from scratch has taught me I don't know shit.

Redpill me on llvm

>Disgusting

Yes, CMake sucks ass in many ways, but it gets shit done, Does The Right Thing, and makes adding dependencies comparatively easy and in a cross-platform manner, at least for C/C++.

they fell for the dragon meme

I dont' have time to learn that stuff, I just needed this but maybe I'll look into it later.

>implying c# with basic syntax isnt superior to basic with basic syntax

Hey /dpt/, got a c++ question.
In my .h there is no trace of library X.
In my .cc implementation i use library X.
Should i include in .h or .cc?

You don't create structs just for the sake of having unary functions, you create them to represent a single concept as a set of fields. If you have too many params, reexamine the design of the function and see whether its fuctionality is as cohesive as it should be.
>I just needed this
Yes, and then you'll need another thing, and another thing, and another thing, and will have to mess with new make features every step of the way.

.cc

The functions can't have less arguments, it needs these exact arguments at that exact moment.
Assuming i either stick with functions with up to 6 params or i use params structure, should i use a shared structure or a different structure for each?

You are not making any sense.

I just watched the movie "Nerve" and in it they had a game which was essentially a decentralized network, without a main server to index all the players. How would that be achievable? How could players find eachother without a server to connect? Do they all just scans all IPs for some specific port? I doubt that is the solution since it would be very slow. How is it done then?

> placing all your files inside src/ instead of src/logicalGrouping1, src/logicalGrouping2 etc
I seriously hope you dont do this

>srs/logicalGrouping1/file.h
>header/logicalGrouping1/file.cpp
I cannot stand this

maybe a distributed rtree or any spacial data structure?

I'm talking from a networking prespective. When a person launches the game for the first time, if there is no server, how does it find the other players?

This is the best way to do De Bruijn indices:
data Term a
= Var a
| Abs (Term (Maybe a))
| App (Term a) (Term a)

Capture-avoiding substitution is actually a monad.

>Abs (Term (Maybe a))
What is Abs (Var Nothing)?

also nice polymorphic recursion

λx.x

Nothing is 0 and Just is (+1).

Ah, nice

>using a language that requires 2 files for every file
>putting your src in your header and your header in your src

i guess you will have to scan random ips (on the right port) until 1 of them answers with "yes i am part of the game", then since he's part of the game he can point you the start of the distributed index or some shit

The type parameter of a term is the set of free variables. Closed terms have the empty type as a parameter. Well, ideally, anyways; in Haskell you can use undefined or an infinite loop to inhabit the "empty" type.

What's the point of the way interfaces work in F#, i.e. you're forced to use the "explicit implementation" and any time you want to use anything from that interface you have to cast to it?

>What's the point of _ in F#?
Who knows?

What are pointers good for? All I've gotten so far is that you can get the memory address but what do I use that for?

Someone here told me I should start with learning pointers in C++ because it was important

Can I learn c++ just by internet guides?

I have no programming experience whatsoever.

It's considered more type safe I guess. Don't really know.

what font is that?

curryface

fira code

They allow you to pass big data structures (classes, structs) to functions without the need for copying the entire object for each function call.

How do I recieve packets using a script?

The packets are encoded with msgpck if that helps

Unless you're doing memory management yourself, you don't really need them in C++. References are probably more than enough for you. For instance, you'd use a reference instead of a pointer in this circumstance .

Yeah c++ is easy as shit

trying to make a python script to make surveys for me, does any of you know sites that have surveys that you make money from?

github.com/deeepaaa/rana