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
// XORCipher - Super simple encryption using XOR and Base64 | |
// | |
// Depends on [Underscore](http://underscorejs.org/). | |
// | |
// As a warning, this is **not** a secure encryption algorythm. It uses a very | |
// simplistic keystore and will be easy to crack. | |
// | |
// The Base64 algorythm is a modification of the one used in phpjs.org | |
// * http://phpjs.org/functions/base64_encode/ | |
// * http://phpjs.org/functions/base64_decode/ |
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 myPromise() { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
resolve('Stack Overflow'); | |
// reject('Some Error') | |
}, 2000); | |
}); | |
} | |
function showSpinner() { |
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 React from 'react'; | |
import ReactDOM from 'react-dom'; | |
import App from './App'; | |
import registerServiceWorker from './registerServiceWorker'; | |
import { combineReducers, createStore } from 'redux' | |
import { Provider } from 'react-redux'; | |
import todoReducer from './reducer/todoReducer' | |
import throttle from 'lodash/throttle' |
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 url = 'auth/user/ucok'; | |
const lastStr = url.split("/").slice(-1)[0]; | |
// output 'ucok' |
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 | |
var max = 250 | |
var min = 50 | |
var input = 65 | |
var percent = ((input - min) * 100) / (max - min) | |
// a little longer | |
var range = max - min | |
var correctedStartValue = input - min | |
var percentage = (correctedStartValue * 100) / range |
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
1 == 1 //->true | |
1 == "1" //->true | |
1 == true//-> true | |
1 == 0 //-> false | |
1 == [] //-> false |
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
mport React from 'react'; | |
import { shallow, mount, render } from 'enzyme'; | |
import Todo from '../components/Todo'; | |
import { configure } from 'enzyme'; | |
import Adapter from 'enzyme-adapter-react-16'; | |
configure({ adapter: new Adapter() }); | |
test('Test it', async () => { |
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 fibonacci(num){ | |
var a = 1, b = 0, temp; | |
while (num >= 0){ | |
temp = a; | |
a = a + b; | |
b = temp; | |
num--; | |
} |
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 React, { useState } from "react"; | |
import ReactDOM from "react-dom"; | |
import { Transition } from "react-transition-group"; | |
import "./styles.css"; | |
function App() { | |
const [visible, setVisible] = useState(true); | |
return ( |
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 time = 3600 //second 1 hour | |
var minutes = Math.floor(time / 60); | |
//And to get the remaining seconds, multiply the full minutes with 60 and subtract from the total seconds: | |
var seconds = time - minutes * 60; | |
//Now if you also want to get the full hours too, divide the number of total seconds by 3600 (60 minutes/hour · 60 seconds/minute) first, then calculate the remaining seconds: | |
var hours = Math.floor(time / 3600); |