Skip to content

Instantly share code, notes, and snippets.

View allenhwkim's full-sized avatar

Allen Kim allenhwkim

View GitHub Profile
@allenhwkim
allenhwkim / auto-detect-changes.md
Last active May 4, 2020 19:42
Angular5+ Unit Tests

I do not want fixture.detectChanges() called automatically.

test

import { async, ComponentFixtureAutoDetect, TestBed } from '@angular/core/testing';

describe('NguiVirtualListComponent', () => {
  ...
  beforeEach(async(() => {
 TestBed.configureTestingModule({
@allenhwkim
allenhwkim / sublime3-settings.md
Last active December 4, 2019 07:17
Sublime3 For TypeScript/Vim/Terminal User Settings
@Daniel-Hug
Daniel-Hug / delegate-event.js
Last active September 14, 2020 05:05
Vanilla JS equivalent of jQuery's .live(): use event delegation to handle events whose target matches a selector, closest(): get nearest parent element matching selector
// get nearest parent element matching selector
var closest = (function() {
var el = HTMLElement.prototype;
var matches = el.matches || el.webkitMatchesSelector || el.mozMatchesSelector || el.msMatchesSelector;
return function closest(el, selector) {
return matches.call(el, selector) ? el : closest(el.parentElement, selector);
};
})();
@Couto
Couto / webpack.js
Last active November 11, 2020 17:53
Fetch polyfill with webpack
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var path = require('path');
var folders = {
APP: path.resolve(__dirname, '../app'),
BUILD: path.resolve(__dirname, '../build'),
BOWER: path.resolve(__dirname, '../bower_components'),
NPM: path.resolve(__dirname, '../node_modules')
};
@staltz
staltz / introrx.md
Last active April 25, 2024 04:18
The introduction to Reactive Programming you've been missing
@subudeepak
subudeepak / angular-loadscript-with-documentwrite.js
Last active May 5, 2020 03:16 — forked from endorama/angular-loadscript.js
Loading scripts on ngInclude (ng route) - Script loading directive
/**
* This module is a variant which supports document.write. If you need document.write use this instead
* Author: Deepak Subramanian @subudeepak(https://github.com/subudeepak)
* Distributed under MIT License
*/
/*global angular */
(function (ng) {
'use strict';
app.directive('script', function() {
return {
@mjackson
mjackson / color-conversion-algorithms.js
Last active April 14, 2024 08:46
RGB, HSV, and HSL color conversion algorithms in JavaScript
/**
* Converts an RGB color value to HSL. Conversion formula
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
* Assumes r, g, and b are contained in the set [0, 255] and
* returns h, s, and l in the set [0, 1].
*
* @param Number r The red color value
* @param Number g The green color value
* @param Number b The blue color value
* @return Array The HSL representation