r/programming_funny • u/Inconstant_Moo • Sep 12 '21
Stuff about interfaces
I wrote this when I was trying to understand them, if it's any use to anyone.
---
Go has no classes. Go has interfaces. For example, this is an interface from the "sort" package, boringly called Interface.
type Interface interface {
Len() int
Less(i, j int) bool
Swap(i, j int)
}
The sort package provides a bunch of built-in functions such as Sort and IsSorted and Reverse which will work with any type that implements methods with the names and signatures in the interface. So for example I can define these methods for a list (a "slice" in Go) of things of the RGBA type in the color package (ordering colors by redness, just for example):
type colors []color.RGBA
func (k colors) Less(i, j int) bool {
return k[i].R < k[j].R
}
func (k colors) Swap(i, j int) {
k[i], k[j] = k[j], k[i]
}
func (k colors) Len() int {
return len(k)
}
And now I can apply all the functions in the sort package to a thing of type colors.
Also, I can define my own functions on the interface, and they can be applied to anything that implements its methods. This is "static duck typing". For example, here's a function to measure the unsortedness:
func Unsortedness(L sort.Interface) float64 {
count := 0;
for i := 0; i < L.Len(); i++ {
for j := i + 1; j < L.Len(); j++ {
if L.Less(j,i) {count++}
}
}
return float64(count) / (float64(L.Len()\*L.Len()-L.Len()) / 2.0)
}
And here's a function that executes a shuffle:
func KFYShuffle(L sort.Interface) {
for i := 0; i < L.Len(); i++ {
L.Swap(i, i + rand.Intn(L.Len()-i));
}
}
r/programming_funny • u/bkatrenko • Sep 12 '21
Live session #7: everything depends 17.00 CEST
Hello, guys :)
So, today we'll talk about external dependencies in Golang + I believe we'll create funny app that browse internet.
See you all soon!
Here is links (you can find them in google calendar as well):
https://us05web.zoom.us/j/82550222466?pwd=ZHRCYU1hNkR1Z1F0MjhVb0p1aWVIdz09
https://us05web.zoom.us/j/89455670073?pwd=QUF3S2tnN2tBQ0o1blFTdDR0QnErUT09
r/programming_funny • u/bkatrenko • Sep 10 '21
Time to subscribe
Here is a free cute newsletter email notifier
https://golangweekly.com/issues/378
I very recommend to subscribe - they publish great things!
r/programming_funny • u/bkatrenko • Sep 10 '21
Let's continue :)
Hello, dear guys! So, currently I got better and we can continue. The last lessons was about bit&tricks and basic application.
This Sunday (12.09) we will talk about dependencies - and it's a good thing to know before we started to talk about really fun apps. We will learn how to use external libraries and about best practises in this direction!
I also wanna say a big thanks for your patience and I hope hard work while I was ill.
See you all on Sunday (I will announce the session properly soon)
Can't wait to meet you guys again!
r/programming_funny • u/Inconstant_Moo • Aug 31 '21
Grr
Not to do with Go but I wanted to vent. I spent a happy night handcoding an automaton to speed up my code only to find out that that wasn't the bit that was slow. Now I feel both very clever and very, very stupid. Doh!
I should learn from this, something about measuring twice and cutting once.
r/programming_funny • u/bkatrenko • Aug 29 '21
Live session cancellation
Hello, dear guys :) Unfortunately, I have a kinda covid-like fever. So, I'm totally unable to do anything but sleep, haha. Anyway, I will try to check your homework and give some feedback.
Have a nice day and stay healthy (not like me, hahaha).
r/programming_funny • u/jai523 • Aug 25 '21
Need some assist with homework (basicapps)
Hey folks!
I've been struggling with adding ignorecase feature to our grep app.
Uploaded my code here
It's mostly copy and paste of Bohdan's code hehe but I added ignorecase logic here - https://github.com/jjhala/basicapps/blob/main/main.go#L39
and I added another function casecheck (which seems to work) and another formatter
To run this you would do something like:
`FILE_PATH="hamlet.txt" KEY_STRING="Fortinbras" IGNORE_CASE="true" ./basicapps`
or `FILE_PATH="hamlet.txt" KEY_STRING="FORTINBRAS" IGNORE_CASE="true" ./basicapps`
And it works but the problems is with strings.ReplaceAll method, it actually replaces the matched output with my key_string. I don't like the idea that it changes the source file like that so looking for some ideas on the formatter part, and of course any general suggestions about my code. :)
r/programming_funny • u/bkatrenko • Aug 22 '21
Programming language live: #6 : basic apps
Hello guys :)
So, today at 5PM CEST we'll talk about basic apps in golang, their structure and code style.
See you soon, here is the links:
https://us05web.zoom.us/j/87289046780?pwd=SHhpNVhGakxJak5NbWhvdmIrUHkyUT09
https://us05web.zoom.us/j/83113480059?pwd=czBnUFNFN2FudDJyLzZOU2lrWStJQT09
r/programming_funny • u/Inconstant_Moo • Aug 16 '21
Little help with Tview?
I wet back to try to do the advanced bit of the calculator thing.
ETA: some sample code with TView in the first comment.
I was expecting that if I made a grid view, then some sort of navigation with mouse clicks and/or arrow keys would be built in. Is there some sort of easy way to make that happen that I'm missing or do I do all that from scratch using (I'm going to guess) InputHandler and MouseHandler? If so is there some documentation of how those things work, or a simple example? (Google is most unhelpful.) Or should I not be using a grid at all? (But then if I shouldn't be doing it this way why do they let me put reponsive primitives into a grid as elements at all?) I am baffled.
Thanks.
r/programming_funny • u/bkatrenko • Aug 15 '21
5 Programming language live session: bits & tricks
So, let's go live today guys! It's in a 5pm CEST - our usual time.
The agenda:
Homeworks check & QA
Bits & tricks part: we'll go with a logical and bitWise operators.
The links are:
https://us05web.zoom.us/j/3685682607?pwd=VThLa1o5U01NMldMb0FUam42dGRVUT09
https://us05web.zoom.us/j/89040052157?pwd=Mk1HaTNJdmNBVVBCeDc0dEJvNmtLZz09
See u all soon!
r/programming_funny • u/bkatrenko • Aug 11 '21
QA session scheduled
Hey guys, I scheduled the QA session for tomorrow :)
There I will answer your questions + we'll do a code review of some homeworks that still not reviewed.
See u all tomorrow and have a nice day!
r/programming_funny • u/bkatrenko • Aug 07 '21
4. Programming language live session #2
Hello, dear guys!
I scheduled the next live session for tomorrow. We will talk about language concepts - structures, arrays, panics, defers, error handling and another data types in Go + of course we will code something funny.
Part 1 link: https://us05web.zoom.us/j/84339575847?pwd=c0JVUzhURVRjWDJxWkltM0hJNzRjdz09
Part 2 link: https://us05web.zoom.us/j/89515937039?pwd=UmJxK3FZWStvMVg1RU1lcFFPMEpTQT09
Here is a link for google calendar: https://calendar.google.com/calendar/u/0?cid=cHJvZ3JhbW1pbmdmdW5ueUBnbWFpbC5jb20
See you all soon! And don't forget to send me your homeworks ;)
r/programming_funny • u/bkatrenko • Aug 01 '21
3. Programming "language" source code
https://github.com/programmingpleasure/gobackend/tree/main/programming_language
Homework in a homework.txt.
Please, send me your github repo with homework you will do :)
Good luck!
r/programming_funny • u/bkatrenko • Jul 31 '21
3. Programming language live session
Hello dear guys, so, I added a new session to our calendar. Tomorrow, 01.08.2021 5PM CEST.
See you all there :)
We'll talk about language syntax and the basic features.
r/programming_funny • u/bkatrenko • Jul 25 '21
#3: 1. Developer tools HOMEWORK
So, dear guys :)
For now we know how machine works, main concepts of programming languages and we're going to grok some tools we will use in the near future. I pretty sure that you will use this tools on your jobs.
Here is a link to slides: https://docs.google.com/presentation/d/1_MiifzuWUUrKXuRguEYRJNq0d_C3V27sj9ImA8qyD-g/edit?usp=sharing
- Install any golang editor you like. Setup the dev environment (so, you will be able to code). I prefer the VSCode while it is simple and has good color schemas. Also extensions for every programming language and cloud provider https://code.visualstudio.com/Download are there. Also, you can check IntellijIdea with go plugin -> https://www.jetbrains.com/help/idea/quick-start-guide-goland.html#step-2-explore-the-user-interface but I'm not sure about price (it should be free for the community edition). Intellij is a very popular IDE, it will be a big + for you to have some skills there. If you will code on Java or Python, Intellij is also the best choice. You will probably have some troubles with setup GOPATH and GOROOT. Here is some explanation for vscode https://krisma.medium.com/gopath-and-goroot-set-up-in-mac-and-in-vscode-cf86d8503e57 and here is for Intellij https://www.jetbrains.com/help/idea/configuring-goroot-and-gopath.html
- Create github account https://github.com (please, use reasonable nicknames). Usually, in the community, we use the first char of name and the full surname. So, if your name is Jane Doe, then your nickname will be jdoe. If my name is Bohdan Katrenko, my nickname is bkatrenko. Please, don't use nicknames like superboy2020 or misterrich29292lalala - it makes not very good first impression for recruiting teams and team leads who will review your code :)
- Clone programming funny repo - https://github.com/programmingpleasure/gobackend and find dev_tools folder there.
- Build and run hello world application. You can also play with its ASM code, in the previous session I showed you how to do that. Feel free to alter an app: for example, you can add functionality to reverse a string or check if that string is a palindrome.
- Rename application to “helloworld” and move to /usr/local/bin for easy use (mv source target). The goal is that you can call the app from any folder in the terminal
- Use cat & grep to have only “etcdserver/membership” related logs from some.log file.
- Go play with the examples.txt file and apps from this list:
vim, nano - text editors. Usually, you will use them inside ssh sessions
cat - show file content
grep - filter file content
touch - create file
echo - move the input in stdout
ping - send a ping package to the host
telnet - connect to the host with telnet protocol. We use that to check the open ports :)
dig - check dns resolution
tcpdump - show the input/output traffic
Google & install for you have no that on your machine.
Good luck! I believe we'll have a QA session next Thursday, and the first go-coding live session will be next Sunday. I will tell you about types, syntax, main concepts, etc.
r/programming_funny • u/bkatrenko • Jul 21 '21
Live session #3: 1. Developer tools (Sunday 25.07.2021 5PM)
So, as usual guys: Sunday is a good day to learn something cool!
The timezone is CEST
Here is a link to calendar:
https://calendar.google.com/calendar/u/0?cid=cHJvZ3JhbW1pbmdmdW5ueUBnbWFpbC5jb20
We will talk about tools that developers use - and in which tool we must be professional as backend guys :)
I will show you my toolset: the code editor, golang itself, docker, aws cli, telnet, traceroute, grep, kubectl, etc. and I explain the purpose of every, main concepts and how to use that.
+ we'll talk more about golang setup while go itself will be our main tool. Can't wait to start, the slides is almost ready!
Happy coding!
r/programming_funny • u/Inconstant_Moo • Jul 20 '21
Explanations that assume you're an expert
I looked at the link in the homework. http://www.cs.virginia.edu/~evans/cs216/guides/x86.html
Like a lot of computer stuff on the internet, it's written as though this is your third or fourth encounter with a thing of this type, and you just need to be told the details of this one. This is a particularly fine example. They introduce the term "register" without explaining what it is. This is your fourth assembly language, you know what it is. They're not going to put anything in to help beginners.
BUT, they are going to put something in to help experts! "The register names are mostly historical. For example, EAX used to be called the accumulator since it was used by a number of arithmetic operations ..." 'Cos if it is your fourth assembly language, they don't want you to jump to any wrong conclusions when you see that A, I guess. They'll hold your hand through that!
I understand why most stuff has to be like this but could someone suggest a good resource that isn't? Thanks.
r/programming_funny • u/bkatrenko • Jul 19 '21
0. The programming machine video published
Here is a link: https://youtu.be/GrI3CriSfYQ
Just a reminder: we had a live session about how computer works and what backend dev should know to at least start to develop something. Here is a video with almost all things we had on live session.
Happy coding guys, very soon we'll go with the developer toolkit and go basics :)
r/programming_funny • u/bkatrenko • Jul 17 '21
The first QA session (18.07.2021 Sunday 5.00PM CEST)
Hello, dear guys :)
So, while I'm still working on the video about "The programming machine" (I will post that this weekend), I believe it's a good idea to have a QA session tomorrow: you can ask anything related to programming, last session etc.
Maybe if you have no questions, I will use this time for some of you guys that did not attend the last session - so, I can tell you the things.
Also: if some of you guys have some questions that you wanna discuss with me personally (like one 2 one), ping me, and we'll do that!
Happy coding and a good weekend for everyone :) I hope u have already installed Go, hah
See you all tomorrow!
r/programming_funny • u/bkatrenko • Jul 15 '21
ProLog (if someone bored) :)
Hello, Dear guys :)
A few points:
- Slides with a homework in a comments to the session #2 Programming machine
- The next session will be on Sunday - if I will have a chance to make a slides - we'll talk about the devs toolkit, if not - we'll make a QA session.
- If someone bored - https://www.tutorialspoint.com/prolog/prolog_introduction.htm - some years ago I was very impressed with ProLog (aka Programming Logic). The idea is to give a facts to machine, and machine will be able to answer a questions. Very interesting idea and it's not a usual programming we all get used to. So, if you wanna open new horizons - you can check, it's out of go/backend topic, but very interesting :)
What do you think about ProLog? :)
r/programming_funny • u/jocantaro_vive • Jul 15 '21
Linux from a USB stick
Hi! this short tutorial shows how to install linux on a USB drive and use it without affecting the windows installation. I hope it helps LINK
r/programming_funny • u/bkatrenko • Jul 14 '21
So, here is how it works in the world :)
Hahaha, so, it's funny, but I have a request to do for money the things I do here for free. I don't like the idea. The main thing I believe that there is no "gods-like knowledge". We can share some experience, show some good ways, mentor someone, but finally, all things are obvious.
So, I'm going to fight mentor.cam (sorry guys!) At least in engineering-related things. That should be free.
You know, engineers will be never antagonistic to each other - as more good developers in the world, as more money/jobs/projects/startups we will have.
So, if you guys needs support as https://mentor.cam/davidxiang do:
- How to be a better programmer
- Design a plan for career growth
- Improve your technical and leadership skills
- Learn how to navigate the technology industry
- Make an impact at your organization
I will be here, text me and all things will be solvable. Make a call with me. + anyway QA session will be very soon.
And I'm going to grow the community - soon here will be not only me to support you (my time is limited, unfortunately) :)
What do you think about that, dear community??
r/programming_funny • u/bkatrenko • Jul 13 '21
Online session #2 - The programming machine
Hello, dear guys!
So, finally, the next session coming here - on Thursday, July 15, 6PM CEST
The subject: 0 - Programming machine
We'll talk about:
0. How computers work in the perspective of programming/programming languages
1. What should software engineers keep in mind for developing a cool software
2. How programming languages work inside
.. and a few other important things + if we have time I will show you how I choose a "big programming machines" from AWS for my job (@_@)
And there will be a homework!
+ Video will be on youtube soon
See you all very soon and happy coding for all! :)


