Skip to content

Instantly share code, notes, and snippets.

View stefbowerman's full-sized avatar

Stefan Bowerman stefbowerman

View GitHub Profile
@stefbowerman
stefbowerman / AnalyticsEvent.coffee
Last active January 2, 2016 03:29
Wrapper object for analytics tracking. Pass in a hash of tracking params (category, action, label, etc) and the constructor takes care of the rest.
## Requires _gaq
## TRACKING DOM ELEMENT CLICK EVENTS ##
##-----------------------------------------##
## To be tracked, a dom element must have a few data- attributes
## data-trackable !Required for element to be tracked - set it to "true" or something, doesn't matter, just needs to exist
## data-event-category !Required - String
## data-event-action !Required - String
@stefbowerman
stefbowerman / PopupWindow.coffee
Created January 3, 2014 18:54
Coffeescript class for creating a popup window in the center of the screen.
# Requires jQuery
class @PopupWindow
attributes =
title : "Popup Window Title"
windowHeight : 600
windowWidth : 600
openOnCreate : true
@stefbowerman
stefbowerman / BalancedString.coffee
Last active January 2, 2016 10:09
Prototype method to check if a string is balanced in terms of opening and closing parentheses.
String.prototype.isBalanced = ->
parens = this.match( /[()]/g )
return false unless parens?
openStarted = false
closureBalance = 0
for i in [0...parens.length] by 1
char = parens[i]
if openStarted
if char == "(" then closureBalance++ else closureBalance--
else
@stefbowerman
stefbowerman / MaxLength.coffee
Created January 7, 2014 18:28
Event handler for typing into inputs and textareas with a 'maxlength' attribute. Enforces a character limit on the frontend and displays a character count when approaching the maximum.
$ ->
# Binds to all inputs with a 'maxlength' attribute
# Enforces the limit and will update & hide/show an element to the user to tell them how close they are the to the limit
# the maxlength attribute is valid in HTML5 but not supported in all browsers
# Eg. <span id="my-display" class="char-count-display"></span> <input type="text" maxlength="20" data-count-display="my-display" />
ignore = [8,9,13,33,34,35,36,37,38,39,40,46]
eventName = 'keyup'
$white : #FFF;
$grayLight : #CCC;
$baseBorderRadius : 3px;
$baseZIndex : 50;
@mixin border-radius($radius) {
-webkit-border-radius: $radius;
-moz-border-radius: $radius;
border-radius: $radius;
}
@stefbowerman
stefbowerman / Preferences.sublime-settings
Created January 20, 2014 17:52
Sublime Text Editor Settings
{
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
"font_face": "Fira Mono OT",
"font_size": 14.0,
"ignored_packages":
[
"Vintage"
],
"line_padding_bottom": 2,
"line_padding_top": 2,
@stefbowerman
stefbowerman / myPlaySubscribe.php
Last active January 4, 2016 20:29
MyPlay Mailing List Subscribe
<?php
$url = "https://subs.myplay.com/app/ly/signup";
$fields = array(
'email' => urlencode('user@email.com'),
'country' => urlencode('US'),
'list' => urlencode('ln_musicbox_newsletter'),
'lists_on_form' => urlencode('ln_musicvox_newsletter'),
'confirm' => urlencode('Y'),
@stefbowerman
stefbowerman / cursorTrail.js
Created January 29, 2014 18:59
MySpace Cursor Trail. Used originally to trail a balloon looking cursor with 3 different sized bubble images.
function randomFromInterval(from,to)
{
return Math.floor(Math.random()*(to-from+1)+from);
}
function cursorTrail(e){
var i = randomFromInterval(1, 3),
fadeOutTime = randomFromInterval(100, 200),
top = e.pageY - randomFromInterval(15, 20),
left = e.pageX- randomFromInterval(15, 20),
@stefbowerman
stefbowerman / candy-stripe.scss
Last active August 29, 2015 13:56
Candy stripe text shadow. Looks cool if the font color is the same as the background color.
$color1: #FFF;
$color2: #F00; // Red
.candy-stripe {
color: $color1;
text-shadow:
1px 1px 1px $color2,
2px 2px 1px $color1,
3px 3px 1px $color2,
4px 4px 1px $color1;
@stefbowerman
stefbowerman / gist:9130315
Created February 21, 2014 07:45
Text effect. Makes text look like ink splashed with water.
.fuzz-text {
color: #333;
color: rgba(0, 0, 0, 0.6);
text-shadow: 0 0 1px #797979;
}