/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Previous thread:

Attached: (You).webm (1280x720, 955K)

Other urls found in this thread:

my.mixtape.moe/aeqocy.zip
github.com/rootcoma/cclife
docs.rs/im/10.0.0/im/
rustjobs.rs/
twitter.com/NSFWRedditVideo

nothing

What the fuck is up with python devs and not understanding separation of concerns?
So we have the Mongoengine package--it's a wrapper around an ODM(ORM) for MongoDB, built on top of PyMongo.

>You want to build an application composed of more than one .py file?
>Sure thing! Just instantiate an instance of mongoengine and use that specific instance to define literally every field of the class definition for ALL of your models.
>You want to put your models in more than one file?
>oh shit you better instantiate it in __init__.py and import it in all of your files
>be careful about circular references too bro
What the fuck.
What is wrong with Python devs

>using hipster shit like sneklang and mongoloiddb
you deserve all the suffering, user

>What are you working on, Jow Forums?
Trying to get some progress on my image glitching script, but instead spending time conforming to pep8 formatting.

>implying I have a choice
Here's my list of options--they apply to you as well:
>JAVA
Jesus fucking christ. There's enough Java EE running around in this company, I'm not going to add to it.
>Node.js Express
Strictly speaking the environment wouldn't be so bad if it weren't for the fact that it was Javascript.
>C#
They won't pay for a copy of Visual Studio.
>Golang
Hahahahahaha I don't have any coworkers that actually know Golang so that's fucking stupid.
>C++
Oh yeah, let's just reinvent the wheel for the nth time, I'll start from TCP sockets

I welcome any non-idiotic ideas you have

>Python and MongoDB is hipster shit
How's your Haskell job hunt going?

Will you ever post source?

Ya I posted source before and I will post it any time you want. Want a tar of my WIP?

Sure. I would like to see how you did it.

Do it.

>Paying for programs that people worked hard to make
NJVYC-BMHX2-G77MM-4XJMR-6Q8QF

In my defense I never actually used enterprise features. Just old plain community features.

what to code and put on my shithub to impress hiring managers?

Blockchain in the cloud on an IoT device

with AI

my.mixtape.moe/aeqocy.zip

Written for python2 at the moment.

Requires pyopengl, ctypes, PILLOW, and pysdl2. All of those should be available through PIP. If you are on windows pysdl2 takes a few extra steps though.

You can get console by hitting `

Commands are
record
screenshot
play
stop
shuffle
list
add
all
load
mov
clear


Outside of console mode you can use 'a' to play and 's' to stop playing. - and = will zoom in and out and arrow keys can navigate around the image.

Let me know if it doesn't work or if you have questions.

This code iterates over an ArrayList and selects the elements with lengths over a threshold to copy them into another ArrayList that will later on be printed as a list of results:

public static ArrayList filter( ArrayList listStrings )
{
for ( String s : listStrings )
{
if( s.length() > threshold )
{
listResults.add( WHAT GOES HERE? );
}
}


The problem is that I don't know how to reference the current element of listStrings dynamically so it will give the proper one on every iteration. What do I write in there?

s

listResults.add(s);
bruh...

Attached: 1522137189550.jpg (240x240, 10K)

If I want recursive, polymorphic, reconstructible types, is Hindley-Milner what I'm looking for? I know HM gives me polymorphism and there's a type reconstruction algorithm, can the types be made recursive?

what the other guys said. foreach already accesses the right element for you and you don't have to worry about it. Remember: in java, object identifiers are actually references passed by value

Will realloc shrink to fit?

I'm actually pretty lazy at work most of the time except for stretches of high productivity and achievement

Why do I still feel like a failure?

Attached: 1517775083025.png (433x639, 245K)

You mean if the shrink operation leaves the remaining data in the same place? There's no guarantee which is why realloc always returns a new pointer.

But I believe this was one of the first things I tried, hours ago, and the compiler told me to fuck off because the data types didn't match or some shit. Of course the array has Strings, and s should be a String too... it's a mistery to me.

Only if it feels like it.

That's fine. I just want to know if it's reasonably expected to happen in practice for a huge buffer.

Let's say I have a class named Enemy. Enemy has position, health etc.
How would you implement this in functional programming language if you can't have variables?

Attached: 1514521419448.jpg (320x320, 27K)

you can have variables they're just usually immutable, you'd create a new object with the updated values

I've decided I want to learn C. As a starter project, I was thinking some terminal app that has a few keybinds. Doesn't need to be cross-platform (Linux only). What should I be looking at? Curses? Google is fucking useless.

What do you mean? It's not like you don't have values

You can't have enemies in FP. In FP, everyone is friends because we're civilized people, unlike dirty POO monkeys.

Curses is great. Here's an example github.com/rootcoma/cclife

>How would you implement this in functional programming language
By recreating the entire game state from scratch every frame and generating incredible amounts of garbage in the process. FP is useless for games.

Depends on what you want them to do.

^this

You'll probably have an environment/state containing a list or some other data structure with your Enemies, and you'll have functions that take this state and returned a modified state. In Haskell, this is idiomatically done using the State monad.

Hi! I'm a professional Rust developer. I've used Rust since v1.0. Ask me anything!

Attached: steve klabnik.jpg (1400x933, 384K)

Why haven't you learned Haskell yet, Jow Forums?

How much soy a day do you recommend?

docs.rs/im/10.0.0/im/
Now it's basically Haskell. Just without the Monad autism.

>no HKTs
>no rankNs
>no constraintKs
>no GADTs
>no dataKs
0/10 you tried

Attached: 1453648836231.png (840x720, 681K)

>no adoption
memelang confirmed

>only using languages other people use
cuck

Attached: 1453651274892.jpg (263x217, 27K)

What programming language can you recommend me if I want to suck cocks but I'm not gay?

Python

>if I want to suck cocks
sounds about rust

>rustjobs.rs/
>There are no open rust jobs anywhere in the world.
>That doesn't sounds right... post a job.

Attached: 729.gif (340x340, 137K)

>rustjobs.rs/
What are even those companies marked as using rust?
>npm
it doesn't have single line of rust code in it.

fucking kek

Is this even a real site? Because if it's a joke then fucking kudos.

it is real

Lots of people may think that the kid in the webm is a retard, but actually he is a pen-tester trying to find an exploitable bug to abuse,
and as shown in the webm, he(girl) already found a weakness point in the 1st hole, and he(girl) now trying to abuse the second hole

>he already found a weakness point in the 1st hole
>and he now trying to abuse the second hole
You are violating the Rust CoC. Cease and desist.

Attached: 92148198512.jpg (225x225, 7K)

Javascript is best scrypt.

Javascript belongs in a crypt

>Say Rust BTFO C++ full system for programming low level
>Rust people write web developer thing and want Python,Ruby audience.

are we jewgle /codejaming/ family

>only ever have motivation to study when I'm extremely tired
>constantly worried I'm not actually learning the material because of this
>panic that I'm only following along with instructions and think I'm not actually learning the concepts
please fix me /dpt/

Attached: 1500600335961.jpg (672x672, 87K)

[insert tirade about how learning is for retards and real employed coders are ignorant /dpt/ twats]
Hope it makes you feel better. I know it makes me feel better whenever I sperg out at CS students.

Do you use Light or Dark theme and why?

The dark theme, because I'm a 1337 hacker.

they're right, but they failed to mention that your function should return an arraylist of strings, not of ints. That's what the compiler was telling you too.

this

Usually dark because I like it.

My monitor have no backlight, so even light theme will be dark

dark, it's easier on the eyes in all lighting conditions.

maybe you're learning the wrong subject then
if it's just programming then find something you want to make (calculator or game) and just do that. doesn't matter how shit it ends up, you'll learn exponentially more than just reading and/or following instructions.

Dunno if this is better asked here or on webdev general, so whatever.

Is there some plugin or whatever that lets me load the XUL Firefox addons and easily tweak them? Doesn't need to necessarily save the changes to the addon, I just want something to facilitatte hacking the codes of various addons together.

Attached: 28872566_1354156821396784_8092632608107659264_n.jpg (522x521, 36K)

I've been stuck on this for a while but can't seem to find a good method:

currently i have a python main that runs functions. i have a try: around the main and an except KeyboardInterrupt: to interrupt the script if i have to.

However, if the functions in the main were started successfully, the except doesn't catch the keyboardinterrupt

How can i make the except work *over* my main functions?

The book I'm reading, says that this code is weak because it destroys the pointer and thus it would have to be used only once(he is showing some uses of pointers and whatnot):
#include
#include

#define TRUE 1
#define FALSE 0

int find_char(char **strings, int value)
{
assert(strings != NULL);

/*
** For each string in the list ...
*/
while(*strings != NULL) {
/*
** Look at each character in the string to see if
** it is the one we want.
*/
while(**strigns != '\0') {
if(*(*strings)++ == value)
return TRUE;
}
strings++;
}
return FALSE;
}

But I fail to see how it would destroy the array of pointers. Wouldn't the original variable(array, for example) still have the address saved and recalling find_char works again?

(*strings)++
This expression mutates the char* pointed to by strings.

Post code snippet. Your verbal explanation is subpar.

You're complaining about JS but using python? Fucking lol holy hell

let's say initialize() function in main begins successfully, keyboard interrupt will not register until initialize() is finished (since the try was successful), which completely defeats the purpose of the interrupt, as I need it to work instantly, at all times. I know this is like a babby question but it's never had to do it.

Attached: ki.png (494x156, 54K)

Do you need to keep running after you catch the KeyboardInterrupt? Or is the catch only to cleanup and then you exit after?

why is async programming in rust such a fucking mess?

You had read SICP?

Why did Mozilla hire a fucking ruby on rails dev to work on a systems programming language?

the catch sends the command "1tR" to all devices, which is universal ascii kill signal.

So no, don't need to keep running after. It's pretty much an E-stop I guess.

What language is the easiest to deal with asynchronous?

Have you ever VisitorPattern'd an AbstractBeanFactory?

>What language is the easiest to deal with asynchronous?
Erlang.

Weird. The following works for me as expexted (both on my laptop and RPi):
def do_thing():
a = input()

def main():
do_thing()

try:
main()
except KeyboardInterrupt:
print("interrupted")

Does this work for you?
What happens if you kill SIGINT your program externally?

What programming language is the least normie?

>The kind of people who need types to hold their hands

Erlang.

I don't know why you current logic doesn't work. As soon as the interrupt comes in it should be caught.

You can try to use the atexit module and then don't catch the interrupt and register a function to be called before the script exits
def kill_devices():
# send kill to devices
pass

import atexit
atexit.register(kill_devices)


I would think that would act the same way as your current logic, though. I would be interested in what initialize is doing that it cannot be interrupted.

Haskill

I think maybe because each function has a time.sleep() in it, which is "blocking" right?

try putting a time.sleep(5) in your do_thing function and see if it still works

>not being a coding wizard

www twitch tv/nybblesio

sleep shouldn't be an issue from what I can tell
import time

def init():
print "before"
time.sleep(5)
print "after"

try:
init()
except KeyboardInterrupt as e:
print "caught"

Output:
before
^Ccaught

Anyone here use Go?
Why is it hated so much?

It's too simple for anyone but a brainlet to use without feeling constricted.

However within that category of languages I think it's better than the alternatives e.g. POOlangs and Python-tier scripting langs.

lol no generics

hmmmm idk then. thanks for the help anyway. I guess I'll have to take a different approach

>It's too simple for anyone but a brainlet to use without feeling constricted.
It's not like most Go critics are able to make good use of advanced language features.

I use go both privately and at work. It's great because Go APIs tend to be simple and most packages are permissively licensed. There are some great projects created in Go, it's definitely worth learning/using if it fits the circumstances.

lol no generics

How do I learn good practices in C?
To increase the quality and security of my code.

Attached: 1.jpg (750x740, 445K)

>Don't use pointers needlessly
>watch your pointer and array use carefully, >write unit tests,
>use CICD,
>use valgrind and static analyzers on your code