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
export function debounce(func, wait, immediate) { | |
var timeout | |
return function () { | |
var context = this, | |
args = arguments | |
var later = function () { | |
timeout = null | |
if (!immediate) func.apply(context, args) | |
} | |
var callNow = immediate && !timeout |
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
def isValid(self, s): | |
""" | |
:type s: str | |
:rtype: bool | |
""" | |
if len(s) % 2 != 0: | |
return False | |
par_dict = {'(':')','{':'}','[':']'} | |
stack = [] |
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
const canJump = function(nums) { | |
let len = nums.length; | |
let max = 0; | |
for (let i = 0; i < len; i++) { | |
if (i > max) return false; | |
max = Math.max(max, i + nums[i]); | |
} | |
return true; | |
}; |
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
const isBalanced = function (input) { | |
let open = ['{', '[', '(']; | |
let close = ['}', ']', ')']; | |
let stack = []; | |
for (let i = 0; i < input.length; i++) { | |
if (open.indexOf(input[i]) >= 0) { | |
stack.push(input[i]); | |
} else { | |
if (close.indexOf(input[i]) !== open.indexOf(stack.pop())) { | |
return false; |
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
/* | |
Two Sum | |
Input: nums = [2,7,11,15], target = 9 | |
Output: [0,1] | |
Input: nums = [3,2,4], target = 6 | |
Output: [1,2] | |
Input: nums = [3,3], target = 6 | |
Output: [0,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
find ./node_modules/ -name package.json | xargs grep <package name> | |
# Example: find where bootstrap is being used. | |
# find ./node_modules/ -name package.json | xargs grep bootstrap |
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
<?php | |
/* | |
* APIData::get(string $name) : array | |
* | |
* v1/people - array(array(name, phoneNumber, address, occupation), ...) | |
* v1/jobs - array(array(occupation, salary, numberOfPeople), ...) | |
* v1/employers - array(array(businessName, address, goodOrService), ...) | |
* | |
* Given a $name, return an HTML table displaying the data the API call returns | |
* |
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
# !/usr/local/bin/python3 | |
""" | |
Back-up PHP web projects and not include the modules or vendor directories, will put back up in same DIR as script' | |
* need TAR installed on machine | |
To run: $ python3 backup_projects.py | |
""" | |
from datetime import datetime | |
from pathlib import Path |
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
/* | |
To Use: | |
:: Component A :: | |
import eventBus from "./EventBus"; | |
- Dispatch an Event to component B - | |
eventBus.dispatch("aResource", { resource: this.state.resource }); |
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
/* | |
There is a large pile of socks that must be paired by color. Given an array of integers representing the color of each sock, determine how many pairs of socks with matching colors there are. | |
Example | |
n = 7 | |
ar = [1,2,1,2,3,1,2] | |
There is one pair of color 1 and one of color 2. There are three odd socks left, one of each color. The number of pairs is 2. | |
Function Description |
NewerOlder