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 / 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,
}
@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 / 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 / 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 / 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 / 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 / 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 / color_brightness.php
Last active December 21, 2015 21:58
Color Brightness
<?php
function color_brightness($hex, $percent) {
// Work out if hash given
$hash = '';
if (stristr($hex,'#')) {
$hex = str_replace('#','',$hex);
$hash = '#';
}
@cointilt
cointilt / gist:5681163
Created May 30, 2013 20:55
Loop through slides and delay animation
// previous code condenced to make sense of code
this.slides = $('.slides');
// loop through each slide with a delay to slide in
_.each(this.slides, function (v, k) {
// slide in slide
$(this.slides[k]).delay(200 * k).animate({
top: '0px',
opacity: 1
}, 800);
@cointilt
cointilt / font_stacks
Created May 29, 2013 19:57
Font stacks based on system fonts
Font stacks based on system fonts
---------------------------------
Times New Roman stack
font-family: Cambria, "Hoefler Text", Utopia, "Liberation Serif", "Nimbus Roman No9 L Regular", Times, "Times New Roman", serif;
Georgia stack:
font-family: Constantia, "Lucida Bright", Lucidabright, "Lucida Serif", Lucida, "DejaVu Serif," "Bitstream Vera Serif", "Liberation Serif", Georgia, Palatino, Palatino Linotype, Times, Times New Roman, serif;
Garamond stack