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
.parent{ | |
display:flex; | |
flex-direction:column; | |
} | |
.child{ | |
flex: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
//spread the options here.... | |
let xhrURLOptns = { | |
cors: true, | |
crossDomain: true, | |
contentType: 'application/json', | |
withCredentials: true, | |
beforeSend: function (xhr) { | |
xhr.setRequestHeader('Authorization', `Bearer ${token}`); |
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
/* | |
Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 - 1], then return 0. Assume the environment does not allow you to store 64-bit integers (signed or unsigned). | |
Examples :: | |
1. Input: x = 123, Output: 321 | |
2. Input: x = -123, Output: -321 | |
3. Input: x = 120, Output: 21 | |
//you could spread a string to an array.. rather than splitting it. |
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 axios from "axios"; | |
import * as config from './Settings'; //get app settings.. | |
import { store } from '../index'; | |
//initialize headers... | |
const headers = { 'Content-type': 'application/json; charset=UTF-8' }; | |
//use interceptors to catch all axios events.. loading events... | |
// Add a request interceptor |
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
//on the index.js - import required libraries.. | |
import { Provider } from 'react-redux'; | |
import { createStore, applyMiddleware, compose } from 'redux'; | |
import thunk from 'redux-thunk'; | |
import reducers from './reducers/index'; //all reducers combined here.. | |
const store = createStore(reducers, compose(applyMiddleware(thunk))); | |
// also you refactor the initaal ReactDom.render script to this... |
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
//npm install bcrypt --save | |
import bcrypt from 'bcryptjs'; | |
import UserModel from '../models/users.js'; | |
export default config = { | |
PORT: 5200, | |
DB_USER: '.......', | |
DB_PASS: '.......', | |
DB_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
let arr = paginate(index, len); | |
const paginate = (index, len) => { | |
let curIndex = (index === null) ? 1 : index; | |
let prvArr = (curIndex == 1) ? [] : (curIndex == 2) ? [1] : (curIndex == 3) ? [1, 2] : ['..', curIndex - 1]; | |
let nxtArr = (curIndex == len) ? [] : (curIndex == len - 1) ? [len] : (curIndex == len - 2) ? [len - 2, len - 1] : [curIndex + 1, '...']; | |
return [1, ...prvArr, curIndex, ...nxtArr, len] | |
.filter((v, i, s) => s.indexOf(v) === i) | |
.map(v => v === '..' ? '...' : v) | |
.map(v => v === '...' ? '.....' : v); |
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
// mongoDB Shell Commands... | |
// show dbs - show databases. | |
// use mycustomDatabase - create database and switch | |
// db - show me the current database being used... | |
db.createUser({ | |
user:"antyrii", | |
pwd: "99wcl34", |
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
var arr = String('aminu;ocholi;oketta;odinma;mohammed;fidelis;james;brown;').split(';'); | |
var students = [ | |
{ name: 'aminu', age: 9, class: 'primary 6' }, | |
{ name: 'delilah', age: 84, class: 'primary 6' }, | |
{ name: 'mary', age: 19, class: 'primary 6' }, | |
{ name: 'sujim', age: 12, class: 'primary 6' }, | |
{ name: 'Mohammed', age: 29, class: 'primary 6' }, | |
{ name: 'Tango', age: 84, class: 'primary 6' }, |
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 lonelyinteger(a) { | |
// Write your code here | |
let isUnique = (value, index, self) => self.indexOf(value) === index; | |
let distinct = a.filter(isUnique); | |
let lonelyint = null; | |
distinct.forEach(v => { | |
if (a.filter(index => index == v).length == 1) { | |
lonelyint = v; | |
} | |
}); |
NewerOlder