Skip to content

Instantly share code, notes, and snippets.

@dupuy
dupuy / README.rst
Last active February 15, 2024 18:07
Common markup for Markdown and reStructuredText

Markdown and reStructuredText

GitHub supports several lightweight markup languages for documentation; the most popular ones (generally, not just at GitHub) are Markdown and reStructuredText. Markdown is sometimes considered easier to use, and is often preferred when the purpose is simply to generate HTML. On the other hand, reStructuredText is more extensible and powerful, with native support (not just embedded HTML) for tables, as well as things like automatic generation of tables of contents.

@shvechikov
shvechikov / upprint.py
Created February 27, 2012 09:11
UnicodePrettyPrinter
# -*- coding: utf-8 -*-
import sys
from pprint import PrettyPrinter
class UnicodePrettyPrinter(PrettyPrinter):
"""Unicode-friendly PrettyPrinter
Prints:
- u'привет' instead of u'\u043f\u0440\u0438\u0432\u0435\u0442'
@jboner
jboner / latency.txt
Last active March 28, 2024 03:39
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
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active March 27, 2024 19:48
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@nikcub
nikcub / README.md
Created October 4, 2012 13:06
Facebook PHP Source Code from August 2007
@neilj
neilj / window-controller.js
Last active November 4, 2022 21:41
Cross-tab window controller
function WindowController () {
this.id = Math.random();
this.isMaster = false;
this.others = {};
window.addEventListener( 'storage', this, false );
window.addEventListener( 'unload', this, false );
this.broadcast( 'hello' );
@grantm
grantm / gist:4367372
Last active December 10, 2015 02:28
Ever forgotten the ':' after the hostname of an scp command?
# a useful addition to anyone's .bashrc
#
# Note, you don't want this function in effect on the remote host side of the scp transfer,
# so make sure to only define it for interactive shells, e.g.: wrap with: if [ ! -z "$PS1" ]
function scp() {
if echo "$@" | grep -q ':'
then
/usr/bin/scp "$@"
else
@ndarville
ndarville / examples.mdown
Last active December 9, 2019 11:32
“We’ve Been Hacked” Boilerplate Announcement

How Companies Communicated Being Hacked

It’s probably a pretty bad idea to have your site go down, when people are supposed to read the blog post explaining the hack.

Notice how another site reporting the hack received more attention than Twitter’s own announcement. Why was that?

@NV
NV / Readme.md
Last active May 28, 2023 20:42
Prepend the debugger statement to a function as easy as stopBefore('Element.prototype.removeChild'). Works in Chrome DevTools and Safari Inspector, doesn’t work in Firebug‘s and Firefox Developer Tools‘ console (I don’t know why). Works as a standalone script everywhere.

stopBefore.js

2min screencast

Examples

stopBefore(document, 'getElementById')
stopBefore('document.getElementById') // the same as the previous
stopBefore(Element.prototype, 'removeChild')
@ianb
ianb / assert.js
Last active December 16, 2015 17:19
assert() for Javascript
function AssertionError(msg) {
this.message = msg || "";
this.name = "AssertionError";
}
AssertionError.prototype = Error.prototype;
/* Call assert(cond, description1, ...)
An AssertionError will be thrown if the cond is false. All parameters will be logged to the console,
and be part of the error.
*/