Skip to content

Instantly share code, notes, and snippets.

View xingmarc's full-sized avatar
💭
✨🦄️🌟🦄️✨

我可以回答你一句无可奉告 xingmarc

💭
✨🦄️🌟🦄️✨
View GitHub Profile
@xingmarc
xingmarc / findCoinCombination.js
Created March 27, 2017 06:21
Find all coin combinations
// find all combination of coins up to an amount of money.
function findCoinCombination(money, coins) {
var solution = Arrays.from(coins, function() {
return 0;
})
function helper(moneyLeft, level, solution) {
if (level == solution.length - 1) {
solution[level] = moneyLeft;
console.log(solution)
return;
@xingmarc
xingmarc / how-webpack-create-final-asset.js
Created March 27, 2017 04:52
How Webpack create final asset
// iife
(function(moduleArray) {
var cache = {};
function webpackRequire(index) {
if (cache[index]) {
return cache[index];
}
var module = { exports: {} };
var file = moduleArray[index];
@xingmarc
xingmarc / debounce.js
Last active March 27, 2017 01:11
A simple debounce function
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)
}
@xingmarc
xingmarc / typeahead.html
Created March 20, 2017 06:40
input typeahead simple example.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>A Type Ahead Example</title>
</head>
<body>
<!-- The Trick here is to use two overlapping <input>, one for the hint, one for the actual input -->
<div style="position: relative;">
<input