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
class CreatePost | |
def self.call(*args) | |
new(*args).call | |
end | |
include Virtus.model | |
attribute :user | |
attribute :post_params | |
attribute :image |
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
class GetFacebookPages | |
def self.call(*args) | |
new(*args).call | |
end | |
include Virtus.model | |
attribute :account, FacebookAccount | |
def call |
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
# This file should contain all the record creation needed to seed the database with its default values. | |
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). | |
# | |
# Examples: | |
# | |
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) | |
# Mayor.create(name: 'Emanuel', city: cities.first) | |
xlsx = Roo::Spreadsheet.open('db/xlsx/zipcodes.xlsx') | |
sheet = xlsx.sheet(0) |
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
class FacebookGraph | |
def initialize(token) | |
@graph = Koala::Facebook::API.new(token) | |
end | |
def profile | |
@graph.get_object('me') | |
end | |
def friends_ids |
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
class MyClass | |
def word | |
"word" | |
end | |
def go | |
word = word | |
word | |
end | |
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
class MyClass | |
def word | |
"word" | |
end | |
def go | |
word = word + "whatever" | |
word | |
end | |
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
# full description: | |
# https://codility.com/demo/take-sample-test/ps/ | |
# tl;dr: Write a function that, given a zero-indexed non-empty array A consisting of N integers, returns the first covering prefix of A. | |
def solution(a) | |
last_unique = a.uniq.last | |
a.index { |el| el == last_unique } | |
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
class Triangle | |
attr_reader :a | |
attr_reader :b | |
attr_reader :c | |
def initialize(a, b, c) | |
@a, @b, @c = a, b, c | |
end | |
def type |
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
class BuckFizz | |
def print | |
all.each do |buck_fizz| | |
puts buck_fizz | |
end | |
end | |
private | |
def all |
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
def fibbonaci_iterate do | |
Stream.unfold([0, 1], fn [prev, curr] -> {curr, [curr, (prev + curr)]} end) | |
end | |
# fibbonaci_iterate |> Stream.take_every(10) |> Stream.map(fn(x) -> x * 2 end) |> Enum.take(5) | |
# [2, 178, 21892, 2692538, 331160282] | |
# note that the list was actually only enumerated once |
OlderNewer