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
# Change Bash's autocomplete to be case insenstive | |
bind "set completion-ignore-case on" | |
# Fancy PS1 | |
expressions=("👉" "🐙" "🐼" "🎉" "🏆" "👾" "🌍" "🏗️" "🗽" "🌚" "🔥" "💻" "💰" "✏️" "📌") | |
selectedexpression=${expressions[$RANDOM % ${#expressions[@]} ]} | |
export PS1="\e[38;5;208m$(echo $selectedexpression) PavSidhu:\W > \[$(tput sgr0)\]\[$(tput sgr0)\]" | |
# Git Aliases | |
alias g="git" |
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 validation from 'validation.js' | |
export default function validate(fieldName, value) { | |
// Validate.js validates your values as an object | |
// e.g. var form = {email: '[email protected]'} | |
// Line 8-9 creates an object based on the field name and field value | |
var formValues = {} | |
formValues[fieldName] = value | |
// Line 13-14 creates an temporary form with the validation fields |
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 React, {Component} from 'react' | |
import {View, Button} from 'react-native' | |
import TextField from 'textfield' | |
import validation from 'validation' | |
import validate from 'validation_wrapper' | |
export default class Form extends Component { | |
constructor(props) { | |
super(props) |
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 React from 'react' | |
import { View, TextInput, Text } from 'react-native' | |
const TextField = props => ( | |
<View> | |
<TextInput/> | |
{props.error && <Text>{props.error}</Text>} | |
</View> | |
) |
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 validation = { | |
email: { | |
presence: { | |
message: '^Please enter an email address' | |
}, | |
email: { | |
message: '^Please enter a valid email address' | |
} | |
}, | |
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 React, {Component} from 'react' | |
import {AppRegistry} from 'react-native' | |
import {Provider} from 'react-redux' | |
import App from './app' | |
import configureStore from './store.js' | |
const store = configureStore() | |
class MyCounterApp extends Component { |
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 reducer from './reducer' | |
// This connects the reducer to the store | |
export default function configureStore() { | |
let store = createStore( | |
reducer | |
) | |
return store | |
} |
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
// We speciify the name of the action as a variable | |
const ADD_TO_COUNTER = 'ADD_TO_COUNTER' | |
// This is an action creator, it simply specifies the action. | |
// this is what we call to send an action. | |
export function addToCounter() { | |
return { | |
type: ADD_TO_COUNTER | |
} | |
} |
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 {ADD_TO_COUNTER} from './actions' | |
// This is the default state of the app i.e. when the app starts for the first time | |
const initialState = { | |
counter: 0 | |
} | |
// This is a reducer which listens to actions and modifies the state | |
const reducer = (state = initialState, action) => { | |
// A switch is used since if more actions are added in the future, it will be easy |
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
class App extends Component { | |
render() { | |
return ( | |
// this.props.count comes from the Redux state | |
<Text>{this.props.count}</Text> | |
// This.props.addToCounter() is a function to update the counter | |
<Button onPress={() => this.props.addToCounter()}> | |
Click Me! | |
</Button> |
NewerOlder