Skip to content

Instantly share code, notes, and snippets.

View weapp's full-sized avatar
💸

Manuel Albarran weapp

💸
View GitHub Profile
@weapp
weapp / Gemfile
Last active September 30, 2015 22:02
RedBunny. redlock + bunny. redis + rabbitmq
# -*- coding: utf-8 -*-
source 'https://rubygems.org'
gem "pry", group: 'development'
gem "bunny", ">= 2.1.0"
gem "redlock"
@weapp
weapp / Gemfile
Last active March 13, 2018 23:26
groups, tree
# frozen_string_literal: true
source "https://rubygems.org"
group :development, :test do
gem "pry"
end
@weapp
weapp / selfdestruct.rb
Last active November 9, 2015 20:38
This message will self destruct
str = " [ = This message will self destruct = ]"
wave = -> max { [*0.upto(max), *max.downto(0)] }
puts
wave[str.length].each do |char|
sleep(0.05)
print "\r\e[2K#{str[0..char]}"
end
print "\e[M\e[1A\r"
@weapp
weapp / application.rb
Created December 3, 2015 03:26
RequestId
# http://stackoverflow.com/a/9380164/1171712
module MyFancyApp
class Application < Rails::Application
config.log_tags = [:uuid, :remote_ip]
end
end
require 'securerandom'
require 'benchmark/ips'
hashs = 20.times.map do
20.times.map { [SecureRandom.hex(2), SecureRandom.hex(2)] }.to_h
end
Benchmark.ips do |x|
x.time = 5
x.warmup = 2
RSpec::Support::Differ.new(color:true).diff("a\na\na\na\na\n", "a\na\na\na\nb\na\n")
@weapp
weapp / Gemfile
Last active February 8, 2017 14:21
Paypal + Sinatra Integration
# -*- coding: utf-8 -*-
source 'https://rubygems.org'
gem 'sinatra'
gem 'faraday'
@weapp
weapp / __README__.md
Last active February 20, 2017 23:27
GildedRose

based on: https://github.com/jimweirich/gilded_rose_kata

The Gilded Rose Code Kata

This is a Elixir version of the Gilded Rose Kata, found here.

This is a refactorying kata, so you will be starting with a legacy code base. To work the Kata, clone this git repository and checkout the tag 'start-here'. Read the description below for the "rules"

defmodule Mod do
@table %{
a: 1, b: 2, c: 3, d: 4, e: 5,
f: 6, g: 7, h: 8, i: 9, j: 0,
}
def fun1(k) do @table[k] end
for {k, v} <- @table do
def fun2(unquote(k)) do unquote(v) end
defmodule MyMap do
def bodyrecursive([]) do [] end
def bodyrecursive([h|t]) do [h + 1 | bodyrecursive(t)] end
def generic_bodyrecursive([], _) do [] end
def generic_bodyrecursive([h|t], fun) do [fun.(h) | bodyrecursive(t)] end
def tail(list) do tail(list, []) end
defp tail([], acc) do :lists.reverse(acc) end
defp tail([h|t], acc) do tail(t, [h + 1 | acc]) end