Skip to content

Instantly share code, notes, and snippets.

View harmstyler's full-sized avatar

Tyler Harms harmstyler

View GitHub Profile

Moving from jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})

Keybase proof

I hereby claim:

  • I am harmstyler on github.
  • I am harmstyler (https://keybase.io/harmstyler) on keybase.
  • I have a public key ASAHu5vyMaraw8XhU-rFa8YOZMvsUMAbSkQsTwsi0gbtJQo

To claim this, I am signing this object:

Div full Width/Height of viewport with jQuery

This handy piece of code allows you to create a full width/height div according to the viewport. The code also handles window resizing. Great for modal dialogs or popups.

// global vars
var winWidth = $(window).width();
var winHeight = $(window).height();

// set initial div height / width
$('div').css({
@harmstyler
harmstyler / gist:7896595
Last active December 30, 2015 22:49
Compares two arrays and returns boolean value. Coffeescript and Javascript versions provided
Array::equals = (array) ->
return false unless array
return false unless @length is array.length
i = 0
while i < @length
if this[i] instanceof Array and array[i] instanceof Array
# Check and recurse into the nested arrays
return false unless this[i].equals(array[i])
else if this[i] instanceof Object and array[i] instanceof Object
# Stringify objects for comparison
@harmstyler
harmstyler / one-liners.md
Last active December 30, 2015 06:29
Command One Liners
@harmstyler
harmstyler / statics.py
Created November 14, 2013 18:37
django 1.5 Project and Base Directory variables
import os
PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
BASE_DIR = os.path.abspath(os.path.join(PROJECT_DIR, '../../'))
# URL prefix for static files.
# Example: "http://example.com/static/", "http://static.example.com/"
STATIC_URL = '/static/'
# Additional locations of static files
@harmstyler
harmstyler / affixEvents.js
Created November 8, 2013 15:16
Code taken from comment by @gregjopa on how to add affix events to bootstrap.
$alert.on('unaffixed.bs.affix', function () {
// ... Code Here
});
$alert.on('affixed.bs.affix', function () {
// ... Code Here
});
@harmstyler
harmstyler / accessibleDropdown.coffee
Created August 2, 2013 16:13
Keyboard accessible dropdown menu.
$.fn.accessibleDropDown = ->
el = $(this);
enter = -> $(this).addClass('hover')
leave = -> $(this).removeClass('hover')
# Hover dropdown
$("li", el).hoverIntent(enter,leave)
# Make dropdown menus keyboard accessible
$("a", el).focus( ->
$(this).parents("li").addClass("hover");
enableScrollMenu = ->
$(".bottomscrollbar").hover (->
$this = $(this)
windowHeight = $this.prev().children().length * $this.prev().children().height()
$this.prev().animate(
scrollTop:windowHeight
,600)
), ->
# stop on unhover
$(this).prev().stop()
@harmstyler
harmstyler / caret.scss
Created June 26, 2013 19:02
Simple hack to give more caret options to bootstrap's caret class
/* ***** Carets and other CSS icons ***** */
.caret {
&.up {
border-bottom: 4px solid #000000;
border-top: none;
}
&.left {
border-top: 4px solid transparent;
border-right: 5px solid #000000;
border-bottom: 4px solid transparent;