-
1.8.7 - Retired since 2013-06-30
-
1.9.3 - Retired since 2015-02-23 - No bug fix, nor even security ones will be backported then
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/views/price_versions/_form.html.erb | |
# Shorted to only the main parts. | |
# I hook into the stimulus controller with "html: { data: { controller: :imask } }" at the form. | |
# I trigger the mask in each input field by using "as: masked_priced" (that will be rendered by MaskedPriceInput custom SimpleForm input. | |
<%= simple_form_for [versionable, price_version], | |
wrapper: :half_horizontal_form_bs5, | |
html: { data: { controller: :imask } } do |f| %> | |
<%= f.simple_fields_for :size_prices, size_prices do |spf| %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example from: http://hanamirb.org/guides/1.2/getting-started/#implementing-create-action | |
module Web::Controllers::Books | |
class Create | |
include Web::Action | |
def call(params) | |
BookRepository.new.create(params[:book]) | |
redirect_to '/books' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
module Api | |
module V1 | |
# Controller to consume read-only data to be used on client's frontend | |
class FrontEndController < ActionController::API | |
include Orderable | |
# GET /:resource | |
# GET /:resource.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
begin | |
require "bundler/inline" | |
rescue LoadError => e | |
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler" | |
raise e | |
end | |
gemfile(true) do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding: utf-8 | |
# This will remove old Readline if it's already defined | |
require 'rb-readline' | |
# This will load RbReadline for real | |
require 'rbreadline' | |
# This will load Readline that relies on RbReadline | |
require 'readline' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# This codeship custom script depends on: | |
# - API_KEY env var from Heroku | |
# - STAGING_APP_NAME | |
# - STAGING_APP_URL | |
set -e | |
export HEROKU_API_KEY="${API_KEY}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module FactoryGirl::Syntax::Methods | |
def find_or_create(name, attributes = {}, &block) | |
factory = FactoryGirl.factory_by_name(name) | |
clazz = factory.build_class | |
factory_attributes = FactoryGirl.attributes_for(name) | |
attributes = factory_attributes.merge(attributes) | |
clazz.find_or_create_by(attributes, &block) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
file = File.open "acao_e_reacao_utf16_le.txt" | |
=> #<File:acao_e_reacao_utf16_le.txt> | |
file.methods.grep /enc/ | |
=> [:external_encoding, :internal_encoding, :set_encoding] | |
file.external_encoding | |
=> #<Encoding:UTF-8> | |
file.internal_encoding |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
#coding: utf-8 | |
def del_first_three_original_1(a) | |
num_to_del = a.find { |e| a.count(e) >= 3 } | |
return a if num_to_del.nil? | |
3.times do | |
ind = a.index { |e| e == num_to_del } | |
a.delete_at(ind) | |
end |
NewerOlder