Skip to content

Instantly share code, notes, and snippets.

View alexkahn's full-sized avatar

Alex Kahn alexkahn

  • Chicago, IL, USA
View GitHub Profile

Keybase proof

I hereby claim:

  • I am alexkahn on github.
  • I am alexkahn (https://keybase.io/alexkahn) on keybase.
  • I have a public key ASAwHU9DLrKOovCHkmcuEoxv7Nx9P7mb9yHAVVLOBJWJyAo

To claim this, I am signing this object:

@alexkahn
alexkahn / traceback.log
Created May 4, 2016 14:47
Traceback from migrate fail
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/rof/.virtualenv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
utility.execute()
File "/home/rof/.virtualenv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 345, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/rof/.virtualenv/local/lib/python2.7/site-packages/django/core/management/base.py", line 348, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/rof/.virtualenv/local/lib/python2.7/site-packages/django/core/management/base.py", line 398, in execute

JavaScript not considered harmful

Each topic that was brought up in the Slack channel has a heading with a answers between them.

JS in html file as <script/> vs having a separate JS file (generally best practices)

So this is a question of trade-offs. Sometimes you need to have some JS inline with your HTML due to your web framework. Eg. You have some JS that sends Google Analytics/Mixpanel events and needs to have a user's email address which must be given to your JavaScript.

@alexkahn
alexkahn / main.js
Created December 12, 2015 23:36
crockford constructor
function constructor(spec) {
var that = other_constructor(spec),
member,
method = function() {
//spec, member, method
};
that.method = method;
return that;
}
# blow away untracked files
git ls-files --others --exclude-standard | xargs rm
@alexkahn
alexkahn / before.js
Created November 30, 2015 17:36
exercise
var markerInfo = [
//MONDAYS
{
"location": "City Hall Plaza - Fisher Park", "latitude": "42.360082",
"longitude": "-71.058880",
"day": "Mondays"
},
// TUESDAYS & THURSDAYS
{
"location": "South End - Harrison Avenue and East Concord Street by BMC",
@alexkahn
alexkahn / after.js
Created November 24, 2015 21:23
DRYing up the Code
var hoursLocations = [{
'days': 'mondays',
'times': '11AM - 3PM',
'location': 'City Hall Plaza - Fisher Park'
},
{
'days': 'TUESDAYS &amp; THURSDAYS',
'times': "11AM - 3PM",
'location': "South End - Harrison Avenue and East Concord Street by BMC"
},
@alexkahn
alexkahn / godo.md
Created November 24, 2015 16:56
Get Started with Node.js

Getting Started with Node.js

This short guide will get you familiar with Node.js so we can go do some fun stuff.

Installation

OSX

brew install node

*nix

apt-get install node yum install node

@alexkahn
alexkahn / opacity.js
Created November 4, 2015 00:02
opacityHandler
var header = document.getElementsByTagName('header');
var range = 200;
window.addEventListener('scroll', opacityHandler, false)
function opacityHandler() {
var scrollTop = $(this).scrollTop();
var offset = header.offset().top;
var height = header.outerHeight();
@alexkahn
alexkahn / views.py
Created September 23, 2015 16:47
pass a query param to a form
from .forms import AccountCreationForm
class IndexView(TemplateView):
template_name = 'myapp/mytemplate.html'
def get_context_data(self, **kwargs):
ctx = super(IndexView, self).get_context_data(**kwargs)
# you can use any query param key you'd like...
ctx['form'] = AccountCreationForm(initial={'promotion_code': self.request.GET.get('c', '')})