Skip to content

Instantly share code, notes, and snippets.

View weapp's full-sized avatar
💸

Manuel Albarran weapp

💸
View GitHub Profile
@weapp
weapp / benchmark.rb
Created August 7, 2015 08:58
Faraday backends
require 'benchmark/ips'
require 'faraday'
require 'excon'
require 'typhoeus'#, '~> 0.3.3'
require 'patron'
require 'net-http-persistent'
default_adapter = Faraday.new(:url => 'http://localhost') do |faraday|
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
end
@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"}
'
{ title: "My ER Diagram" }
# Tables
[User] { color: :blue }
*id
blog_id* <nullable>
name
[Blog] { color: :orange }
*id
@weapp
weapp / life.js
Last active August 29, 2015 14:26 — forked from faddah/life.js
function from Lea Verou's version of Conway's Game Of Life
(function() {
var buttons = {
next: $('button.next')
};
buttons.next.addEventListener('click', function() {
lifeView.next();
});
#!/usr/bin/env ruby
# require 'bundler/setup'
# Bundler.require(:default)
module F
ZERO = -> p { -> x { x } }
ONE = -> p { -> x { p[x] } }
TWO = -> p { -> x { p[p[x]] } }
#!/bin/bash
cd ~/projects/
echo -en '\033]2;'$1'\007' # set the title of the window
case "$1" in
wubytes) cd wubytes && foreman start;;
kiwitime) cd kiwitime && rails s -p 5000;;
require "pp"
block_size = 4_096
def tags_from_file(filename)
no_tag_or_tag = /([^<>]+)|(<\/[^<>]+>)|(<[^<>]+?\/>)|(<\!\[CDATA\[(?:.*?)\]\]>)|(<[^!a-zA-Z][^<>]+>)|(<[^<>]+>)/
reg_exp = /\A(?<p>(?:#{no_tag_or_tag}))*\g<p>*/
block_size = 4_096
Enumerator.new do |enum|
@weapp
weapp / _Regions_.md
Last active February 7, 2022 17:21
Experiment about functional programing in different languages

Definitions:

  • callable: something that can be called with params; like a function, method, procedure, macro...
  • Point:: 2d tuple/list/array or object/struct with coordinates (x, y) as attributes/fields
  • Region: a callable that receive a point and return true if is inside of a a region, and false if is out.
  • Distance : a float

Problem:

  • We have a two tanks (in a two positions), and we want to know if we can shot to another positions without danger.
  • The tanks have a secure region defined by a circle
  • The tanks have a maximun shot distance.
@weapp
weapp / nginx.conf
Created August 4, 2014 17:21
Return common errors as json in Nginx
error_page 500 /500.html;
location /500.html{
return 500 '{"error": {"status_code": 500,"status": "Internal Server Error"}}';
}
error_page 502 /502.html;
location /502.html{
return 502 '{"error": {"status_code": 502,"status": "Bad Gateway"}}';
}