Skip to content

Instantly share code, notes, and snippets.

View jlong's full-sized avatar
🚀

John W. Long jlong

🚀
View GitHub Profile
@jlong
jlong / reset.css
Created January 21, 2019 21:12
Modified Meyer Reset with Universal Selector
View reset.css
// Modified Meyer reset
// Universal selector works great!
// See: http://blogs.telerik.com/kendoui/posts/12-09-28/css_tip_star_selector_not_that_bad
*, *::before, *::after {
margin: 0;
padding: 0;
border: 0;
border-collapse: collapse;
border-spacing: 0;
@jlong
jlong / micro-reset.scss
Created May 17, 2017 16:14
Micro CSS reset
View micro-reset.scss
// micro-reset.scss
//
// Based on the Meyer reset
// Universal selector works great!
// See: http://blogs.telerik.com/kendoui/posts/12-09-28/css_tip_star_selector_not_that_bad
*, *::before, *::after {
margin: 0;
padding: 0;
border: 0;
@jlong
jlong / apiV2.rb
Last active April 27, 2016 16:48
Using the UserVoice API v2 with a trusted client
View apiV2.rb
require 'net/http'
require 'json'
# For now you must use a trusted API client, never place your API credentials
# for a trusted client in an insecure location. Especially not in JavaScript on
# the client side.
client_key = "YOUR_API_CLIENT_KEY"
client_secret = "YOUR_API_CLIENT_SECRET"
host = "YOUR_SUBDOMAIN.uservoice.com"
View angular.visibility.js
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) {
View stealth.bas
' $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 ()
View smiley.bas
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)
@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
View position.js
function getViewportOffset(element) {
var node = element
, left = node.offsetLeft
, top = node.offsetTop
;
node = node.parentNode;
do {
var styles = getComputedStyle(node);
@jlong
jlong / SassMeister-input.scss
Created July 10, 2014 15:33
Generated by SassMeister.com.
View SassMeister-input.scss
// ----
// 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";
View _brightness.scss
// 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 February 1, 2014 22:53
Navigate a nested maps with map-fetch() in Sass
View SassMeister-input.scss
// ----
// 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