Skip to content

Instantly share code, notes, and snippets.

View sergiomaia's full-sized avatar
💭
Focused

sergiomaia sergiomaia

💭
Focused
View GitHub Profile
# app/forms/registration.rb
class Registration
include ActiveModel::Model
attr_accessor(
:company_name,
:email,
:first_name,
:last_name,
:terms_of_service
@sergiomaia
sergiomaia / magazine.html
Created January 30, 2017 15:46
Magazine Code
<iframe width="700px" height="425px" src="http://online.fliphtml5.com/cgpf/jhut/#p=1" frameborder="0" allowfullscreen allowtransparency></iframe>
@sergiomaia
sergiomaia / busca_linear.rb
Created September 27, 2017 02:40
Ruby Algorithm - Linear Search
def find_index(values, target)
values.each_with_index do |value, i|
return i if value == target
end
end
find_index([2, 4, 6, 8, 10, 12], 6)
# => 2
require 'rspec'
string_collection = [
"Web IconHTML & CSS100%",
"Command LineLearn the Command Line100%",
"Ruby IconRuby50%",
"Rails IconLearn Ruby on Rails100%",
"Git IconLearn Git100%",
"SassLearn Sass20%",
"JQuery IconjQuery1%",
{
"public": [
{
"thumb": "/uploads/user/avatar/thumb_6fd0915dcee8eb1a04bb215f68ecfa5a.png",
"name": "Lucky Luciano",
"email": "lif****@xample.com"
}
],
"privates": [
{
# tenho a seguinte situação:
def update
ids = params["_json"].map { |hash| hash["id"] } # --> return [10, 20, 30, 40, 50]
positions = params["_json"].map { |hash| hash["position"] } # --> return [0, 1, 2, 3, 4]
query = MyQueryQuery.new
query.visible = true
query.active = true