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
| // define a reducer | |
| const reducer = function(state, action) { | |
| if (action.type === 'INC') { | |
| return state + action.payload | |
| } else if (action.type === 'DEC') { | |
| return state - action.payload | |
| } | |
| return state | |
| } |
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
| # .htaccess template | |
| # http://www.htaccesseditor.com/en.shtml#a_extension | |
| # Default page | |
| # (in order of first specified) | |
| ############### | |
| DirectoryIndex index.html index.php | |
| # Enable Rewrites |
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
| ; the following three settings limit the maximum size of data that can be submitted and handled by PHP | |
| ; One user also said that post_max_size and memory_limit need to be larger than upload_max_filesize. | |
| post_max_size = 128M | |
| memory_limit = 128M | |
| upload_max_filesize = 64M ; e.g. when importing databases, general file uploads |
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
| // $Font Variables | |
| $font-body: 'Open Sans', Tahoma, sans-serif; | |
| $font-headings: 'Brandon Grotesque', Georgia, serif; | |
| $font-code: Consolas, Monaco, Lucida Console, monospace; | |
| // $Color Variables | |
| $color-brand-pink: #F17B91; | |
| $color-brand1: #F599C0; | |
| $color-brand2: #59CBF5; |
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 { createStore, applyMiddleware } from 'redux' | |
| import createLogger from 'redux-logger' // logger so i don't have to manually log state before & after every dispatched action | |
| // REDUCER | |
| const counter = (state = 0, action) => { | |
| switch(action.type) { | |
| case 'INCREMENT': | |
| return state + 1 | |
| case 'DECREMENT': | |
| return state - 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
| // Basic AJAX Example | |
| import React, { Component } from 'react' | |
| import { render } from 'react-dom' | |
| import { createStore, applyMiddleware, combineReducers } from 'redux' | |
| import { Provider, connect } from 'react-redux' | |
| import axios from 'axios' | |
| import createLogger from 'redux-logger' | |
| import thunkMiddleware from 'redux-thunk' | |
| const logger = createLogger() |
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
| <table> | |
| <caption>Awesome caption</caption> | |
| <thead> | |
| <tr> | |
| <th></th> | |
| <th>million km</th> | |
| <th>m</th> | |
| </tr> | |
| </thead> | |
| <tbody> |
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
| let nums = [1, 2] | |
| let newNums = nums.concat(3) | |
| console.info(newNums) // [ 1, 2, 3 ] | |
| let moreNums = nums.concat(3, 4, 5) | |
| console.info(moreNums) // [ 1, 2, 3, 4, 5 ] | |
| let diverseNums = nums.concat(true, 'hello', undefined) | |
| console.info(diverseNums) // [ 1, 2, true, 'hello', undefined ] |
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
| let items = [ 1, 2, 3, 4, 5, 6 ] | |
| let filtered = items.filter(x => x > 3) | |
| console.info('filtered:', filtered) // filtered: [ 4, 5, 6 ] |
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
| /* | |
| Loop over a two-dimensional array | |
| https://jsfiddle.net/7p6g03z6/ | |
| */ | |
| arr = ['Ali', 'Hakim', 'Rana', ['Shahid', 'Naeem']] | |
| // Map and Conditional (ternary) Operator | |
| arr.map(name => { | |
| Array.isArray(name) |