- Architecture of client-side code
- Responsibilities
This file contains 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 snakeToCamelObjectKeys(obj) { | |
return Object.keys(obj).reduce((output, key) => { | |
let value = obj[key] | |
const isObject = value.toString() === '[object Object]' | |
if (isObject) { | |
value = snakeToCamelObjectKeys(value) | |
} | |
const newKey = key.replace(/_(\w)/g, (match, $1) => $1.toUpperCase()) |
This file contains 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
//@flow | |
import React, { Component } from 'react' | |
import type { ElementRef } from 'react' | |
type Props = { src: string, alt: string } | |
type State = { source?: string } | |
export default class LazyImage extends Component<Props, State> { | |
state = {} |
This file contains 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 React = require('react') | |
const ReactDomServer = require('react-dom/server') | |
const fetch = require('node-fetch') | |
function App(props) { | |
const { repos } = props | |
return React.createElement('p', { | |
children: repos.length ? repos[0].name : 'no name', | |
}) |
This file contains 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
Configuring Charles to proxy, so you can test localhost on a virtual machine. | |
1. In Charles proxy settings, set a port, i.e., 8889. | |
2. In your VM, modify the local area settings. | |
1. In IE, go to Settings > Connections > LAN Settings | |
2. Under proxy server, select Use a proxy server. | |
3. Under proxy server Address, use your machine's IP. | |
4. Under proxy server Port, use the Charles proxy port, i.e., 8889. | |
3. Turn on proxying in Charles. |
This file contains 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 { columns, display, gridSpans, margin } from './css-modules-styles' | |
const COLUMNS = 12 | |
const toArray = arrayLike => Array.prototype.slice.call(arrayLike) | |
const placeItemsOnGrid = grid => { | |
const withGutters = grid.classList.contains(columns.withGutters) | |
let currentColumnSpansInRow = 0 | |
let currentRow = 1 |
This file contains 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 { parse } = require('css') | |
const { readdirSync, readFileSync } = require('fs') | |
const { basename, extname, resolve } = require('path') | |
const camel = require('lodash.camelcase') | |
const baseNameForCSSFile = filename => basename(filename, '.css') | |
const isAClassSelector = selector => /^\./.test(selector) | |
const removeLeadingDotAndTrailingSelectors = selector => |
This file contains 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
{ | |
"rules": { | |
"indent": [ | |
2, 2 | |
], | |
"quotes": [ | |
2, | |
"single" | |
], | |
"linebreak-style": [ |
This file contains 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
Show hidden characters
{ | |
"disallowImplicitTypeConversion": ["numeric", "boolean", "binary", "string"], | |
"disallowKeywordsOnNewLine": ["else"], | |
"disallowMixedSpacesAndTabs": true, | |
"disallowTrailingWhitespace": true, | |
"disallowTrailingComma": true, | |
"disallowYodaConditions": true, | |
"disallowKeywords": [ "with" ], | |
"disallowMultipleLineBreaks": true, | |
"disallowMultipleVarDecl": "strict", |
This file contains 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/sh | |
protectedBranch='master' | |
currentBranch=$(git rev-parse --abbrev-ref HEAD) | |
lastCommand=$(ps -ocommand= -p $PPID) | |
disallowedCommand='force|\-f' | |
if [[ $lastCommand =~ $disallowedCommand ]] && [ $currentBranch = $protectedBranch ]; then | |
echo "Force pushing to $protectedBranch is not allowed. Your push is rejected." |
NewerOlder