Skip to content

Instantly share code, notes, and snippets.

View cointilt's full-sized avatar
🍣
West Coast Keto!

Will Ayers cointilt

🍣
West Coast Keto!
View GitHub Profile
@cointilt
cointilt / cssAnimationComplete.js
Created May 8, 2014 14:37
Detect Css Animation Completion
/* From Modernizr */
function whichTransitionEvent () {
var t,
el = document.createElement('fakeelement'),
transitions = {
'transition': 'transitionend',
'OTransition': 'oTransitionEnd',
'MozTransition': 'transitionend',
'WebkitTransition': 'webkitTransitionEnd'
};
@cointilt
cointilt / nsUnit.js
Created June 25, 2014 15:33
AngularJS Model
// Creating a fake model called Unit
(function (angular) {
'use strict';
// Unit Model Construtor
function Unit (futureUnitData) {
// Data is immediately available
if (! futureUnitData.inspect) {
// not sure if this is underscore, LoDash or something with angular
// need to research
@cointilt
cointilt / loadScript.js
Created July 25, 2014 16:42
Load Script
var s = document.createElement('script');
s.setAttribute('type', 'text/javascript');
s.setAttribute('src', 'script.js');
document.getElementsByTagName('body')[0].appendChild(s);
@cointilt
cointilt / app.js
Last active August 29, 2015 14:06
Define || Assign Angular Module
/**
* Assign or Create Angular Module
*
* The purpose of this is to first get the module if it exists, if not then create it
*/
// NO WORK
var myTestModule = angular.module('myTestModule') || angular.module('myTestModule', []);
// WORKS - with the registeredModules.js file
@cointilt
cointilt / watchers.js
Created October 7, 2014 16:45
Check For How Many Watchers in Angular App
(function () {
var root = $(document.getElementsByTagName('body'));
var watchers = [];
var f = function (element) {
if (element.data().hasOwnProperty('$scope')) {
angular.forEach(element.data().$scope.$$watchers, function (watcher) {
watchers.push(watcher);
});
}
@cointilt
cointilt / filterContains.html
Last active August 29, 2015 14:07
Angular Filter Contains
<div ng-app="myApp">
<ul ng-controller="myCtrl">
<li ng-repeat="item in items | contains:'id':showList">{{ item.title }}</li>
<!--
now instead of showing all items, it will only show list items with the id of 2 or 4 like below:
<li>two</li>
<li>four</li>
-->
</ul>
@cointilt
cointilt / StateProvides.js
Last active April 24, 2018 02:29
State Provider for Dumb Components
import React, { Component } from 'react'
import { bool, object } from 'prop-types'
class StateProvides extends Component {
state = {
state: {},
hydrated: false,
}