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 from 'react' | |
import { Link, LinkProps, useRouteMatch } from 'react-router-dom' | |
const VendorContextLink = (props: LinkProps) => { | |
const match = useRouteMatch<{ vendorId: string }>('/vendors/:vendorId') | |
if (!match) { | |
return <Link {...props} /> | |
} |
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 range = n => Array.from({length: n}, (value, key) => key) | |
const range = (n, cb = (value, index) => index) => Array.from({length: n}, cb) |
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 from 'react' | |
import Downshift from 'downshift' | |
export default class Dropdown extends React.Component { | |
render() { | |
const { children, onChange } = this.props | |
return ( | |
<Downshift onChange={onChange}> | |
{({ |
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'; | |
/** | |
* Declarative approach to setInterval | |
*/ | |
class ReactInterval extends Component { | |
static propTypes = { | |
enabled: React.PropTypes.bool, | |
interval: React.PropTypes.number, // interval time in ms | |
onInterval: React.PropTypes.func.isRequired |
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
{ | |
"extends": "airbnb", | |
"parser": "babel-eslint", | |
"rules": { | |
"array-bracket-spacing": [2, "always"], | |
"comma-dangle": 0, | |
"consistent-return": 1, | |
"curly": [1, "multi-or-nest", "consistent"], | |
"eqeqeq": [2, "smart"], | |
"max-len": 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
class MobileAppInfo | |
# | |
# @param platform [String] Device Platform ("ios" or "android") | |
# @param app_name [String] Mobile App Name ("makeshift" or "makeshift_live") | |
# @param app_version = "" [String] App Version | |
# | |
def initialize(platform, app_name, app_version = "") | |
raise ArgumentError.new("Mobile App name is required. Example: 'makeshift'") unless UserDevice::APP_NAMES.include?(app_name) | |
raise ArgumentError.new("Mobile Platform is required. Example: 'ios'") unless UserDevice::DEVICE_TYPES.include?(platform) |
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
RSpec::Matchers.define :permit do |action| | |
match do |policy| | |
policy.public_send("#{action}?") | |
end | |
failure_message do |policy| | |
"#{policy.class} does not permit #{action} on #{policy.record} for #{policy.user.inspect}." | |
end | |
failure_message_when_negated do |policy| |
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
[ | |
{ | |
"id": 830, | |
"start": 1262279460, | |
"end": 1262281260, | |
"title": "\u003cscript\u003ealert(\"foo\")\u003c/script\u003e", | |
"body": "", | |
"multi": 0, | |
"allDay": false, | |
"extension_id": 2 |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Information</key> | |
<dict> | |
<key>Description</key> | |
<string>Map Rails ActiveSupport timezones to iOS readable timezone IDs.</string> | |
<key>Version</key> | |
<string>1.0</string> |
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
#Session controller provides a token | |
#/controllers/api/sessions_controller.rb | |
class Api::SessionsController < Devise::SessionsController | |
before_filter :authenticate_user!, :except => [:create] | |
before_filter :ensure_params_exist, :except => [:destroy] | |
respond_to :json | |
def create | |
resource = User.find_for_database_authentication(:email => params[:user_login][:email]) | |
return invalid_login_attempt unless resource |
NewerOlder