Skip to content

Instantly share code, notes, and snippets.

View pedro823's full-sized avatar
🎲
The most order we can get is pure randomness

Pedro Pereira pedro823

🎲
The most order we can get is pure randomness
View GitHub Profile
@unnu
unnu / lru_cache.rb
Created July 20, 2009 08:14
Ruby LRU cache with tests
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
@tylerl
tylerl / rsa.py
Created September 24, 2011 08:27
RSA Explained in Python
#!/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.
#####################################################################
@hrldcpr
hrldcpr / tree.md
Last active June 8, 2024 18:11
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@banaslee
banaslee / XGH - en.txt
Last active June 18, 2024 06:53
eXtreme Go-Horse Process
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?
@felippenardi
felippenardi / guide.md
Last active July 25, 2018 17:35 — forked from swalkinshaw/tutorial.md
GraphQL API Design Guide

Guide: GraphQL API Design

This guide was created by VTEX for internal purposes inspired by Shopify's GraphQL API Tutorial.

Error Handling

There is no official GraphQL guidelines for handling errors, so we are stabilishing our own.

@souenzzo
souenzzo / arch-volatil.sh
Created October 2, 2018 02:43
cria uma VM com arch linux descartavel em menos de 1 min. Requer ~3Gb de RAM livre (para criar disco+RAM)
#!/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}")"