Skip to content

Instantly share code, notes, and snippets.

View 1337's full-sized avatar
🧠
🤯

Brіаn 1337

🧠
🤯
View GitHub Profile
@1337
1337 / pep8.py
Created April 5, 2012 19:52
So many things to hate about PEP 8
#!/usr/bin/env python
# PEP 20 supersedes PEP 8 http://www.python.org/dev/peps/pep-0008/#a-foolish-consistency-is-the-hobgoblin-of-little-minds
# Follow PEP 20 if readability is affected by PEP 8
# max length 79 chars, not 80 (http://www.python.org/dev/peps/pep-0008/#maximum-line-length)
"""One-line summary of purpose. # double quoted docstrings; max length 72 chars (http://www.python.org/dev/peps/pep-0008/#maximum-line-length)
# 2nd line must be blank http://www.python.org/dev/peps/pep-0257/#multi-line-docstrings
More things # aligns with the quotes
More things
"""
@1337
1337 / gist:2314040
Last active October 2, 2015 20:28
Far fewer things to hate about JavaScript
/* http://javascript.crockford.com/code.html
JavaScript code should not be embedded in HTML files unless
the code is specific to a single session.
*/
// All variables should be declared before used.
var sampleVar; // Avoid lines longer than 80 characters.
var stupidFunction = function (param1, param2, param3, // There should be no space between the name of a function and the (, except If a function literal is anonymous
@1337
1337 / gos.js
Last active October 4, 2015 13:48
get any one script
var getAnyOneScript = function (scripts) {
// TODO: http://stackoverflow.com/questions/2027849/how-to-trigger-script-onerror-in-internet-explorer/2032014#2032014
scripts = scripts instanceof Array ? scripts : [scripts];
var script = document.createElement('script');
script.setAttribute('type', 'text/javascript');
script.setAttribute('src', scripts[0]);
script.onerror = function () {
scripts.shift();
getAnyOneScript(scripts);
@1337
1337 / dt.js
Last active October 11, 2015 21:28
Bring you to the definition.
/*
when you click on <a class="dt">Hello</a> and a
<dt>Hello</dt> is on the same page, the page scrolls
to that location.
*/
$(document).ready(function () {
$('a.dt', document).each(function () {
var that = $(this), rel = that.attr('href') ||
that.text().replace(/\s+/g, ' ');
if (!rel) {
/*
PubSub by github.com/1337
GPLv3 (if you don't ask) or MIT (if you ask first)
what this does depends on the func signature.
$.pubSub(name);
calls all funcs under this name with default params
$.pubSub(name, params);
calls all funcs under this name with params
$.pubSub(name, params, callback);
A R N D C Q E G H I L K M F P S T W Y V
A 4 -1 -2 -2 0 -1 -1 0 -2 -1 -1 -1 -1 -2 -1 1 0 -3 -2 0
R -1 5 0 -2 -3 1 0 -2 0 -3 -2 2 -1 -3 -2 -1 -1 -3 -2 -3
N -2 0 6 1 -3 0 0 0 1 -3 -3 0 -2 -3 -2 1 0 -4 -2 -3
D -2 -2 1 6 -3 0 2 -1 -1 -3 -4 -1 -3 -3 -1 0 -1 -4 -3 -3
C 0 -3 -3 -3 9 -3 -4 -3 -3 -1 -1 -3 -1 -2 -3 -1 -1 -2 -2 -1
Q -1 1 0 0 -3 5 2 -2 0 -3 -2 1 0 -3 -1 0 -1 -2 -1 -2
E -1 0 0 2 -4 2 5 -2 0 -3 -3 1 -2 -3 -1 0 -1 -3 -2 -2
G 0 -2 0 -1 -3 -2 -2 6 -2 -4 -4 -2 -3 -3 -2 0 -2 -2 -3 -3
H -2 0 1 -1 -3 0 0 -2 8 -3 -3 -1 -2 -1 -2 -1 -2 -2 2 -3
This file has been truncated, but you can view the full file.
[
{
"name": "Kelly's",
"regular_price": 9.44,
"package": "1000 mL bottle",
"volume": 1000,
"alcohol_content": 20.0,
"id": 113332
},
{
#!/usr/bin/env python2
"""sudo cp xkcd.py /usr/local/bin/xkcd"""
__author__ = '1337'
from os.path import basename, join
from subprocess import call
import re
import sys
#!/usr/bin/env python2
class Foo(object):
x = 3
# [ ] 1. what's wrong with this line? how would you improve it?
def func(self, list=[]):
# [ ] 2. what is "list" here? what will be appended to it?
list.append(list is [])
// 1. [ ] how is "foo = function foo" from "foo = function"?
// 2. [ ] what happens when you do "function foo(foo)"?
var func = function func(func) {
// 3. [ ] what happens when you do "var foo" in a "function(foo)"?
var func;
// 4. [ ] what is "typeof func" here?
console.log(typeof func);
};