Skip to content

Instantly share code, notes, and snippets.

View kayhadrin's full-sized avatar

David kayhadrin

  • AU-US in betweener
View GitHub Profile
@kayhadrin
kayhadrin / jquery-trackScroll.js
Created December 1, 2015 08:52
jQuery plugin to raise custom scroll_vertical and scroll_horizontal events
/**
* Simple plugin to track scroll events and trigger a custom jQuery event (scroll_vertical or scroll_horizontal)
* when the corresponding type of scroll has happened.
* Event handlers can receive the original scroll event and the scroll delta as second values.
* e.g. function(jqEvent, scrollEvent, delta)
*
* To stop this, unbind the 'scroll.trackScroll.vertical' or 'scroll.trackScroll.horizontal' event
* @param {string} direction Scroll direction to track
* @return {jQuery}
*/
@kayhadrin
kayhadrin / .bashrc
Last active October 9, 2015 00:11
bash config
# Git aliases
alias g="git"
alias gits="git status"
alias gitc="git commit"
alias gitb="git branch"
alias gs='git status'
alias gc='git commit'
alias gb='git branch'
alias gbr='git branch -r'
alias gf='git fetch && git fetch --tags'
@kayhadrin
kayhadrin / index.html
Created November 12, 2014 23:22
A Pen by David.
<div>
<span>
<a class="menu-item">Home</a>
</span>
<span>
<a class="menu-item">Contact</a>
</span>
</div>
@kayhadrin
kayhadrin / Dynamic-column-width-with-css-calc().markdown
Last active August 29, 2015 14:08
Dynamic column width with css calc()

Dynamic column width with css calc()

The general formula of the column width for a known separator width is columnWidth = ( fullWidth + separatorWidth * (1 - columnNb) ) / columnNb

A Pen by David on CodePen.

@kayhadrin
kayhadrin / index.js
Created January 4, 2014 00:33
requirebin sketch
var MemDB = require('memdb');
var db = MemDB();
console.log('memdb db = ', db);
@kayhadrin
kayhadrin / index.html
Created July 21, 2013 04:34
A CodePen by David. Custom Rivets binder for jQuery plugins - Example of how to write a custom rivet binder for jQuery plugins that report changes with custom events.
<!-- JS Includes -->
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.4/underscore-min.js" type="text/javascript"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/backbone.js/1.0.0/backbone.js" type="text/javascript"></script>
<script src="https://rawgithub.com/mikeric/rivets/master/dist/rivets.js" type="text/javascript"></script>
<script src="https://rawgithub.com/azproduction/rivets-backbone-adapter/master/rivets-backbone.js" type="text/javascript"></script>
<p style="color: red;">
Open your dev tools and watch the console log for output. You should notice that when setting the value manually using the Backbone set(), the "routine" is fired off twice.
</p>