Skip to content

Instantly share code, notes, and snippets.

View guilherme's full-sized avatar
🤔

Guilherme Campos guilherme

🤔
View GitHub Profile
@vasanthk
vasanthk / System Design.md
Last active April 9, 2025 20:07
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@blasten
blasten / KMP.js
Last active February 11, 2025 22:10
String matching based on the KMP algorithm. This how `String.prototype.indexOf` is generally implemented.
// Construct a table with table[i] as the length of the longest prefix of the substring 0..i
function longestPrefix(str) {
// create a table of size equal to the length of `str`
// table[i] will store the prefix of the longest prefix of the substring str[0..i]
var table = new Array(str.length);
var maxPrefix = 0;
// the longest prefix of the substring str[0] has length
table[0] = 0;
@JoshCheek
JoshCheek / pipeline.rb
Created July 28, 2014 06:06
Goodies are at the bottom.
class Symbol
def enter(rider)
(!self).call rider
end
def !@
-> subject do
method = subject.method(self)
return method.call if method.arity.zero?
method.to_proc.curry
@jimweirich
jimweirich / README.md
Created December 12, 2011 02:28
Description of a Refactoring Kata

Refactoring Kata

Here's an interesting refactoring challenge.

Refactor the tangle.c program described at http://axiom-developer.org/axiom-website/litprog.html with the goal of making it more readable and maintainable.

Some suggested guidelines and constraints. Of course, you can do

@justinwiley
justinwiley / cucumber-capybara-capistrano.feature
Created August 31, 2011 18:48
Integrating Cucumber Capybara Smoketest with Capistrano
@test_deploy @javascript # @test_deploy tag setup in cucumber.yml profile, @javascript runs in capybara-webkit
Feature: Smoke Test
In order to test that the application is deployed
As a caring developer
I want to check a few features of the site
Background:
Given we are in the deploy environment
Scenario: Logging in and checking basic navigation
@ericallam
ericallam / gist:1019446
Created June 10, 2011 18:35
How to log all queries for a PostgreSQL homebrew install on OS X

Open the postgresql.conf config file:

$> mate /usr/local/var/postgres/postgresql.conf

Uncomment the line with 'log_destination' and set it to 'syslog'

log_destination = 'syslog'

Open the syslog config:

# Redis configuration file example
# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
daemonize yes
# When run as a daemon, Redis write a pid file in /var/run/redis.pid by default.
# You can specify a custom pid file location here.
pidfile /var/run/redis.pid
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db