Skip to content

Instantly share code, notes, and snippets.

View weapp's full-sized avatar
💸

Manuel Albarran weapp

💸
View GitHub Profile
@weapp
weapp / tail-color.sh
Last active August 29, 2015 14:26 — forked from kartikshah/tail-color.sh
Color output of linux tail command
$tail -100f /var/log/applications/application.log | awk '
/INFO/ {print "\033[32m" $0 "\033[39m"}
/Exception/ {print "\033[31m" $0 "\033[39m"}
'
@weapp
weapp / at.sjs
Last active September 13, 2015 15:54
Macros
// https://gist.github.com/mateuspv/45bfb3e10a84e34b0074
/**
Sweet.js version: 0.7.2
`this` nickname `@`
Expected:
@ -> this
@something -> this.something
example:
function hello (tag) {
[
{ "keys": ["ctrl+alt+super+d"], "command": "toggle_side_bar" },
{ "keys": ["super+l"], "command": "show_overlay", "args": {"overlay": "goto", "text": ":"} },
{ "keys": ["super+shift+l"], "command": "expand_selection", "args": {"to": "line"} },
{ "keys": ["ctrl+super+r"], "command": "reveal_in_side_bar" },
{ "keys": ["alt+shift+up"], "command": "select_lines", "args": {"forward": false} },
{ "keys": ["alt+shift+down"], "command": "select_lines", "args": {"forward": true} },
{ "keys": ["ctrl+shift+<"], "command": "erb" },
{ "keys": ["super+shift+t"], "command": "reopen_last_file" },
{ "keys": ["super+i"], "command": "copy_path" },
@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"
{ title: "My ER Diagram" }
# Tables
[User] { color: :blue }
*id
blog_id* <nullable>
name
[Blog] { color: :orange }
*id
@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
@weapp
weapp / install.sh
Last active December 12, 2015 04:49 — forked from fenprace/install.sh
#!/bin/sh
sudo mv /usr/bin/xdg-open /usr/bin/xdg-open.bak
sudo curl https://gist.github.com/weapp/4717249/raw/16b3ce7ae4c4e63162ca0d9e47b2805d410bfa14/xdg-open.rb -o /usr/bin/xdg-open
sudo chmod a+x /usr/bin/xdg-open
@weapp
weapp / log_queue.py
Created February 10, 2013 22:55
Collection for store a degradable history
from collections import Iterable
import numpy as np
import math
class LogQueue(object):
"""Collection for store a degradable history"""
def __init__(self, size=5, depth=1):
super(LogQueue, self).__init__()
self.items = []
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