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 UserDecorator < Draper::Decorator | |
# code | |
def most_recent_profile_photo | |
if object.uploads.present? | |
object.uploads.where('stage_id IS null').select { |upload| upload.uploadable_type == 'ProfilePhoto' }.last.media.service_url || '' | |
else | |
'https://cdn1.iconfinder.com/data/icons/business-charts/512/customer-512.png' | |
end | |
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
import axios from 'axios'; | |
import { AsyncStorage } from 'react-native'; | |
# Works | |
const client = () => { | |
let token = `Token eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyX2lkIjoxLCJleHAiOjE1NTkyNjY4MDl9.KlSSy_o-C8eACIgCrDPDCfUp5O6rqNuc1B5v-z7RoSpZmWc9Lo1BbWueZCVpHvkxOIjdZuTXxdR0mvk-CzwtvA'`; | |
console.log('Token is:', token); | |
const defaultOptions = { | |
headers: { |
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 client from '../utils/client'; | |
export default class Main extends React.Component { | |
state = { posts: [] } | |
componentWillMount() { | |
const request = client(); | |
request.get(`${API_ROOT}posts`).then(response => { | |
return response.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
// Too many nested conditionals | |
renderCurrentUser() { | |
const { currentUser, avatarSource } = this.state | |
const { size, photoStyle } = styles | |
if (avatarSource) { | |
return ( | |
<Image | |
style={photoStyle} | |
source={avatarSource} |
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
{ | |
"slides": [ | |
{ | |
"id":5, | |
"title": "VISIT US AT MGACE", | |
"sub_title":"Get the highest score in Tengen Tetris!", | |
"image":"https://i.imgur.com/Y79kxFy.png", | |
"page_link":"https://news.matchroom.net/visit-mgace/", | |
"target":"_self" | |
}, |
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' | |
import { | |
Animated, | |
Platform, | |
StyleSheet, | |
TouchableOpacity | |
} from 'react-native' | |
import PropTypes from 'prop-types' | |
import { Icon } from 'react-native-elements' |
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
// 1. Get total number of dice to be rolled. | |
const numberOfDice = Math.floor((Math.random() * 20)) | |
numberOfDice // What am I? | |
// 2. Variables to store dice rolls sum & individual rolls. | |
let diceSum = 0 | |
let diceRolls = [] | |
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
// Objectives | |
// Our goal with these exercises is to use arrays, objects, and the fundamental building blocks of JS to query our data | |
// and make new assertions. From a list of people whose attributes we have, what conclusions can be drawn? | |
// Hint | |
// 1. The most important piece of data we will work with is the people array below. | |
// 2. Take a moment to think about the objects in the array. | |
// 3. Contemplate how we could sort people based on the data we have about them. | |
// 4. All functions we write in this exercise will take the people array as it's only argument |
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 people = [{ | |
id: 1, | |
age: 18, | |
weight: '70kg', | |
followers: 200, | |
height: '160mm', | |
firstName: 'Loi', | |
lastName: 'Tran', | |
friendsCount: 100, | |
nationality: 'USA', |