Skip to content

Instantly share code, notes, and snippets.

View weapp's full-sized avatar
💸

Manuel Albarran weapp

💸
View GitHub Profile
@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"}}';
}
@weapp
weapp / Gemfile
Created January 10, 2023 16:45 — forked from caendekerk/Gemfile
Rails API only with Okta but without Devise
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0.0'
# Shorten boot time
gem 'bootsnap'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', github: 'rails/jbuilder'

%title: Splats: beyond *args %author: weapp %date: 2017-04-20

-> # What is * (splat) <-

by urbandictionary

@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 / Gemfile
Created May 30, 2017 20:35
dummy foxy example
source "https://rubygems.org"
gem "foxy"
group :development, :test do
gem "pry"
gem "pry-byebug"
end
@weapp
weapp / Gemfile
Created June 25, 2020 10:22 — forked from dhh/Gemfile
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers
@weapp
weapp / optparse-template.rb
Created May 29, 2019 06:48 — forked from rtomayko/optparse-template.rb
Ruby optparse template
#!/usr/bin/env ruby
#/ Usage: <progname> [options]...
#/ How does this script make my life easier?
# ** Tip: use #/ lines to define the --help usage message.
$stderr.sync = true
require 'optparse'
# default options
flag = false
option = "default value"
#!/usr/bin/env ruby
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "rack"
gem "foxy", git: "git://github.com/weapp/foxyrb.git"
end
class App
class Field
attr_accessor :name, :type, :default
def initialize(name, type, default)
@name = name.to_s
@type = type
@default = default
end
TYPECASTS = {