Skip to content

Instantly share code, notes, and snippets.

@mickelsonm
Last active August 29, 2015 14:16
Show Gist options
  • Save mickelsonm/d75f26d6a67714a35f46 to your computer and use it in GitHub Desktop.
Save mickelsonm/d75f26d6a67714a35f46 to your computer and use it in GitHub Desktop.
Blogging, maybe?

So, I decided to keep it pretty light-weight tonight. Just wanted to vent a little on coding practices:

If you name your return types, what's the point in returning with those names?

  • BAD
	func GetAllTodos() (todos Todos, err eror){
		db, err := sql.Open("mysql", database.ConnectionString())
		if err != nil{
			return todos, err //WHY?!!?!??!?!!?
		}
		defer db.Close()
		///more goodies...
	}
  • GOOD
	func GetAllTodos() (todos Todos, err eror){
		db, err := sql.Open("mysql", database.ConnectionString())
		if err != nil{
			return
		}
		defer db.Close()
		///more goodies...
	}

If you plan on returning one thing...return the type and don't name it!

  • BAD
	//REALLY? WHY are we naming it then?
	func (t *Todo) Get() (err error){
		db, err := sql.Open("mysql", database.ConnectionString())
		if err != nil{
			return err
		}
		//more goodies...
	}
  • GOOD
	func (t *Todo) Get() error{
		db, err := sql.Open("mysql", database.ConnectionString())
		if err != nil{
			return err
		}
		//more goodies...
	}

Straight from Programming Fundamentals: Name your variables appropriately!

  • BAD
	func ReallyComplicatedFunction() (returnTypes ReturnTypes, err error){
		//imagine this function being really complicated...
		//lots of loops...
		//channels, go routines, and pieces being put together...
		//then...
		//you...
		//see...
		shazaam := false

		for rows.Next(){
			shazaam = true
			//process some rows

		}

		if shazaam == false{
			//more stuff to do...
		}
		//more goodies...
	}

First of all, WTF is shazaam and what does it do? At first glance, I have no clue.

  • GOOD
	func ReallyComplicatedFunction() (returnTypes ReturnTypes, err error){
		//imagine this function being really complicated...
		//lots of loops...
		//channels, go routines, and pieces being put together...
		//then...
		//you...
		//see...
		queryHasRows := false

		for rows.Next(){
			queryHasRows = true
			//process some rows

		}

		if !queryHasRows{
			//more stuff to do...
		}
		//more goodies...
	}

I should be able to look at any variable and have some idea of what it is doing or what it is about to do! I can clearly see now that I am going to be checking to make sure that I have rows. Easy peasy.

So it took me way longer to come back here than originally anticipated. Unfortunately, my eyes have been watering non-stop for a couple days now and my faces feels like someone hit me in the face with a baseball bat. So needless to say it makes it much harder to stare at a computer screen.

Anyways, just wanted to say that I received some negative feedback when I commented briefly on managers...let me address those concerns/comment again:

What the hell do you know about being a manager?

I thought I made it pretty clear in my comments that I have only sat through managerial/leadership classes at the university level. I have never held a supervisory or managerial position before, but I have been/am an employee, so I have in the past and am continuously observing a variety of work situations.

Are you calling me a bad manager?

Not necessarily. If you did take offense, it means you need to evaluate. Some people jump into managerial positions thinking experience will be enough and often that is not the case. I've only met and had 1 manager where this worked. He was a people pleaser, a motivator, a coach, trainer, and overall just a likeable guy. He was the goto guy in the company, because he knew his stuff, and he did whatever it took to make sure it was always a win-win for everyone (man I was lucky to be on his team!).

The byproduct of higher education is that it increases knowledge. As the equation goes, knowledge = power and having power increases influence. Influence, that's a quality every leader has and is what is required to get people to follow them or believe in a cause that is worth fighting for!

I can relate to what you're going through man. Been there done that. Just keep in mind that not all managers are like that. If your situation doesn't improve, get the hell out of there!

I know and it is good to know that I am not the only one. I am giving it a chance, hoping things improve, and am going to continue to entertain offers.

Why can't you say or do anything? Aren't you doing that now?

Trust mostly. I simply don't have that reassurance yet that there are people I can trust.

Technically, all of what I write here is strictly my opinion and in a way it is my form of venting. I used to vent/talk about this stuff to my roommate, but unfortunately he no longer lives with me. I am going to implode if I don't have a venue of getting it off my chest.

Enough said for now...more feedback is always welcome!

Well, today is the last day of February. Onto March!

So, today I have just been sitting around and just chilling. Listening to some music and re-looking at some code I wrote awhile ago.

package main

import (
	"fmt"
	"strings"

	"github.com/PuerkitoBio/goquery"
)

func main() {
	doc, err := goquery.NewDocument("http://ariesjeep.com/dealerlocator/map.html")
	if err != nil {
		return
	}

	doc.Find("#app #markers_tab_content table tbody tr").Each(func(i int, s *goquery.Selection) {
		output := strings.TrimSpace(s.Find("td a").Text()) + ","

		latlng, _ := s.Find("td a").Attr("href")
		latlng = strings.Replace(latlng, "javascript:void(C2MEngine.instance.openMarker(", "", -1)
		latlng = strings.Replace(latlng, "));", "", -1)

		latlng = strings.Join(strings.Split(latlng, ",")[1:], ",")

		output += latlng

		fmt.Println(output)
	})
}

It basically rips the Company name and latitude/longitude pair from Google Maps. Web scraping is becoming more and more popular, because quite frankly it is much easier than having to manually extract information.

Today, I have come to the realization that I feel comfortable disconnecting myself from the rest of the world. Here’s why I think that:

  • I am easily misunderstood, probably because I am “socially awkward”. I haven’t mastered the art of “thinking on your toes.” People that have this skill will always look better than me and I don’t think it is fair judgment.
  • I am so tired of giving ideas or suggestions, just to have them ignored or having others take the credit. I don’t want awards, but getting occasional recognition for an idea would be nice.
  • I don’t think experience alone entitles anyone to a position of authority. For example, if you worked at company X for 5 years, it doesn’t mean that you’re ready to be a manager or be in a leadership position. I think that a good manager/leader should be open-minded and come to the realization that having some theory-based knowledge that only higher education can provide, can craft them into a well-rounded manager/leader. I have sat through managerial/leadership classes and all I can say is that it has been interesting to be in situations of what they say not to do and see issues that could be avoided if they were properly addressed with the right knowledge/theory that can be learned. Only kicker is I can’t say or do anything about it. Perhaps a day will come when I have more experience, then perhaps I can apply what I have learned and not make the same mistakes.
  • I find it funny how people never have any money. Once you start observing their behaviors or lifestyle choices, you can quickly see where all their money goes. I hate it when it reaches the point where that is all they talk about or quickly judge you if you don’t support their choice. For example, if all you talk about is going out and getting drunk every night, well…I think you’re a moron. I might not tell it to your face, but that is what I am thinking. If you expect sympathy or start asking for money because of these idiotic things, well I say you deserve to be kicked in the head. For me, I refuse to live beyond my means and I’ll always save for a rainy day.

All hope is not lost. I believe people can change, including myself, and I think it will be a matter of time before change has to happen. I am making small attempts of getting outside of my comfort level, but I refuse to change because people want me to. I am in control of my life and I am pretty confident that will never change.

So, tonight I decided to amuse myself by embedding a Github Gist onto a webpage and completely obliterating the web contents that was there previously. I must say that it is was much simpler than I thought, which is always a good thing!

Back to watching the movie, Good Will Hunting, for me!

@eedrah
Copy link

eedrah commented Feb 27, 2015

It's not your fault...

@mickelsonm
Copy link
Author

I know... 😄

@eedrah
Copy link

eedrah commented Feb 27, 2015

No, no, you don't. It's not your fault.

@eedrah
Copy link

eedrah commented Feb 27, 2015

Ha, I'll stop :D

@mickelsonm
Copy link
Author

Sounds like you've seen that a time or two as well!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment