Skip to content

Instantly share code, notes, and snippets.

View icfantv's full-sized avatar

Adam Gordon icfantv

View GitHub Profile
@icfantv
icfantv / angular-material.css
Last active June 10, 2016 20:41
Bootstrap-ish Chips from Stripped-down Material
[tabindex='-1']:focus {
outline: none;
}
input[type="search"] {
-webkit-appearance: textfield;
box-sizing: content-box;
-webkit-box-sizing: content-box;
}
@icfantv
icfantv / service-module.js
Created May 29, 2016 21:48
Sample NG1 Service (ES5)
angular.module('services', [])
.service('MyService', ['$resource', MyService]);
function MyService($resource) {
var resource = $resource(...);
this.getAll() {
return resource.$get(...);
}
@icfantv
icfantv / FilterService.ts
Last active May 27, 2016 01:47
Subject Observer Example
import {Observer} from 'rxjs/Observer';
import {Subject} from 'rxjs/Subject';
export class FilterService {
private subject: Subject = new Subject();
private _name: string;
private _tags: CollectionMatcher = {
values: [],
allMustMatch: false
@icfantv
icfantv / AlphaNumComparator.ts
Created May 13, 2016 20:02
Alpha-Numeric comparator in TypeScript
export class StringUtils {
// shamelessly ripped from http://www.davekoelle.com/alphanum.html
/**
* Returns whether or not the specified value is a string.
* @param value the value to check for a string type.
* @returns {boolean} whether or not the specified value is a string.
*/
public static isString(value: any): boolean {
@icfantv
icfantv / alert.json
Last active May 9, 2016 19:48
NGBS API Layout
{
"inputs": [
{
"key": "close()",
"value": "A callback function that gets fired when an alert is closed. If the attribute exists, a close button is displayed as well."
}
],
"outputs": [
]
}
@icfantv
icfantv / OneServiceTest.spec.js
Last active May 4, 2016 16:09
Webpack, Karma, and You
import {IngredientService} from './IngredientService';
describe('test ingredient service', () => {
let service, _$httpBackend;
beforeEach(() => {
inject(($http, $httpBackend) => {
_$httpBackend = $httpBackend;
service = new IngredientService($http);
});
});
@icfantv
icfantv / resolveSnippet.js
Created April 22, 2016 18:40
Resolve Function
{
resolve: {
foo: ['$q', 'ModalService', 'MyService', ($q, ModalService, MyService) => {
return $q.resolve(ModalService.open()
.then(() => {
console.log('modal resolved');
return MyService.doSomething(someData);
})
.catch((error) => {
console.log('rejected');
@icfantv
icfantv / ScrollShadow.js
Created April 18, 2016 22:21
Angular Component
class ScrollShadowCtrl {
static get $inject() {
return ['$window', '$scope', '$elment'];
}
constructor($window, $scope, $element) {
this.$window = $window;
this.$element = $element;
@icfantv
icfantv / example.js
Created April 13, 2016 14:38
Preferred DI Structure
angular.module('app', [])
.controller('MyController', MyController);
function MyController($scope) {
}
MyController.$inject = ['$scope'];
@icfantv
icfantv / AlertService.es6
Last active March 31, 2016 19:20
Alert Service
import _remove from 'lodash/remove';
export class AlertService {
static get $inject() {
return ['$timeout', '$rootScope', 'UuidFactory'];
}
constructor($timeout, $rootScope, UuidFactory) {
this.$timeout = $timeout;
this.$rootScope = $rootScope;