BEM is a methodology for naming and classifying CSS selectors in a way to make them a lot more strict, transparent and informative.
The naming convention follows this pattern:
.block{}
.block__element{}
.block--modifier{}
from inspect import isfunction | |
from django.views.generic import View, CreateView, UpdateView, DeleteView, DetailView, ListView | |
from django.views.generic.edit import ModelFormMixin | |
from django.views.generic.detail import SingleObjectMixin | |
def parse_func_dict(selfobj, d): | |
""" | |
Recursively goes through a dict, calling functions that refer to a view's | |
self and therefore need to be called from within -- such as getting extra | |
kwargs for a form constructor based on request data. |
''' | |
adminreverse from here http://djangosnippets.org/snippets/2032/ | |
changed for working with ForeignKeys | |
''' | |
''' | |
reverseadmin | |
============ | |
Module that makes django admin handle OneToOneFields in a better way. | |
A common use case for one-to-one relationships is to "embed" a model |
------------------------------- ------------------ Django -------------------- | Browser: GET /udo/contact/2 | === wsgi/fcgi ===> | 1. Asks OS for DJANGO_SETTINGS_MODULE | ------------------------------- | 2. Build Request (from wsgi/fcgi callback) | | 3. Get settings.ROOT_URLCONF module | | 4. Resolve URL/view from request.path | # url(r'^udo/contact/(?P<id>\w+)', view, name='url-identifier') | 5. Apply request middlewares | # settings.MIDDLEWARE_CLASSES
{-# LANGUAGE OverloadedStrings, RankNTypes, KindSignatures, FlexibleContexts #-} | |
module Plugins.NotificationDaemon where | |
-- xmobar plugin API | |
import Plugins | |
import DBus.Bus | |
import DBus.Client | |
import DBus.Constants |
--[[ | |
Currently implemented functions are: | |
login(user, passwd) | |
me(auth) | |
submit(title, isSelf, content, subreddit, auth) | |
comment(thing_id, text, auth) | |
]] | |
local json = require "json" | |
local util = require "reddit.util" |
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
var Module = require('module'); | |
var vm = require('vm'); | |
var path = require('path'); | |
var filename = process.cwd() + '/lib/eval.js'; | |
var mod = new Module(filename); | |
var context = { | |
module: mod, | |
__filename: filename, |
try: | |
from django.utils.deprecation import MiddlewareMixin | |
except ImportError: | |
MiddlewareMixin = object | |
class ForceDefaultLanguageMiddleware(MiddlewareMixin): | |
""" | |
Ignore Accept-Language HTTP headers | |
//Results from running test/jsdom/leak.js on brianmcd's fork of JSDOM which uses Contextify. | |
node --trace-gc leak.js | |
Scavenge 2.6 -> 2.3 MB, 1 ms. | |
Mark-sweep 3.5 -> 2.8 MB, 3 ms. | |
Scavenge 4.4 -> 3.9 MB, 0 ms. | |
Scavenge 5.9 -> 5.0 MB, 1 ms. | |
Mark-sweep 7.0 -> 4.8 MB, 10 ms. | |
Mark-sweep 8.7 -> 7.2 MB, 10 ms. | |
Mark-sweep 14.2 -> 9.8 MB, 16 ms. |