Skip to content

Instantly share code, notes, and snippets.

@sbisbee
sbisbee / couchdb-csrfTokens
Created February 8, 2011 23:04
Proposal on how to prevent CSRF attacks against CouchDB with tokens.
Proposal to Prevent CSRF Attacks on CouchDB with Tokens
=======================================================
This is a draft for commentary from the community.
Goals
-----
1. Establish a mechanism that would defeat CSRF attacks against CouchDB by
leveraging the standard provided by OWASP at
@rsuniev
rsuniev / zipper.hs
Created April 14, 2011 10:53
JSON Zipper
module Zipper where
import Data.List
import Text.JSON
import Data.Maybe
import Control.Monad
data JSZipper = JSZipper {
parent :: Maybe JSZipper,
lefts :: [JSValue],
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@voidfiles
voidfiles / app_net_grids.md
Created August 15, 2012 19:01
How App.net uses YUI3 grids

How you can create a responsive grid system using YUI3 grids and SASS

This is a quick rundown of how and why we use YUI3 grids at App.net

As far as I can tell there are three types of CSS grids: a static-width pre-defined grid, a flexible-width pre-defined grid, and a generative grid. In the first two grids (pre-defined width), you basically decide how many columns you have across the screen, and then create blocks in any multiple of those. This pattern often looks like "span-4", "span-6", "pull-10", "push-5", etc. You find this style in popular frameworks like Bootstrap and Blueprint.

The third way, the generative/recursive grid system, doesn't seem to be as popular as the others. I am not entirely sure why, because the generative grid can pack more punch in less lines. In this vein is there is OOCSS and YUI3 CSS Grids.

@mcdonc
mcdonc / gist:3898894
Created October 16, 2012 12:11
oh my god i'm using emacs to reindent html in sublime text 2
# Sublime's HTML reindenting is currently pretty bad. And Tidy and xmllint
# change my code in ways I don't really like or need. I just need the thing
# reindented sanely. Emacs did that pretty well.
#
# One thing led to another. A few drinks later and now I'm using Emacs to
# reindent HTML from within Sublime.
#
# Save the contents of this file as ohmygodemacs.py in your User directory.
# Then save the contents of the following docstring as ohmygodemacs.elsip in your
# User directory
@dustin
dustin / caperturber.go
Last active December 16, 2015 05:19
Example rate limited writer in go. Specify bytes per second and it will constrain you.
// This is just a creepy text effect over a writer just to demonstrate
// more io layering.
package main
import (
"io"
"math/rand"
"unicode"
"unicode/utf8"
@jvanasco
jvanasco / custom_sessions.py
Last active December 18, 2015 18:39
configurable sessions with pyramid
import logging
log = logging.getLogger(__name__)
import pyramid_beaker
from pyramid.session import UnencryptedCookieSessionFactoryConfig
import types
valid_args_pyramid_UnencryptedCookieSessionFactoryConfig = [
'secret',
@debasishg
debasishg / gist:8172796
Last active November 11, 2024 07:10
A collection of links for streaming algorithms and data structures

General Background and Overview

  1. Probabilistic Data Structures for Web Analytics and Data Mining : A great overview of the space of probabilistic data structures and how they are used in approximation algorithm implementation.
  2. Models and Issues in Data Stream Systems
  3. Philippe Flajolet’s contribution to streaming algorithms : A presentation by Jérémie Lumbroso that visits some of the hostorical perspectives and how it all began with Flajolet
  4. Approximate Frequency Counts over Data Streams by Gurmeet Singh Manku & Rajeev Motwani : One of the early papers on the subject.
  5. [Methods for Finding Frequent Items in Data Streams](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.187.9800&rep=rep1&t
"""
Python 2:
$ python-2.7 finallyfun.py
e: Exception()
Python 3:
$ python3.3 finallyfun.py
Traceback (most recent call last):
File "finallyfun.py", line 9, in <module>
foo()
@nickjacob
nickjacob / systemd-prblm.service
Last active March 17, 2023 16:11
execute arbitrary bash code/variable substitution in systemd units
[Unit]
Description=Demonstrate Bash
[Service]
ExecStartPre=/usr/bin/bash -c "/usr/bin/systemctl set-environment MYVAR=$(( 2 + 2 ))"
ExecStart=/usr/bin/echo "2 + 2 = ${MYVAR}"