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
$('input.j-checkbox').each(function(){ | |
if ($(this).attr('checked')) { | |
$(this).next().trigger('click'); | |
} | |
}); | |
$('.j-selectbox').val('NO_RECEIVE'); |
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
class Business < ActiveRecord::Base | |
include SubuserExtender | |
# ... | |
end |
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
// Async | |
function giveOrderToChef(giveFoodToCustomer){ | |
var food = makeFood(); | |
giveFoodToCustomer(food); | |
} | |
function callbackFunction(food) { | |
goToKitchen(food); | |
grabFood(food); | |
bringFoodToCustomer(food) |
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
# Plugins | |
run-shell ~/Dev/opensource/tmux-resurrect/resurrect.tmux | |
run-shell ~/Dev/opensource/tmux-continuum/continuum.tmux | |
set -g @resurrect-strategy-vim 'session' | |
set -g @continuum-restore 'on' | |
setw -g mode-keys vi | |
bind -n C-k send-keys -R \; clear-history |
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 chain(fns) { | |
let c = {}; | |
let toEx = []; | |
for (let fn in fns) { | |
this[fn] = fns[fn]; | |
c.[fn] = function () { | |
toEx.push({ [fn]: arguments }); | |
} | |
} |
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 Node(data, next = null) { | |
// this.data = data; | |
// this.next = next; | |
// } | |
function map(head, fn) { | |
if (!head) return null; // Just return bad nodes | |
const mappedHead = new Node(fn(head.data)); | |
let lastMappedNode = mappedHead; |
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
// hashmap() | |
// 56 ms, faster than 87.12% | |
// 37.2 MB, less than 50.00% | |
function hashmap (nums) { | |
let existance = {}; | |
for (let i = 0; i < nums.length; i++) { | |
if (nums[i] in existance === false) | |
existance[nums[i]] = 1; | |
else | |
delete existance[nums[i]]; |
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
/** | |
* @param {string[]} sentences | |
* @param {number[]} times | |
*/ | |
var AutocompleteSystem = function(sentences, times) { | |
this.trie = { letters: {} }; | |
this.sentences = {}; | |
this.searchInput = ''; | |
sentences.forEach((sentence, sentenceIdx) => { |
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
var topKFrequent = function(words, k, frequency = {}) { | |
words.forEach(word => frequency[word] = frequency[word] + 1 || 1); | |
return Object.keys(frequency).sort((left, right) => { | |
const freqDiff = frequency[right] - frequency[left]; | |
return freqDiff === 0 ? left.localeCompare(right) : freqDiff; | |
}).slice(0, k); | |
}; |
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
var findAllConcatenatedWordsInADict = function(words) { | |
words.sort((a, b) => a.length - b.length); | |
let wordSet = new Set(); | |
words.forEach(word => { | |
// Use Trie | |
if (word) wordSet.add(word); | |
}); | |
// DFS |
OlderNewer