/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?


Previous Thread:

Other urls found in this thread:

github.com/deeepaaa/wassily
regex101.com/
regular-expressions.info/tutorial.html
ex-parrot.com/~pdw/Mail-RFC822-Address.html
twitter.com/NSFWRedditVideo

fpbp

github.com/deeepaaa/wassily

C is a different kind of hard, and requires a different kind of autism from video game development.

My advice for learning practical C is to use open source projects written in C, and dig around whenever you find something that breaks. Otherwise, learning the best practices can be hard, since the language has been around so long, and everyone has their own ideas of what is best.

And don't be afraid to reinvent the wheel because, for better or worse, that's just part of the C culture. Every company seems to have their own library for shit like LinkedList, HashMap, etc. Use it as an excuse to learn more of what goes on under the hood. Then go ahead and use a battle tested lib if you need it for a real project.

Ask your much beloved and highly praised programming literate anything (r/IAMA)

Thank you for using an anime image.

Why haven't you killed yourself yet

What is the point in programming?

to kill time until death

What do you think about using unikernels in production environments?

Please stop using anime on a tech related discussion board

>implying this isn't a tech discussion board framed in the context of a site that has a culture of anime being applied to a myriad of aspects of our daily lives and interests

In other words, "no".

>What are you working on, Sup Forums?
Trying to figure out how to move data from one point in the cloud to another point in the cloud without it routing through my on-premise server.

> Trying to figure out how to move data from one point in the cloud to another point in the cloud without it routing through my on-premise server.

usually not possible, unfortunately, but for many cloud services (e.g. AWS, I think) traffic inside the same datacenter is free. So e.g. you could do an S3->EC2->S3 copy for $0, AFAIR.

can someone help me, I don't understand this error

im using requests, I do a post request and I get the answer and I get a AttributeError: 'dict' object has no attribute 'loads'

asd = res.content.decode("utf-8")
tjson = json.loads(asd)

I'm actually trying to move data within an Azure SQL Server instance to another database in that instance, but the Azure SQL Server is a standalone application, so I can't run a .NET application on it like I would if it was installed on a Red Hat Linux server locally.

I'm wondering if I should host up an azure application service or something; good point on the in-cloud transfer, that might be something I can abuse.

>requires a different kind of autism from video game development.
Yeah, I get that. I'm not really interested in the programming aspect of video games.
The kernel and driver stuff sounds interesting though.
>My advice for learning practical C is to use open source projects written in C,
That's what I planned to do.
>and dig around whenever you find something that breaks.
What do you mean? Finding something broken then fixing it for an open source project?

Thanks for your posts, I guess I'll stick to C for now.

you probably shadowed the json identifier with a dict somewhere by doing something like

json = {}


or so

Well it seems like to me, tjson has no attribute "loads"

It's a dictionary and in Python, dictionaries don't have a method called "loads"

idk shit about either azure or SQL server. Maybe it has something like postgres where you can use an SQL command to connect to another postgres server and then dump over tables. IDK how billing works on azure though, they would probably bill you for the traffic.

Maybe you can just use the replication system

hwat hwanime

eva

waitwhat.
Is that Shinji?

of course

argh, omg thanks that was the problem

I am in think python's third chapter and wanted to try out importing and using functions in the interactive shell.

Pic related is what I get.
The file is in the root folder, as it should be

this is the code
def print_lyrics():
print("I am a lumberjack, and I am okay with that")
print("I am sleeping all day and working all day")

def repeat_lyrics():
print_lyrics()
print_lyrics()


repeat_lyrics()

any assistance would be a huge improvement on my case.

did you try


>>> import filename
>>> filename.print_lyrics()


?

forgot pic

no.
I did that and it made it work.
Thank you.

import
import Lyrics_man.py
import Lyrics_man.py
repeat_lyrics
import Lyrics_man
ArithmeticError
repeat_lyrics
repeat_lyrics()

wtf

Well, it would be easy enough if what I'm doing could be easily done in SQL, but it's going to need to run through a .NET application for some transformation logic.

You can also do something like

>>> from Lyrics_man import print_lyrics
>>> print_lyrics()


or even
>>> from Lyrics_man import *
>>> print_lyrics()
>>> repeat_lyrics()

which dumps all of the functions and variables defined in Lyrics_man into your current namespace (not generally that recommended though, 'cause it clutters things up)

I was trying some stuff out.
I am new for fucks sake.

And you can't do that transformation logic in SQL? I bet you can...

Other than that, guess your only option is to spin up an instance and run some code.

> Is data transfer between Azure services located within the same region charged?
> No. For example, an Azure SQL database in the same region will not have any additional data transfer costs.

If it didn't work the first time, what made you think it work the next 10,000 times?

Nah man, don't you know you're never allowed to make a mistake? :^)
Don't let him turn you off of programming. Not all of us are fuckheads.

implementing my own React

Ever hit a nail with a hammer, made it look strange and still tried to continue with the hopes that MAYBE, the nail will still get inside?

>The kernel and driver stuff sounds interesting though.
It's harder to learn that on your own, but definitely doable (since at the very least, I did it). Get used to using virtual machines early, since that'll be your bread and butter for testing kernel work. And don't be afraid to download the linux kernel source code and start poking around. Even if you don't understand the code at first, the documentation is pretty amazing, and it will teach you a lot.

>Finding something broken then fixing it for an open source project?
Yeah, but starting out, you don't even have to fix it. Just being able to navigate the code to the point where you can understand why things are broken is a huge challenge at first. But you'll learn a lot that way.

Also, a solid way to get used to a C codebase is to choose one message the program outputs, figure out where it lives in the code, and change it to say something else. It's mostly a matter of code navigation, but code navigation is one of the most important skills for C, since C codebases are often fuckhuge. Plus it feels good to make a tangible, easily verifiable change in a program.

>I'll stick to C for now.
It sounds like the right choice for you. Have fun!

A nail isn't a computer. It's literal. 2+2 will always give an output of 4 no matter how many times you repeat it

>Read trump's tweets comments.
>Massive amounts of retards.

wew lad

Not even remotely related to programming.

Piss off, wankuh.

What are you talking about? Trump will ban Haskell once and for all.

There's a small os written by MIT called xv6 the source code is online along with the book which explains each line of the code. Maybe start with that

For kernel I liked Robert love. Also you can try os161 for os assignments

What would you recommend to learn regex? Doesn't need to be advanced at all, just need to parse some strings in a nicer way

This. I also recall he tweeted that Java was created by the Chinese to make American software uncompetitive.

Use an online regex tester such as:
regex101.com/

And read this:
regular-expressions.info/tutorial.html

And google anything else you need to know to parse that particular string.
Like anything else, the best way to learn is by doing. After using regex several times it will start to come naturally.

Yeah. It's useful for some cases. But be warned, it's not a end all be all solution.
ex-parrot.com/~pdw/Mail-RFC822-Address.html

wew lad

won't be doing anything that complex, I've never been a fan of it, but for short strings it seems a lot easier in some languages than traditional ways.

thanks, I'll have a go

Well, coming from a blue collar household, I didn't realize that.
What I can say though, that coding IS fun. Plus I get to learn so much from my own mistakes and other's advice.

Worth learning Golang? I hear that people around Sup Forums seem to like it. Is it just a meme?

Go is about 92% meme

Not really, the only thing that it's got going for itself is goroutines but you can have that in other languages as well.

Protip: ignore posts containing either "wtf", "omg", "XD", "fuck", "tfw" or "retard"

Thank you for not using Himegoto image

>I hear that people around Sup Forums seem to like it.

Where the fuck did you hear that?

Since your post contains all of those phrases, I've ignored it.

>"I am easily triggered"

Don't ever forget that coding is fun. When you stop having fun you're going to stop learning things. Make sure you're doing stuff that you like.

its ok, I use it at work

it has some really annoying aspects to it, and the community is extremely shit and deluded. If you say anything that can be remotely construed as a criticism of anything related to go, people will jump on your throat. Or if you just mention that you also use C or C++ etc, they will declare you insane. OTOH when there is any progress, the crowd starts chanting "we realtime now, we realtime now" etc. If you ask or question any of the internals of the go implementation, people will scream "YOU'RE NOT SUPPOSED TO CARE ABOUT THAT!!!!" at you.

Just don't let yourself get infected with the toxicity, and you'll be fine.

But it is a good & productive language if you want to get shit done, like implementing HTTP APIs and other such services. The lack of generics and exceptions is annoying at times, but you can live with it. It has a decent amount of libraries etc (we use the go AWS SDK a lot to interact with amazon etc)

the type-system is also not as powerful as one might wish, as a result there are a lot of interface{}'s being thrown around in stead of properly safe generics as you would have in C++. But you can make do.

while that's true, in many other languages they are not nearly as well-integrated. since they are a "default" feature of go, everything plays nice with them. I've used coroutines etc in other languages, and it's often not that easy.

OTOH goroutines, channels and the other primitives go offers are really not the end-all be-all solution of modelling concurrent or parallel problems either. They have a lot of subtleties and edge-cases that can cause hung goroutines, leaks (goroutine leaks, filehandle leaks, slice leaks, ...) etc.

Also, it has occurred in some cases that I would've preferred to just have an asynchronous, single-threaded i/o event loop instead of spawning a shittonne of goroutines, but you don't get to chose, in that case goroutines are kinda forced on you. but oh well.

I'm trying to pass a member of a struct to a function but I get an error "Request for member year of something not a structure or union"
typedef struct {
int year;
int month;
int day;
} Date;
char *parseInt( char *s, int *value )
char *parseDate( char *s, Date *d )
{
/* The date looks like this '2016-10-05', so read an int, skip the
'-', read an int, etc
*/

parseInt(s, d.year);//Error here!

d.year is an int, but parseInt expects to receive an int*.

try

parseInt(s, &d.year);

pretty cool

also, parseDate takes a Date* not a Date, so you can't write d.year, you have to write d->year (or change it to not take a Date* but a Date instead)

so you have to do something like
parseInt(s, &d->year);

actually.

how do I get my dick sucked by the cute girl who's sitting next to me in programming class?

Impress "her" by not being a sperglord and just asking "her" out. Extra points if you shower, brush your teeth, and groom regularly.

Guys! I got an A in C Programming! I know that is laughable to many of you but it is quite the accomplishment for me at 29. If you were in my shoes, which language would you learn next; C++ or Java? Those are my choices as of now.

what are you implying here? that it's a dude?

what do you mean you got an a in C? I would go for c++ and java.

Show her your gentoo install with haskell source code open on emacs.

java if you want to go into android programming or do web services etc

c++ if desktop applications, games, low-level applications (microcontrollers, operating systems, drivers, ...) or anything performance-critical are more your thing

java is quite a bit easier to get your head around, there's less stuff to learn about.

I'm making a chinese name generator, any ideas?

ideas for what?

I'm not implying anything user. Your subconscious seems to be fixated on something.

ching bong ding dong

The names, sorry for not being specific enough

thank you.

are functions in a bunch of languages the same as methods in java?

About to take my programming final consisting of trick multiple choice questions which don't test my ability to write a program at all!

Wish me luck :')

what else can be added?

methods stem off of functions, but functions are just java classes which are just java files

>;
Shit, too much C

I'm not gay user, I promise!!

In my college, it was required to learn C before C++. I got an A in that programming class is what I meant. Do you mean try to take both at the same time?

>java is quite a bit easier to get your head around, there's less stuff to learn about.

Heh. I had someone tell me the opposite. He said since I know C, if I know java; I will know both. He said C++ is basically a hybrid of java and C. -Some guy from India.

There is a *lot* more to C++ than that. Javas type-system is not nearly as powerful as C++s, for instance. C++ also has its own standard-library which is very different from java, and many concepts that make no sense in java like xrefs/rrefs/etc, move semantics, destructors, smart pointers etc

Pretty low tier, user. At least do an array for first name and last name and return a whole name.
You could even give the function an argument to determine whether you need a first name, a last name, or both.

user doth protest too much, methinks.

...Are you okay there, user?

>smart pointers
So that's how those kids get head shots every time.
Which is better for getting an entry-level job? Java or c++

Obviously the program have to dynamically generate its own name

probably java, I'd rather employ an inexperienced java programmer writing shit java code than an inexperienced C++ programmer writing shit c++ code that has security issues. If I'm looking for a C++ dev, I'd definitely put the bar a good deal higher.

But both are very in-demand languages, so ultimately learning either is a good time-investment for your career.

I have mandatory programming as a team class in 5 minutes set up by by work to the entire IT dept, which I'm pretty sure is just a free demonstration to try and get us to take their class. Please end me

Smart pointers are pretty much pointers that know when they're going to be dereferenced so that go out of scope.

congrats on giving the worst explanation of smart pointers I've ever read

java is master race

What do I win?

???

How do I write a program to stop me from reading /r9k/'s posts from girls who are hopelessly lonely just like me.
It just fills me with wanton desire to find girls like that and it's not healthy.
I just want to walk the pious path and be a programming literate just like our exemplary poster here.

don't go to r9k then???
next

Start small, do some "Hello World" and "FizzBuzz" programs.

Eventually, you'll be able to do slightly more advanced things, like basic automation.

Use this knowledge to do some small freelance jobs for office workers trying to make their life easier.

Eventually, you'll have enough money to buy a fairly cheap pistol and take a class or two on how to use it.

After that, simply load the weapon, put the barrel in your mouth pointing towards the top of your skull, and then pull the trigger!

a dumb pointer

> /r9k/
> girls

you got memed, friendo :^)

also
sudo sh -c 'echo -e "127.0.0.1 www.Sup Forums.org www.Sup Forums.org\n127.0.0.1 boards.Sup Forums.org boards.Sup Forums.org\n127.0.0.1 sys.Sup Forums.org sys.Sup Forums.org" >> /etc/hosts'


you'll thank me later

Would saying that smart pointers are just pointers that enforce some encapsulation to assure that you use them in stricter ways that let you be assured of their more narrow space of potential states.

that's also wrong

>wrong
Could you please correct it? I'd learn a lot from that.

I suppose in a sense that is correct, if you consider e.g. "dangling"/"leaked" to be states of the pointer

but there's really not much point in trying to give a description of "smart pointers" in general; rather, one should give a description of the two main kind of smart pointers (std::shared_ptr and std::unique_ptr) individually, since they achieve rather different things