Skip to content

Instantly share code, notes, and snippets.

@zxbodya
zxbodya / render-react-with-rxjs.md
Last active November 1, 2021 08:49
React with RxJS, reactive way :)

Observable React elements with RxJS

Note: if you want to skip history behind this, and just looking for final result see: rx-react-container

When I just started using RxJS with React, I was subscribing to observables in componentDidMount and disposing subscriptions at componentWillUnmount.

But, soon I realised that it is not fun to do all that subscriptions(that are just updating property in component state) manually, and written mixin for this...

Later I have rewritten it as "high order component" and added possibility to pass also obsarvers that will receive events from component.

@coreyhaines
coreyhaines / .rspec
Last active April 11, 2024 00:19
Active Record Spec Helper - Loading just active record
--colour
-I app
@mrpunkin
mrpunkin / arel_based.rb
Created March 7, 2012 21:47
Using arel to query SQL functions
dc = Arel::Nodes::NamedFunction.new "DATE", [ p[:created_at] ] ## second argument must be an array
## Sub this...
arel.project("DATE(`photos`.`created_at`)")
## For this...
arel.project(dc.to_sql)
arel.to_sql >> "SELECT DATE(`photos`.`created_at`) FROM `photos` INNER JOIN `votes` ON `photos`.`id` = `votes`.`photo_id`"
@tansengming
tansengming / Rails Console Actionmailer test.rb
Created April 24, 2009 15:14
Rails Console Actionmailer test
# Copy and paste this to the rails console to test your email settings
class MyMailer < ActionMailer::Base
def test_email
@recipients = "someone@somewhere.com"
@from = "must_be_same_as_smpt_account_login@gmail.com"
@subject = "test from the Rails Console"
@body = "This is a test email"
end
end