Skip to content

Instantly share code, notes, and snippets.

View egasimus's full-sized avatar
🐒
all our telepaths are on leave and the ascended master is currently downshifting

egasimus

🐒
all our telepaths are on leave and the ascended master is currently downshifting
View GitHub Profile
@virtualstaticvoid
virtualstaticvoid / iptables_rules.sh
Created June 14, 2011 08:58
25 Most Frequently Used Linux IPTables Rules Examples
# Modify this file accordingly for your specific requirement.
# http://www.thegeekstuff.com
# 1. Delete all existing rules
iptables -F
# 2. Set default chain policies
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP
@brianmcd
brianmcd / contextify_leak_js_output.txt
Created August 5, 2011 00:24
Contextify Performance
//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.
@vstoykov
vstoykov / force_default_language_middleware.py
Last active June 6, 2024 10:51
Force Django to use settings.LANGUAGE_CODE for default language instead of request.META['HTTP_ACCEPT_LANGUAGE']
try:
from django.utils.deprecation import MiddlewareMixin
except ImportError:
MiddlewareMixin = object
class ForceDefaultLanguageMiddleware(MiddlewareMixin):
"""
Ignore Accept-Language HTTP headers
@anatoliychakkaev
anatoliychakkaev / demo.js
Created January 12, 2012 08:32
Require in runInNewContext
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,
@jboner
jboner / latency.txt
Last active July 30, 2024 02:24
Latency Numbers Every Programmer Should Know
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
@TurplePurtle
TurplePurtle / api.lua
Created August 24, 2012 00:52
Basic reddit API functions
--[[
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"
@travitch
travitch / NotificationDaemon.hs
Created September 12, 2012 14:37
A freedesktop notification plugin for xmobar
{-# LANGUAGE OverloadedStrings, RankNTypes, KindSignatures, FlexibleContexts #-}
module Plugins.NotificationDaemon where
-- xmobar plugin API
import Plugins
import DBus.Bus
import DBus.Client
import DBus.Constants
@copitux
copitux / Doc.rst
Created September 24, 2012 22:20
Django, Django forms and Django rest framework: Payload validation

Django request flow

-------------------------------                         ------------------ 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
@csswizardry
csswizardry / BEM-inuit.css.md
Created October 2, 2012 20:09
Thoughts on BEM for inuit.css

Bringing BEM to inuit.css

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{}
@ramusus
ramusus / gist:4343464
Created December 20, 2012 07:08 — forked from anonymous/gist:4343460
adminreverse from here http://djangosnippets.org/snippets/2032/. changed for working with ForeignKeys
'''
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