Skip to content

Instantly share code, notes, and snippets.

A Lee alee

  • Arizona State University
  • Arizona
Block or report user

Report or block alee

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@alee
alee / against-globals.md
Created Jun 15, 2018 — forked from nicolaspayette/against-globals.md
Why you should probably avoid global variables in NetLogo
View against-globals.md

In my experience, a disproportionate amount of bugs in NetLogo models are caused by the mismanagement of global variables.

Here are a few reasons why I think that is the case, in (roughly) decreasing order of importance:

  • Code is not just a way of getting the computer to do what you want it to do—it is a way of conveying meaning to the reader of your code. When you declare a global variable, the meaning you convey is: “Hey! This thing is important throughout the whole program. You should always be paying attention to it.”

    Sometimes it’s justified , but very often, it is not. An unjustified global is not only failing to convey the right message: it’s actively misleading.

    When I approach a model’s code for the first time, the first thing I do is look at the declarations on top: what breeds do we have, what agent variables do we have, and what global variables do we have? That gives me the “big picture” and tells me what I should be paying attention to when trying to understand what the code is do

@alee
alee / views.py
Last active Jun 25, 2019
Django Discourse SSO endpoint adapted from https://meta.discourse.org/t/sso-example-for-django/14258 - depends on settings.py DISCOURSE_BASE_URL and DISCOURSE_SSO_SECRET
View views.py
import base64
import hmac
import hashlib
from urllib import parse
from django.contrib.auth.decorators import login_required
from django.http import HttpResponseBadRequest, HttpResponseRedirect
from django.conf import settings
@login_required
You can’t perform that action at this time.