Skip to content

Instantly share code, notes, and snippets.

# Extension in my Rails lib dir
require 'lib/extensions/sass_widget_image_url'
# This configuration file works with both the Compass command line tool and within Rails.
project_type = :rails
# Require any additional compass plugins here.
require 'susy'
@jlong
jlong / jquery.preparetransition.js
Last active December 28, 2016 13:56
A new version of $(el).prepareTransition() that uses a timer instead of the poorly implemented TransitionEnd event to ensure that the 'is-transitioning' class is removed.
/**
* prepareTransition
*
* jQuery Plugin for ensuring transitions with display:none or visibility:hidden
* are in the right state until the end of the transition
*
* By John W. Long (http://wiseheartdesign.com)
* April 18, 2013
*
* Based on the prepareTransition plugin by Jonathan Snook (http://snook.ca). This version
@jlong
jlong / SassMeister-input.scss
Created January 14, 2014 15:53
Generated by SassMeister.com.
// ----
// Sass (v3.3.0.rc.2)
// Compass (v1.0.0.alpha.17)
// ----
$sections: red, gold, orange, grey;
@each $i in $sections {
.section-#{$i} {
@jlong
jlong / SassMeister-input.scss
Created February 1, 2014 22:53
Navigate a nested maps with map-fetch() in Sass
// ----
// Sass (v3.3.0.rc.2)
// Compass (v1.0.0.alpha.17)
// ----
//
// map-fetch($map, $keys)
//
// An easy way to fetch a deep value in a multi-level map. Works much like
// map-get() except that you pass multiple keys as the second parameter to
// Brightness math based on:
// http://www.nbdtech.com/Blog/archive/2008/04/27/Calculating-the-Perceived-Brightness-of-a-Color.aspx
$red-magic-number: 241;
$green-magic-number: 691;
$blue-magic-number: 68;
$brightness-divisor: $red-magic-number + $green-magic-number + $blue-magic-number;
@function brightness($color) {
// Extract color components
@jlong
jlong / SassMeister-input.scss
Created July 10, 2014 15:33
Generated by SassMeister.com.
// ----
// Sass (v3.3.9)
// Compass (v1.0.0.alpha.20)
// ----
/* Because of the http prefix on URL, Sass will interpret this as a regular
* CSS import directive. See output... */
@import "http://wiseheartdesign.com/stylesheets/blankslate.css";
@jlong
jlong / position.js
Last active July 18, 2022 11:03
Get the offset of an element relative to the viewport and take scrolling and borders into account
function getViewportOffset(element) {
var node = element
, left = node.offsetLeft
, top = node.offsetTop
;
node = node.parentNode;
do {
var styles = getComputedStyle(node);
DECLARE SUB EraseBackToGB (X AS INTEGER, Y AS INTEGER)
DECLARE SUB AddRoundAbout (X AS INTEGER, Y AS INTEGER, Dir AS STRING)
DECLARE SUB DoRoundAbouts ()
'The SMiLEY Game
'$DYNAMIC
DECLARE SUB AnimateLevWarp ()
DECLARE SUB AnimateSmiley ()
DECLARE SUB AddBouncer (X AS INTEGER, Y AS INTEGER, v AS INTEGER, Dir AS STRING)
DECLARE SUB AddCaterpillar (X AS STRING, Y AS STRING, Dir AS STRING)
DECLARE SUB AddCoin (X AS INTEGER, Y AS INTEGER)
' $DYNAMIC
DEFINT A-Z
DECLARE SUB GLoad (FileName AS STRING, GLoadArray() AS INTEGER)
DECLARE SUB GSave (x1 AS SINGLE, y1 AS SINGLE, x2 AS SINGLE, y2 AS SINGLE, FileName AS STRING)
DECLARE SUB DoWarHead ()
DECLARE SUB DrawWarHead (X AS INTEGER, Y AS INTEGER)
DECLARE SUB DoLasers ()
DECLARE SUB AddLaser (X AS INTEGER, Y AS INTEGER, Speed AS INTEGER, typ AS INTEGER, c AS INTEGER)
DECLARE SUB KillLaser (ID AS LONG)
DECLARE SUB PlayGame ()
angular.module('dom.util', [])
.service('inDom', function($document) {
return function inDom(element) {
var el = angular.element(element);
return $document[0].body.contains(el[0]);
};
})
.service('isVisible', function(inDom) {