Skip to content

Instantly share code, notes, and snippets.

View rajaraodv's full-sized avatar

Raja Rao DV rajaraodv

View GitHub Profile
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"));
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) {
@rajaraodv
rajaraodv / verify-jwt.js
Created November 30, 2016 14:50
verify jwt in app.js
//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 ', '');
@rajaraodv
rajaraodv / TicTacToeHyperapp.js
Last active October 15, 2017 23:23
Hyperapp version of TicTacToe app
const { h, app } = hyperapp;
/** @jsx h */
function Square(props) {
return (
<button class="square" onclick={props.onClick}>
{props.value}
</button>
);
}
@rajaraodv
rajaraodv / TicTacToeReact.js
Created October 15, 2017 23:22
React's version of TicTacToe
function Square(props) {
return (
<button className="square" onClick={props.onClick}>
{props.value}
</button>
);
}
class Board extends React.Component {
renderSquare(i) {
{
"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": [] },
{
"segments": {
"left": [
{
"function": "powerline.segments.shell.mode"
},
{
"function": "powerline.segments.common.net.hostname",
"priority": 10
},
@rajaraodv
rajaraodv / warnings in mate
Created April 15, 2018 21:23
Mate admin theme install warnings..
arning Resolution field "[email protected]" is incompatible with requested version "react@^15.6.2"
warning Resolution field "[email protected]" is incompatible with requested version "react-dom@^15.6.2"
warning Resolution field "[email protected]" is incompatible with requested version "react@^15.4.1"
warning Resolution field "[email protected]" is incompatible with requested version "react@^15.0.2"
warning Resolution field "[email protected]" is incompatible with requested version "react-dom@^15.0.2"
[2/4] 🚚 Fetching packages...
[3/4] 🔗 Linking dependencies...
warning "firebase > @firebase/[email protected]" has unmet peer dependency "@firebase/app-types@^0.1.0".
warning "firebase > @firebase/[email protected]" has unmet peer dependency "@firebase/app-types@^0.1.0".
warning "firebase > @firebase/[email protected]" has unmet peer dependency "@firebase/app-types@^0.1.0".
//Note: This is just an example in Java. This shows how to print and also how to call that method.
//Feel free to change it to your language and framework needs
// Get the browser, viewport and device info from a variable like below or from a file or environment variable.
public static String browser = "Firefox";
public static String viewport = "1200X700";
public static String device = "Laptop";
/**
@rajaraodv
rajaraodv / HackathonReporter.js
Last active July 11, 2020 03:08
An example Test Reporter method in JavaScript
//Note: This is just an example in JavaScript. This shows how to print and also how to call that method.
//Feel free to change it to your language and framework needs
const fs = require('fs');
// Get the browser, viewport and device info from a variable like below or from a file or environment variable.
const browser = "Firefox";
const viewport = "1200x700";
const device = "Laptop";