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 describe(description, &block) | |
| Describe.new(description, block).run | |
| end | |
| class Describe | |
| def initialize(description, block) | |
| @description = description | |
| @block = block | |
| 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
| expect(1 + 1) | |
| => #<Actual:0x00007fa4491e4fc0 @actual=2> | |
| expect(1 + 1).to(eq(2)) | |
| eq(2) | |
| => | |
| expect do | |
| raise ArgumentError.new |
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
| chains = Chain.all.select { |chain| chain.agents_all_commission >= 30 }.select { |chain| chain.agents.map(&:country).include?("MY") } | |
| chains.map { |chain| chains.agents.map(&:country) } | |
| ## 109 are malaysian agents. |
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
| import React, { Component } from 'react' | |
| ## Routers are components as well | |
| const Home = () => { | |
| <div> | |
| Home | |
| </div> | |
| } |
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
| import { battle } from '../utils/api' | |
| constructor(props) { | |
| super(props) | |
| this.state = { | |
| winner: null, | |
| loser: null, | |
| error: null, | |
| loading: true |
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
| // look at the states used in Popular.js | |
| // States. | |
| constructor(props) { | |
| super(props) | |
| this.state = { | |
| selectedLanguage: 'All', | |
| repos: {}, | |
| error: null |
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 is very interesting because, just 1 little change to useContext brings so much benefits to the codebase | |
| export default function Nav() { | |
| const { locale, toggleLocale} = React.useContext( | |
| ) | |
| } | |
| // update code from using LocaleContext.Consumer to useContext |
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
| function reducer(state, action) { | |
| switch (action.type) { | |
| case "fetch": | |
| return { | |
| ...state, | |
| loading: true | |
| }; | |
| case "success": | |
| return { | |
| data: action.data, |
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
| We recently have this feature, where we provide customer's ability to edit / modify content shown in an email. | |
| 1. We need a templating language, something which is not too confusing for customers. | |
| 2. Data from customers need to be sanitized before it is run in the application. In the case of customer putting something like | |
| <%= User.delete_all %> | |
| 3. | |
| def template_renderer(shop) | |
| template = ActionController::Base.renderer.new.render(tempalte: template_file) | |
| Liquid::Template.parse(template) | |
| ## returns a Liquid::Template object |
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
| // something |