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
| // Sample usage: (taken from https://github.com/sobstel/golazon) | |
| // | |
| // class Competition extends Component { | |
| // (...) | |
| // } | |
| // | |
| // const fetchData = ({ id }) => { | |
| // return competitionService.competition(id).then(competition => ({ competition })); | |
| // }; | |
| // |
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
| const API_URL = '...'; | |
| const TIMEOUT = 10; // seconds | |
| export default (path) => { | |
| /* global fetch */ | |
| const req = fetch(API_URL + path); | |
| const timeout = new Promise((resolve, reject) => { | |
| return setTimeout(() => reject(new Error('request timeout')), TIMEOUT * 1000); | |
| }); |
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
| There's a staircase with N steps, and you can climb 1 or 2 steps at a time. | |
| Given N, write a function that returns the number of unique ways you can | |
| climb the staircase. The order of the steps matters. | |
| For example, if N is 4, then there are 5 unique ways: | |
| 1, 1, 1, 1 | |
| 2, 1, 1 | |
| 1, 2, 1 |
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
| Warden::Manager.after_authentication do |user, auth, _opts| | |
| cookies = ActionDispatch::Request.new(auth.env).cookie_jar | |
| cookies.encrypted[REMEMBER_ME_COOKIE_NAME] = { value: user.id, expires: 1.week.from_now } | |
| 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
| #!/bin/bash | |
| # stop on first error | |
| set -e | |
| command -v heroku >/dev/null 2>&1 || { echo >&2 "heroku command is required"; exit 1; } | |
| command -v docker-compose >/dev/null 2>&1 || { echo >&2 "docker-compose command is required"; exit 1; } | |
| DUMPFILE="/tmp/_FILENAME_.dump" |
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
| source 'https://rubygems.org' | |
| ruby '~> 2.3.1' | |
| gem 'cuba' |
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
| // | |
| // Optimizes all images | |
| // (takes only those that have no corresponding @2x) | |
| // | |
| const im = require('imagemagick'); | |
| const glob = require('glob'); | |
| const fs = require('fs'); | |
| const { exec } = require('child_process'); |
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
| const CONNECTION_TIMEOUT = 20000; | |
| function getData (url) { | |
| let timer = null; | |
| const service = fetch(url) | |
| .then((response) => { | |
| clearTimeout(timer); | |
| return response.json(); | |
| }); |
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, { PropTypes, PureComponent } from 'react'; | |
| import { Image, ScrollView, } from 'react-native'; | |
| export default class ScrollViewWithBg extends PureComponent { | |
| constructor (props) { | |
| super(props); | |
| this.state = {contentSize: {width: 0, height: 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
| module Translatable | |
| extend ActiveSupport::Concern | |
| included do | |
| translation_class_name = "Translations::#{model_name}Translation" | |
| has_many :translations, | |
| class_name: translation_class_name, | |
| dependent: :delete_all, | |
| inverse_of: model_name.to_s.underscore.to_sym |