Skip to content

Instantly share code, notes, and snippets.

Avatar

Luís Ferreira zamith

View GitHub Profile
View shipping.diff
diff --git a/app/models/shipping/commodity.rb b/app/models/shipping/commodity.rb
index ae7b51bc..1cdcf3f7 100644
--- a/app/models/shipping/commodity.rb
+++ b/app/models/shipping/commodity.rb
@@ -2,10 +2,13 @@ module Shipping
class Commodity < ApplicationRecord
belongs_to :shipments
+ monetize :sales_unit_price_cents
+ monetize :total_price_cents
View shipping.diff
diff --git a/app/models/shipping/commodity.rb b/app/models/shipping/commodity.rb
index ae7b51bc..1cdcf3f7 100644
--- a/app/models/shipping/commodity.rb
+++ b/app/models/shipping/commodity.rb
@@ -2,10 +2,13 @@ module Shipping
class Commodity < ApplicationRecord
belongs_to :shipments
+ monetize :sales_unit_price_cents
+ monetize :total_price_cents
@zamith
zamith / data.rb
Created Aug 20, 2015
DATA example
View data.rb
puts DATA.gets
__END__
Hello Mr. World!
View app.js
helpButton.on("click", event => {
chan.push("help_needed", {})
})
@zamith
zamith / strings.rb
Created Jul 19, 2015
Format strings
View strings.rb
str = "this is a template string with a %{placeholder} in it"
puts str % { "placeholder": "piece of text" }
# => this is a template string with a piece of text in it
View github_dependency.cr
def install
unless Dir.exists?(target_dir)
repo_url = if @use_ssh
"git@github.com:#{@author}/#{@repository}.git"
else
"git://github.com/#{@author}/#{@repository}.git"
end
exec "git clone#{@branch} #{repo_url} #{target_dir}"
end
View controller
def index
@plans = Plan.all
@graph = Graph.new(@plans)
end
View gist:a63913959d9d4ed67650
(node.v.element.children.data[0].value as LibGumbo::GumboNode).value.type
# Lib
struct GumboNode
type: GumboNodeType
parent: GumboNode*
index_with_parent: LibC::SizeT
parse_flags: GumboParseFlags
v: Node
View mocks.cr
require "spec"
class Double
def initialize(@name, @stubs = {} of Symbol => Object)
end
def receives_and_returns(method_name = :none, return_value = true)
stubs[method_name] = return_value
end
View gist:389a0fef4fc7fef6785e
$ crystal spec/compiler/lexer/lexer_string_array_spec.cr
Using compiled compiler at .build/crystal
Undefined symbols for architecture x86_64:
"_LLVMInitializeX86AsmPrinter", referenced from:
_*LLVM::init_x86:(Void | Nil) in LLVM.o
"_LLVMInitializeX86Target", referenced from:
_*LLVM::init_x86:(Void | Nil) in LLVM.o
"_LLVMInitializeX86TargetInfo", referenced from:
_*LLVM::init_x86:(Void | Nil) in LLVM.o
"_LLVMInitializeX86TargetMC", referenced from: