Skip to content

Instantly share code, notes, and snippets.

View barsukov's full-sized avatar

Wowa Barsukov barsukov

  • Berlin, Germany
View GitHub Profile

2015-01-29 Unofficial Relay FAQ

Compilation of questions and answers about Relay from React.js Conf.

Disclaimer: I work on Relay at Facebook. Relay is a complex system on which we're iterating aggressively. I'll do my best here to provide accurate, useful answers, but the details are subject to change. I may also be wrong. Feedback and additional questions are welcome.

What is Relay?

Relay is a new framework from Facebook that provides data-fetching functionality for React applications. It was announced at React.js Conf (January 2015).

@barsukov
barsukov / embedded_many.rb
Created September 10, 2014 12:02
Move embedded many to has_many mongoid.
child_coll = Mongoid.default_session[:children]
Parent.all.each do |p|
p.childs.all.each do |c|
c.attributes['parent_id'] = p.id
child_coll.insert c.attributes # save children to separate collection
end
p.childs = nil # remove embedded data
@barsukov
barsukov / active_model_serializer.rb
Last active August 29, 2015 14:05
Active model serializer pass parametrs like options
class LoLSerializer < ActiveModel::Serializer
...
hash["super_trooper"] = options[:super_trooper]
...
end
..
#Usage:
ActiveModel::ArraySerializer.new(ololol_collection,
each_serializer: LoLSerializer, super_trooper: params[:super_trooper]).to_json
@barsukov
barsukov / overlaping_date.rb
Created August 7, 2014 08:32
This is paste of overlaping date usual task
class Interval < ActiveRecord::Base
validates_presence_of :start_date, :end_date
# Check if a given interval overlaps this interval
def overlaps?(other)
(start_date - other.end_date) * (other.start_date - end_date) >= 0
end
# Return a scope for all interval overlapping the given interval, including the given interval itself
Factory.define :item do |f|
include ActionDispatch::TestProcess
f.name "Macbook Pro 15"
f.price_in_dollars 1500
f.photo fixture_file_upload('/files/avatar.jpg', 'image/jpg')
end
@barsukov
barsukov / symbolic_link.sh
Last active August 29, 2015 13:58
SImple way to change symbolic link to antoher source
@barsukov
barsukov / state_machine_names.rb
Last active August 29, 2015 13:58
quick get all names from custom state machine (gem state machine)
def available_types
ClassName.state_machines[:message_type].states.map &:name
end
...
cell.recalculate
...
class Sheet
def build_sheet
...
cell = ValueCell.new(self,"A1","A2")
...
cell.recalculate

Capybara

save_and_open_page

Matchers

have_button(locator)