Skip to content

Instantly share code, notes, and snippets.

Avatar
😀

Tyler Harms harmstyler

😀
View GitHub Profile
View moving_from_jquery.md

Moving from jQuery

Events

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

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:

View div-fill-viewport.md

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 Dec 30, 2015
Compares two arrays and returns boolean value. Coffeescript and Javascript versions provided
View gist:7896595
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 Dec 30, 2015
Command One Liners
View one-liners.md
@harmstyler
harmstyler / statics.py
Created Nov 14, 2013
django 1.5 Project and Base Directory variables
View statics.py
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 Nov 8, 2013
Code taken from comment by @gregjopa on how to add affix events to bootstrap.
View affixEvents.js
$alert.on('unaffixed.bs.affix', function () {
// ... Code Here
});
$alert.on('affixed.bs.affix', function () {
// ... Code Here
});
@harmstyler
harmstyler / accessibleDropdown.coffee
Created Aug 2, 2013
Keyboard accessible dropdown menu.
View accessibleDropdown.coffee
$.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");
View enablescrollmenu.coffee
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 Jun 26, 2013
Simple hack to give more caret options to bootstrap's caret class
View caret.scss
/* ***** 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;