/dpt/ - Daily Programming Thread

This is /dpt/, the best subreddit of Sup Forums

Umaru-chan edition, the best of all editions.

In this thread:
r/programming
r/compsci
r/ReverseEngineering
r/softwaredevelopment

code of conduct:
no racism
no insult
no sexual harassment
no gender discrimination

wat r u working on, user-chan ?

Other urls found in this thread:

jetbrains.com/pycharm/download/#section=windows
news.ycombinator.com/item?id=1803815
pastebin.com/pCp6Hmck
twitter.com/NSFWRedditImage

Shit OP, delete this thread and feel shame, thanks.

Nothing. Just learning C I guess.

Nothing. Just unlearning C I guess.

Fuck off sjw weabshit

Rewriting C in B.

First for D.

...

Writing a custom allocator for C that takes another pointer as a parameter. It then returns memory as close as possible to the given pointer. It allows a programmer to optimize for locality without painful boiler plate.

Eventually I'll extend it so the program is profiled while it runs and the allocator keeps track of the usage of a set of memory areas in time and space. I will allow one to pass the set of pointers to an optimize() function which will move the memory around to better take advantage of locality. If this occurs several times throughout a program and over multiple sets of memory the cost overhead of memory access will steadily decrease. It will also dump a profile report which can be loaded by the allocator so that future runs of the allocator in that program exhibit the same allocation scheme the optimized usage had determined.

Profile-guided optimization applied to memory allocation. I think it will take a couple years in between classes and work, so I might use it for my PhD.

I bet you like the D.

C'mon kid, why don't you stop wasting your time with gay hipster shit, and learn a real language like Java or C#? Nobody's going to give you a job using D.

dpt-chan, daisuki~~

Ask your much beloved programming literate anything (IAMA)

>2016
>learning C

Why ?

Good

>no racism
>no insult
>no sexual harassment
>no gender discrimination

Fuck you retarded nigger faggot, I'm going to rape your faggy boipussi and all muh female hacker girls that post ITT and lynch the niggers and japs and chinks.

Say that to my face online not URL and see what happens, fucker

Can someone post recent programming challenges?
Is it worth doing them to prove my skills?

To learn the basics. I plan to move C++ later.

Write a program to find programming challenges for you to do.

>Move to C++ later
That's what I meant

idea to catch pedophiles:

find code execution vulnerabilities in popular image/video viewing software, then upload malicious images/videos that exploit those vulnerabilities to onion sites

when can i claim my job at the nsa

>he calls himself a programmer but he's not able to program for the most widely used operating system in the entire world: Android

So markov chains and stack overflow posts?

If you want to learn the basics, you learn a decent programming language like Scheme. not c or c++.

Yeah, why not. Or some kind of project Euler scraper.

sjws think japs and chinks are white because they don't fit into the racial oppression narrative (along with jews)
since they are white it is ok to denigrate and discriminate against them

how else could you honestly look at the most racially diverse industry, where asians sometimes even outnumber whites, and say it has a huge diversity problem and that having 60% whites is 'gross' when that actually means that whites are UNDERrepresented by 12%?

>sjws
stopped reading there

>t. (((((((user))))))

just finished this sprite sheet packer and animator i made for cocos2d-x. there were no free tools to pack sprite sheets. and no linux tools to animate them

the source code got out of hand so fast lol. it's the biggest thing I've ever written in javascript. 1 file has all the logic and UI with 1500 lines

one ) is missing. yes, i am a lisper.

No user, every company must be made up of 25% whites, 25% blacks, 25% Asians and 25% Hispanics otherwise it is RACIST. Even then it is still bigoted because it is not employing affirmative action. The ideal split is 10:30:30:30.

Found the sjw.

Anyone here use Codelite? It seems pretty decent.

No, use a real editor, you nancy.

Can it detect the size of individual sprites in a sheet? Looks like that's what it's doing. Also your sliders where I can't input values manually triggered me so bad I had to stop watching the gif.

If you triple click it will let you input a value manually.

No thanks. Code completion makes my life so much easier.

Respect kind of restored, but that's very unintuitive. They should just be input boxes so it's immediately obvious. Anyway cool project user.

You can get that in a real editor.

Do you code while wearing a penis gag?

What's a "real editor", then?

It's straightforward, actually.

Single click: slide
Double click: lock/unlock
Triple click: input value manually
Quadruple click: reset to default

Thanks for the kind words, though.

I write my code by flipping switches on an altair 8800, like real men.

Visual Studio
Eclipse
IntelliJ IDEA

hahaha, yes it detects all the sprites within any sprite sheets you give it. good point I'll add a number input to the frame duration slider

echo

Best Python IDE?

you dont need an IDE for a childrens' scripting language

apt-get remove python

spyder

i can use classes when they're in main, but when i split them in diff files i get this error. pic related
(file -> new -> class)

any idea how to fix this?

considering reinstalling code::blocks

For some reason it doesn't see the main() function in your code, and cannot execute.

>childrens'
>myeeeeh I learned a simple language first, but then learned C, so now I shit on anything easier to use

Got my first taste of code on a rusty Compaq, running a BASIC interpreter, the power and usability that python has, shits on basic all day long, despite basic being 'muh hardcore' when compared to it. Get a job and quit telling people your opinions on the internet when you're this wrong about them.

>python is for babbies meme

You're trying to create a console application but it thinks you're compiling for GUI, so it expects WinMain.
Change the type of your program to console and it should work fine.

je ne parlais du su plus plus, user

jetbrains.com/pycharm/download/#section=windows

We have a guy for that

Trying to see what more I can add to pic related before I make it "official" (as in, finished). Like, suggestions or changing difficulties

YO

Python is indeed for babbies. Its claim to fame is that non-programmers like it. It's a terribly-designed language, with no redeeming features.

do you mean from 'project -> properties' ?
because it's already set as console there.

If you're not obliged to use this crappy IDE, switch to Visual Studio. It's 100 times better than this.

>Eclipse

it works just fine on dev-c
visual studio loads forever but i guess i'll just switch to it
thanks anyway

Made a little mpv wrapper because I was bored.

let arguments = Process.arguments.dropFirst()
var mpv = "/usr/local/bin/mpv".cStringUsingEncoding(NSUTF8StringEncoding)!
var volume = Arg.volume(30)
var audioOnly: Arg? = Arg.audioOnly
var urls = [String]()

for arg in arguments {
let a = Arg.parse(arg)

switch a {
case .audioOnly:
audioOnly = a
case .video:
audioOnly = nil
case .volume:
volume = a
case let .url(urlString):
urls.append(urlString)
}
}

let audioOnlyCString = audioOnly?.cString ?? []
let volumeCString = volume.cString
var args = UnsafeMutablePointer.alloc(strideof(UnsafeMutablePointer.self) * (3 + urls.count))

args[0] = cStringToUnsafePointer(mpv)
args[1] = cStringToUnsafePointer(volumeCString)
args[2] = cStringToUnsafePointer(audioOnlyCString)

for i in 0..

What objective standard are you using to determine that python is terribly designed, the code you write in it does what you need it to, it's clean and easy to read. I'll admit it has numerous downsides but it's a fucking scripting language
I can't stand it when the neckbeards on Sup Forums tell 'lesser mortals' which language they should use

I've used C, C++, Z80 assembly, BASIC, Lua, Scheme, C-Lisp, Java, Python, Lua, shell scripting for bash, and just a touch of C# and every one of those languages did exactly what I wanted when I learned the syntax with no real downsides, because I knew what I wanted to use them for, you don't use a hammer to saw a board.

The one exception being Java, fuck that bloated bullshit, but every other language is fine. Fuck yourself if you judge someone based on the combination of letters they type to get their computer to do shit

It's better than whatever retarded hipster shit he's using.

>visual studio loads forever but i guess i'll just switch to it
People always say this, what the fuck kind of a toaster are you running that can't open visual studio in less than 3 seconds?

Should I still be using regular makefiles for building latex documents?
All I'm doing is running pdflatex :\

news.ycombinator.com/item?id=1803815

Why not, especially if you have a bunch of arguments, that way you can come back to the document later and compile with 4 letters instead of having to try to remember all the arguments.

>took about 20 seconds to load
>told me i have to sign in or beat it
>crashed
. . .
>what kind of toaster
it's 4 years old, and it wasn't even new at the time. gonna get a new one when i start making money

Yes, yes, one can compensate for any language's deficiencies simply by throwing more resources at it. That's not the point.

You don't use python for resource intensive applications you dingus!

I meant throwing people and development time at it.

completely irrelevant to Norvig's argument. can you even read ?

I developed a program written in Bash to enable system settings for CSGO and desktop usage.

#!/bin/bash

# CSGO settings

cp ~/.config/openbox/csgo.xml ~/.config/openbox/rc.xml
openbox --reconfigure
pactl set-sink-volume 0 50%
pkill compton
sudo cpupower frequency-set -g performance
sudo gpu-performance
xrandr --output DisplayPort-0 --gamma 1.3:1.3:1.3


#!/bin/bash

# Desktop settings

compton &
cp ~/.config/openbox/desktop.xml ~/.config/openbox/rc.xml
openbox --reconfigure
pactl set-sink-volume 0 100%
sudo cpupower frequency-set -g schedutil
sudo gpu-balanced
xrandr --output DisplayPort-0 --gamma 1.0:1.0:1.0

rate my sudoku generator guys

pastebin.com/pCp6Hmck

please don't take into consideration the time it takes to finish

I don't think of you as a lesser mortal. I think you've been failed by the education system, which has progressively lost rigor in favor of making students more 'employable'.

doubleclick to lock, triple click to input value manually, quadruple click: reset to default
krogank9.github.io

I did read it. He misses the point, as usual.

how do you get better at programming/solving problems? doing leetcode, but some of these problems are fucking hard.

What kind of jackass develops a non web based app in Python? The languages deficiencies come from it's interprreter having to run on top of the system it's installed into. Unless you absolutely need the code to be portable RTFS you shouldn't fucking do that.
So don't use the idiocy of a fucking developer to bash an entire god-damned language, it runs into problems when people do shit with it that it wasn't designed to do. You don't make 3d apps in fucking java for a reason, and if anyone did and their program ran like shit (cough, minecraft) it'd be really fucking obvious why.
God damn you motherfuckers are stupid

I'm self taught you fucking pavement ape, and I shit out more quality code in one night then you will in your whole fucking career

Quintuple click to enlarge?

not programming, go away

Absolutely disgusting, and let me show you why:
Project requirements just changed, you need now need to make this work for a 16x16 board as well.

And just like that you now have to rewrite the entire thing because you relied on so many magic numbers.

>as usual.
explain

>magic numbers
i could give them a formula, but i just wanted a sudoku
>implying that would be an actual project change of scope
lol ok senpai
moreover, this is my own project, and i know the scope of my project will never change

find yourself something you want to do (make a hentai game, etc) and get to it. gonna make you better, solve real problems, and i even get a hentai game at the end

You should follow best practice in everything you write, it makes you a better programmer but more importantly

STOP WRITING SHIT CODE

You asked for a r8, m8. With slightly more effort you could have made a general solution that looks better and is easier to read.

>I'm self taught you fucking pavement ape
Touched a nerve, did I?

>and I shit out more quality code in one night then you will in your whole fucking career
I don't disagree that you write more code than me in general, Python (and C, C#, Lua, go, and most other mainstream languages) force you to write far, far more code than better languages because their capacity for reuse is so limited.

>Touched a nerve, did I?
Actually yes, I had a series of negative experiences within the academic circle, that if someone accuses me of being institutionally taught I actually get really pissed.

>their capacity for reuse is so limited
There's a concept called black-box abstraction wherein you can write a module that gets reused across multiple areas in the program, acting as a self contained unit. You use the black boxes you have to make bigger boxes, until you have a program that does whatever you need it to, this helps keep code modular, reusable and maintainable.

I usually dump functions I like to a header file that I can call whenever I'm writing something else, I can boiler plate it in later, but I've got my own little library of code running
I only write good code because there was a time I wrote really shit code, and developed good habits to compensate

>implying i don't have other things to do with my day
senpai if you don't understand scope then you're the shit programmer
i wrote a (very slow) sudoku generator. i was not seeking nor planning for a general solution. further, if you can't see how easy it is to generalize that code, you're the asshat. those magic numbers are hardly magic.

>easier to read
seems easy enough to read, but then again i just wrote it

Trying to implement RAFT consensus protocol. I've watched 3-4 lectures on it, is there a nice statemachine diagram showing how a single computer in a RAFT network behaves?

...

Why did you post it if you didn't want feedback?

>It's better than whatever retarded hipster shit he's using
That would honestly be a miracle. Eclipse is trash. It's written in Java and it runs like shit (I guess that's redundant).

It doesn't take a toaster for Visual Studio to run like shit, and you don't and shouldn't need a high-end machine to program. I do all my dev work on a $180 machine and it runs like a dream because I don't run shitty bloated software.

Visual Studio is bloated as fuck. You could try Qt Creator, turning off the plugins you don't need (you probably don't need the vast majority of them). It runs a lot better.

> typedef for uint ==> use uint32_t or whatever standard way
> Methods badly named (validate what?)
> Useless variables such as "counter"
> Not parametric => Magic numbers
> Put fucking spaces after commas please
> fillBoardSquare called in square, no just no
> Computes stuff twice (such as i%3)
> Sudoku sudoku; sudoku.print(); ==> Sudoku().print()

Sweet

And to think I was just trolling

i have always used code blocks for c/c++ i love it

Eclipse, for general development, Visual Studio for Windows specific shit software

PyCharm

>CSGO
terriburu taste, fuck off

You fuck off, CS:GO is the shit. Get back to your League garbage.