Skip to content

Instantly share code, notes, and snippets.

View moimikey's full-sized avatar
:shipit:
ship it

Michael Scott Hertzberg moimikey

:shipit:
ship it
View GitHub Profile
Util.isElementInViewport = (el) ->
el = el[0] if el instanceof jQuery
return unless el?
rect = el.getBoundingClientRect()
rect.top >= 0 and
rect.left >= 0 and
rect.bottom <= (window.innerHeight or document.documentElement.clientHeight) and
rect.right <= (window.innerWidth or document.documentElement.clientWidth)
Util.isElementInViewOf = (el, parent) ->
el = el[0] if el instanceof jQuery
parent = parent[0] if parent instanceof jQuery
return unless el? and parent?
rect = el.getBoundingClientRect()
rect.top >= 0 and
rect.left >= 0 and
rect.bottom <= parent.clientHeight and
# absolute document height
Util.getDocumentHeight = ->
Math.max document.body.scrollHeight or 0,
document.documentElement.scrollHeight or 0,
document.body.offsetHeight or 0,
document.documentElement.offsetHeight or 0,
document.body.clientHeight or 0,
document.documentElement.clientHeight or 0
# Detect `y` scroll direction of mousewheel event
Util.scrollDirection = (evt) ->
if evt.detail < 0 or evt.wheelDelta > 0 then 'up' else 'down'
@moimikey
moimikey / app.js
Created November 8, 2014 19:34
quick and easy es6 in the browser
import $ from 'jquery';
export class Zomg {
constructor() {
console.log('es6!', $('body'));
}
}
new Zomg
@moimikey
moimikey / coolbeans
Created December 2, 2014 21:25
coolbeans
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !(wp-content|wp-admin) [NC]
RewriteRule ^(.*/\d{4})/\d{2}/\d{2}(.*)$ /$1$2 [R=301,L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

Keybase proof

I hereby claim:

  • I am moimikey on github.
  • I am moimikey (https://keybase.io/moimikey) on keybase.
  • I have a public key whose fingerprint is 1AD5 03A4 5B61 7D24 92F9 C20A E6F5 36D1 51B6 701F

To claim this, I am signing this object:

❯ npm s /\^strip- htdocs/git/master
NAME DESCRIPTION AUTHOR DATE VERSION
strip-ansi Strip ANSI escape codes =sindresorhus… 2015-01-16 2.0.1
strip-attributes Strip attributes from HTML tags. =jonschlinkert 2014-10-16 0.1.0
strip-banner Strip banners from code. =jonschlinkert 2014-02-13 0.1.1
strip-bom Strip UTF-8 byte order mark (BOM) from a… =sindresorhus 2014-08-22 1.0.0
strip-bomify browserify transform to remove UTF-8 byte order mark from… =michailsmith 2014-10-23 0.1.0
strip-coffee-comments Strip comments from CoffeScript. Remove both line comments… =jonschlinkert 2014-07-10 0.1.1
strip-combining-marks Easily remove Unicode combining marks from strings. =mathias
@moimikey
moimikey / gist:76584ce3bf0d7de36f53
Created February 11, 2015 16:07
auto `nvm use` for `zsh`
function chpwd() {
emulate -L zsh
[ -f .nvmrc ] && nvm use
}
@moimikey
moimikey / react-cursive-timer.jsx
Created March 18, 2015 04:34
React recursive timer animation
'use strict';
var React = require('react');
var Switch = React.createClass({
getInitialState: function() {
return {
switch: true
}
},