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() { | |
var replaceArry = [ | |
[/replaceme/gi, 'newtext'], | |
]; | |
function replace_text() { | |
var numTerms = replaceArry.length; | |
var txtWalker = document.createTreeWalker( | |
document.body, | |
NodeFilter.SHOW_TEXT, { |
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
# https://www.facebookrecruiting.com/portal/coding_puzzles/?puzzle=348371419980095 | |
from typing import List | |
# Write any import statements here | |
def getMinProblemCount(N: int, S: List[int]) -> int: | |
# Write your code here | |
is_even = lambda x: True if x % 2 == 0 else 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
# https://leetcode.com/problems/minimum-distance-to-type-a-word-using-two-fingers/ | |
from string import ascii_uppercase | |
class Solution: | |
def __init__(self): | |
anchor = ord('A') | |
self.keyboard = {c: ((ord(c) - anchor) // 6, (ord(c) - anchor) % 6) for c in ascii_uppercase} | |
self.memo = {} |
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
class Solution: | |
def addOperators(self, num, target): | |
length = len(num) | |
ret = [] | |
def rdfs(curr_index, curr_calculate, curr_expr): | |
if curr_index >= length: | |
if curr_calculate == target: | |
ret.append(curr_expr) |
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
syntax enable | |
"line numbers | |
set number | |
set relativenumber | |
augroup numbertoggle | |
autocmd! | |
autocmd BufEnter,FocusGained,InsertLeave * set relativenumber | |
autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber | |
augroup END |
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
#!/bin/bash | |
db_set() {echo "$1,$2" >> database} | |
db_get() {grep "^$1," database | sed -e "s/^$1,//" | tail -n 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
export ZPLUG_HOME=$HOME/.zplug | |
local zplug_init=$ZPLUG_HOME/init.zsh | |
if [ ! -f "$zplug_init" ] &> /dev/null; then | |
curl -sL --proto-redir -all,https https://raw.githubusercontent.com/zplug/installer/master/installer.zsh| zsh | |
fi | |
source $zplug_init | |
zplug 'zplug/zplug', hook-build:'zplug --self-manage' | |
zplug "robbyrussell/oh-my-zsh", use:"lib/{clipboard,completion,directories,history,termsupport,key-bindings}.zsh" | |
zplug "plugins/zsh_reload", from:oh-my-zsh |
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
# coding=utf-8 | |
import random | |
import math | |
def max_heapify(A, index): | |
left_index = index * 2 | |
right_index = left_index + 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
import sys | |
import math | |
def make_words(document): | |
return document.split() | |
def make_frequency(document): | |
frequency = {} | |
for w in make_words(document): | |
if w in frequency: |
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 createTrie = require('autosuggest-trie'); | |
const sizeOf = require('object-sizeof'); | |
// sample data | |
const locations = [ | |
{ | |
id: 1, | |
name: 'East Richmond 1234 VIC', | |
population: 10000 | |
}, |
NewerOlder