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
{ | |
"name": "Default color scheme for shell prompts", | |
"groups": { | |
"hostname": { "fg": "brightyellow", "bg": "mediumorange", "attrs": [] }, | |
"environment": { "fg": "white", "bg": "darkestgreen", "attrs": [] }, | |
"mode": { "fg": "darkestgreen", "bg": "brightgreen", "attrs": ["bold"] }, | |
"attached_clients": { "fg": "white", "bg": "darkestgreen", "attrs": [] }, | |
"gitstatus": { "fg": "gray8", "bg": "gray2", "attrs": [] }, | |
"gitstatus_branch": { "fg": "gray8", "bg": "gray2", "attrs": [] }, |
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
function Square(props) { | |
return ( | |
<button className="square" onClick={props.onClick}> | |
{props.value} | |
</button> | |
); | |
} | |
class Board extends React.Component { | |
renderSquare(i) { |
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 { h, app } = hyperapp; | |
/** @jsx h */ | |
function Square(props) { | |
return ( | |
<button class="square" onclick={props.onClick}> | |
{props.value} | |
</button> | |
); | |
} |
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
//https://github.com/rajaraodv/react-redux-blog/blob/master/app.js#L41-L63 | |
//middleware that checks if JWT token exists and verifies it if it does exist. | |
//In all the future routes, this helps to know if the request is authenticated or not. | |
app.use(function(req, res, next) { | |
// check header or url parameters or post parameters for token | |
var token = req.headers['authorization']; | |
if (!token) return next(); //if no token, continue | |
token = token.replace('Bearer ', ''); |
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 Validation = require('data.validation') //from folktalejs | |
const Success = Validation.Success | |
const Failure = Validation.Failure | |
const R = require('ramda'); | |
function isUsernameValid(a) { | |
return /^(0|[1-9][0-9]*)$/.test(a) ? Failure(["Username can't be a number"]) : Success(a) | |
} | |
function isPwdLengthCorrect(a) { |
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 tax = R.curry((tax, price) => { | |
if (!_.isNumber(price)) return Left(new Error("Price must be numeric")); | |
return Right(price + (tax * price)); | |
}); | |
const discount = R.curry((dis, price) => { | |
if (!_.isNumber(price)) return Left(new Error("Price must be numeric")); |
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
var Either = require('ramda-fantasy').Either; | |
var Left = Either.Left; | |
var Right = Either.Right; | |
const tax = R.curry((tax, price) => { | |
if (!_.isNumber(price)) return Left(new Error("Price must be numeric")); //<--Wrap Error in Either.Left | |
return Right(price + (tax * price)); //<--Wrap result in Either.Right | |
}); |
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
//imperative | |
//Returns error or price including tax | |
const tax = (tax, price) => { | |
if (!_.isNumber(price)) return new Error("Price must be numeric"); | |
return price + (tax * price); | |
}; | |
//Returns error or price indluding discount | |
const discount = (dis, price) => { |
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 Maybe { | |
constructor(val) { | |
this.val = val; | |
} | |
... | |
... | |
//"ap" takes another "maybe" and applies the function it's holding in itself. | |
//this.val MUST be a function or Nothing (and can't be some string or int) | |
ap(differentMayBe) { |
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 below gist shows how to take care of global variables and also make funcs chainable | |
//Global indexURLs map for different languages | |
let indexURLs = { | |
'en': 'http://mysite.com/en', //English | |
'sp': 'http://mysite.com/sp', //Spanish | |
'jp': 'http://mysite.com/jp' //Japanese | |
} | |
//Imperative |