Skip to content

Instantly share code, notes, and snippets.

View pjurczynski's full-sized avatar
💻
working

Piotr Jurczyński pjurczynski

💻
working
  • Pix4d
  • Switzerland, Lausanne
View GitHub Profile
import { combineLatest } from 'rxjs';
import { TestScheduler } from 'rxjs/testing';
const testScheduler = new TestScheduler((actual, expected) => {
expect(actual).toEqual(expected);
});
describe('simple example of rxjs-marbles', () => {
it('combineLatest', () => {
testScheduler.run(({ expectObservable, cold, hot, expectSubscriptions, flush }) => {

Arel Table

The problem: You want some advanced function from sql, but active record won't help

Example: SELECT * FROM users WHERE name LIKE '%hacker%'

Active Record: User.where("name LIKE '%?%'", 'hacker')

Why it's bad?

class SomeController
@$inject = ['$scope']
constructor: (@scope) ->
$state.transitionTo('app.game.welcome')
someVar: 'xx'
someMethod: ->
console.log "method!"
run Rack::URLMap.new \
'http://api.storytelling.dev/' => API,
'http://api.storytelling.dev/doc/' => GrapeSwaggerRails::Engine,
'http://admin.storytelling.dev/' => Rails.application
def users_to_invite
users ||= begin
contacts_to_connect = Contact.from_id(connection_params[:contact_ids])
emails_to_connect = connection_params[:email_list].split ','
(contacts_to_connect.pluck(:primary_email) + emails_to_connect).uniq
end
end
def count_customers(customer_id, order_count, totals, repeat_customers, new_customers, newly_promising_customers, newly_loyal_customers)
total_orders = totals.fetch(customer_id, 0)
if total_orders == 1 || order_count == total_orders
new_customers += 1
elsif total_orders == 2
newly_promising_customers += 1
elsif (total_orders - order_count) < 4
newly_loyal_customers += 1
elsif order_count != total_orders
class FakeModel
# …
def self.load_from_yml(table_name)
YAML.load(File.read(Rails.root.join("config/wpp/#{ table_name }.yml")))[table_name]
end
# …
end
class FakeModel
# …
def self.load_from_yml(table_name)
YAML.load(File.read(Rails.root.join("config/wpp/#{ table_name }.yml")))[table_name]
end
# …
end
wpp.com/en/stories
wpp.com/stories?lang=en
wpp.com/stories #autodetect english
wpp.com/fr/stories
wpp.com/stories?lang=fr
wpp.com/stories #autodetect french
class AppBuilder < Rails::AppBuilder
include Thor::Actions
include Thor::Shell
def test
append_test_gems
rspec
cucumber
jasmine
end