Skip to content

Instantly share code, notes, and snippets.

💸

Manuel Albarran weapp

💸
Block or report user

Report or block weapp

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@weapp
weapp / optparse-template.rb
Created May 29, 2019 — forked from rtomayko/optparse-template.rb
Ruby optparse template
View optparse-template.rb
#!/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"
View plates.rb
#!/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
View serializable_model.rb
class Field
attr_accessor :name, :type, :default
def initialize(name, type, default)
@name = name.to_s
@type = type
@default = default
end
TYPECASTS = {
View test.tmpl.exs
defmodule PROJECT_NAME.MODULE_NAMETest do
use ExUnit.Case
alias PROJECT_NAME.MODULE_NAME
doctest MODULE_NAME
describe "description" do
setup do
%{
@weapp
weapp / Gemfile
Created May 30, 2017
dummy foxy example
View Gemfile
source "https://rubygems.org"
gem "foxy"
group :development, :test do
gem "pry"
gem "pry-byebug"
end
View splats.md

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

-> # What is * (splat) <-

by urbandictionary

View maps_bench.ex
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
View benchmark_map_vs_pattern_matching.ex
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
View __README__.md

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"

@weapp
weapp / Gemfile
Last active Feb 8, 2017
Paypal + Sinatra Integration
View Gemfile
# -*- coding: utf-8 -*-
source 'https://rubygems.org'
gem 'sinatra'
gem 'faraday'
You can’t perform that action at this time.