GithubHelp home page GithubHelp logo

nathanleclaire / blog Goto Github PK

View Code? Open in Web Editor NEW
47.0 47.0 138.0 89.81 MB

https://nathanleclaire.com source code

Home Page: https://nathanleclaire.com

Shell 0.89% HTML 53.65% CSS 44.70% Makefile 0.19% Dockerfile 0.57%

blog's People

Contributors

ders avatar djmarcin avatar haegin avatar icecreammatt avatar jordycuan avatar josegonzalez avatar joshuadoes avatar nathanleclaire avatar nexweb avatar nielmistry avatar pichsenmeister avatar robleh avatar shankfoo avatar streppel avatar tibsar avatar unicell avatar westoleman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

blog's Issues

confusion could be elaborated on

I found your post here: https://nathanleclaire.com/blog/2014/08/09/dont-get-bitten-by-pointer-vs-non-pointer-method-receivers-in-golang/

after reading this page: https://gobyexample.com/methods

my question is: why does go not seem to care that you pass the correct type (pointer or not) into a method?
Specifically, at the end you have a code block:

func main() {
    m := &Mutatable{0, 0} // line * below seems to work even without the & here
    fmt.Println(m)
    m.StayTheSame()
    fmt.Println(m)
    m.Mutate() . //*
    fmt.Println(m)
}

however, if you just did m := Mutatable{0, 0}, then m.Mutate() still works. Why? What is the effect of this? Why doesn't the compiler complain about m not being a pointer?

Pass by value/pass by reference

Hey Nathan,

Firstly thank you very much for you post. It was really helpful to me, since I was also kinda confused with the best practices for passing args in Go.

In line 74, you talk about pass by mechanisms in Go, which when reading it reminded me of a really interesting article about how this is handled in Go. Maybe you want to make a parenthesis referencing the article for people who are interested, if you think its reasonable. :)
It's Dave Cheney's There is no pass-by-reference in Go

Thanks once more,
Best regards,
R

Curl alpine image suggestion

it would be nice if you added a DNS resolution to the alpine-curl image you wrote by adding the --enable-threaded-resolver or --enable-ares flags. Curl can support it with --dns-servers, but I and many others online are having issues using it that your script could resolve.

Issues with the site.

There are a couple of issues with your site that are not related to the content itself.

First, I subscribed to your blog using the box on the left while I was reading an article. But then, when I reached the bottom of it, there was a modal box offering me to subscribe? not nice.

And then, I decided to read an article in bed in my phone (For the record, it's a Moto G so it has a rather nice screen resolution).

All was fine... until I got to the bottom of it. And that dreaded modal box, that in my phone (with a rather nice screen resolution, mind you) was impossible to get rid of. Now that I think about it I could had zoomed out the page; but that's not the idea, is it?

Misstyped something.

As anyone accustomed to the flexibility afforded you by langauges such as Python and Ruby may be familiar with

Also, the link at the bottom ( fix it and submit a pull request on Github) 404's on Github.

Explanation of "dot rule" is incorrect

There is a technical error in the article "5 AngularJS Antipatterns & Pitfalls" . The advice regarding putting a "dot" in ng-model attribute bindings is sound, but the explanation behind it is incorrect and misunderstands the cause of the problem.

The article claims that the following directive won't work because of conflicts between a "shadow" property on the directive scope and the original property on the parent controller scope:

angular.module('dotDemo').directive('crazyAwesomeWidget', function() {
  return {
    restrict: 'E',
    template: '<input type="text" ng-model="info" />',
    scope: {
      info: '='
    }
  };
});

There's two problems with this.

  1. There are no identically named properties on the OuterCtrl scope and the directive scope
  2. The directive scope is isolated, owing to the inclusion of scope : { ... }, so there's never a scenario when you are looking up the prototype chain of the directive scope to find any missing properties. That only happens when you enable scope inheritance, either explicitly using scope: true or implicitly by skipping scope entirely.

The only case where people trip up on prototypal inheritance in scopes is when the following happens:

  1. You have a property $scope.foo on the scope of an outer controller. It doesn't matter what data type the property holds.
  2. You're using a directive with a non-isolated scope, and the directive scope inherits foo from the outer controller's scope prototypically. Retrieving $scope.foo inside the directive will result in going up the prototype chain and accessing the outer scope's foo property
  3. You assign something to $scope.foo inside the directive (because of ng-model or whatever). This creates a new foo property on the directive's scope, and further references of $scope.foo no longer have anything to do with the prototype, because a foo property can be found right there on the directive scope.

This is not what is going on in the example snippet. The reason the dot is required is simply to make sure that the info property in the directive scope is never assigned to at all. You mutate the value stored in info if you store a { } and use a dot in ng-model, but you never actually update $scope.info to be something else. That's the key thing. That way, the parent scope's foo property and the isolated directive scope's foo property keep pointing at the same item.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.