Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
class LRUCache | |
def initialize(size = 10) | |
@size = size | |
@store = {} | |
@lru = [] | |
end | |
def set(key, value = nil) | |
value = yield if block_given? |
# Author: Pieter Noordhuis | |
# Description: Simple demo to showcase Redis PubSub with EventMachine | |
# | |
# Update 7 Oct 2010: | |
# - This example does *not* appear to work with Chrome >=6.0. Apparently, | |
# the WebSocket protocol implementation in the cramp gem does not work | |
# well with Chrome's (newer) WebSocket implementation. | |
# | |
# Requirements: | |
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby |
#!/usr/bin/env python | |
# This example demonstrates RSA public-key cryptography in an | |
# easy-to-follow manner. It works on integers alone, and uses much smaller numbers | |
# for the sake of clarity. | |
##################################################################### | |
# First we pick our primes. These will determine our keys. | |
##################################################################### |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
eXtreme Go Horse (XGH) Process | |
Source: http://gohorseprocess.wordpress.com | |
1. I think therefore it's not XGH. | |
In XGH you don't think, you do the first thing that comes to your mind. There's not a second option as the first one is faster. | |
2. There are 3 ways of solving a problem: the right way, the wrong way and the XGH way which is exactly like the wrong one but faster. | |
XGH is faster than any development process you know (see Axiom 14). |
According to all known laws of aviation, there is no way a bee should be able to fly. | |
Its wings are too small to get its fat little body off the ground. | |
The bee, of course, flies anyway because bees don't care what humans think is impossible. | |
Yellow, black. Yellow, black. Yellow, black. Yellow, black. | |
Ooh, black and yellow! | |
Let's shake it up a little. | |
Barry! Breakfast is ready! | |
Coming! | |
Hang on a second. | |
Hello? |
This guide was created by VTEX for internal purposes inspired by Shopify's GraphQL API Tutorial.
There is no official GraphQL guidelines for handling errors, so we are stabilishing our own.
#!/usr/bin/env sh | |
set -x | |
set -e | |
MNTDIR="/tmp/lol/mnt" | |
TEMPDISK="/tmp/lol/tempdisk.img" | |
SSH_PUB="${HOME}/.ssh/id_rsa_$(hostname).pub" | |
TEMPDIR="$(dirname "${TEMPDISK}")" |