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
/** | |
* Debounce wrapper for functions which are called rapidly | |
* This wrapper ensures that there is a minimum wait time | |
* between function invocations. | |
* @param func Function to be called | |
* @param wait Minimum time between function calls | |
* @param immediate True if function needs to be invoked immediately, | |
* false if needs to be invoked after delay | |
* @returns Debounced function with the same signature as `func` | |
*/ |
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
// Just copy and paste the following code in the console | |
var logt = createLogger(5); | |
function add(a, b) { | |
var logTag = '.add'; | |
logt.debug(logTag, 'Adding', a, 'and', b); | |
var result = a + b; | |
logt.debug(logTag, 'Result:', result); | |
} |
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
<script src="https://cdn.jsdelivr.net/gh/sidhantpanda/logt/dist/logt.min.js"></script> | |
<script> | |
var LOG_TAG = 'sample tag'; | |
var logger = createLogger('error'); | |
logger.error(LOG_TAG, new Error('example error')); | |
</script> |
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 LogT from "logt"; | |
const LOG_TAG = "sample tag"; | |
const logger = new LogT("error"); | |
logger.error(LOG_TAG, new Error("example error")); |
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
interface IPartitionFunction<T> { | |
(element: T): boolean; | |
} | |
/** | |
* Partitions an array in to two arrays based on `isValid` function | |
* @param array Array to partition | |
* @param isValid Function to test each item against | |
*/ | |
const partition = <T>(array: T[], isValid: IPartitionFunction<T>): T[][] => { |
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
#!/bin/bash | |
[email protected]:sidhantpanda/express-typescript-boilerplate.git | |
read -p "Enter project name [express-typescript-boilerplate]: " project_name | |
if [ "$project_name" == "" ]; then | |
project_name="express-typescript-boilerplate" | |
fi | |
echo -e "Generating project $project_name!\n\n" | |
git clone $repoUrl $project_name |
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, { PropTypes } from 'react'; | |
import ReactDOM from 'react-dom'; | |
export default class PlyrComponent extends React.Component { | |
static propTypes = { | |
'options': PropTypes.object, | |
'youtubeKey': PropTypes.string, | |
} | |
componentDidMount() { |
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
// Assuming input is in form of [[1,2], [2,3], [10,0]] | |
// Came across this problem on the internet | |
// More at: https://blog.emilmoe.com/bowling-score-simulation/ | |
module.exports = { | |
/** | |
* Return a list of accumulated result for an input array of scores in different throws | |
* @param Array attempts the attempts in the game | |
* @returns {Array} Score after each round, cummulatively | |
*/ |