Skip to content

Instantly share code, notes, and snippets.

# rails application template for generating customized rails apps
#
# == requires ==
#
# * rails 2.3+, rspec, cucumber, culerity (langalex-culerity gem), machinist
#
# == a newly generated app using this template comes with ==
#
# * working user registration/login via authlogic, cucumber features to verify that it works
# * rspec/cucumber/culerity for testing
@brandonjp
brandonjp / dabblet.css
Created December 16, 2011 16:09 — forked from LeaVerou/dabblet.css
Previewer test
/**
* Previewer test
*/
background: #f06;
background: linear-gradient(left bottom,
hsla(340, 100%, 50%,.7), yellow);
min-width: 100px;
width: 2in;
transition-duration: 6s;
@brandonjp
brandonjp / barleyBarHider.js
Created August 21, 2013 18:01
hides the Barley editor until ESC (or whatever key you choose) is pressed 3 times in a sec
function barleyBarHider(keyCode) { // need the keyCode? try whatthekeycode.com
var bb = jQuery('#barley-bar').children('#barley-logo').slideUp().end().hide();
var pressCount = 0;
var keyCode = typeof keyCode==="number" && ~~keyCode>0 ? ~~keyCode : 27; // use ESC key if error or NaN
jQuery(document).keyup(function(e) {
if (e.keyCode == keyCode) {
pressCount++;
if (pressCount==3) bb.show().children('#barley-logo').slideDown();
setTimeout(function(){pressCount=0},1000);
}
@brandonjp
brandonjp / gist:8342770
Created January 9, 2014 21:54
waaay too many additional Modernizr tests for convenience and adding classes to root `<html>` element based on browser/os names and versions, etc.
// Modernizr additional tests for device, user agent, etc.
Modernizr.addTest('ie',function(){return!!navigator.userAgent.match(/MSIE/i)});
Modernizr.addTest('ios',function(){return/iP(ad|hone|od)/i.test(navigator.userAgent)});
Modernizr.addTest('mobile',function(){return!!navigator.userAgent.match(/android.+mobile|avantgo|bada\/|MeeGo|NokiaN9|blackberry|BlackBerry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|Kindle|Kindle Fire|silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|pad|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fl
@brandonjp
brandonjp / 15 min interval time array
Created March 3, 2014 21:31
15 min interval time array
$scope.timeList = [
"12:00 AM",
"12:15 AM",
"12:30 AM",
"12:45 AM",
"1:00 AM",
"1:15 AM",
"1:30 AM",
"1:45 AM",
"2:00 AM",
@brandonjp
brandonjp / jquery.prevOrAunt.js
Created December 18, 2014 23:31
jQuery prevOrAunt() - select previous siblings or parent previous siblings
// find first matching prev sibling of this or of parents, within 3 levels up
$form.prevOrAunt('.form-title,.panel-title,.panel-heading,:header', 3);
(function($) {
$.fn.prevOrAunt = function(search, optionalLimit) {
// prevOrAunt(search,optionalLimit) - searches only prev and aunts [Note: aunt=parent.prev, uncle=parent.next]
// search for matches in priority: prev siblings, parent prev siblings (repeat)
// with optional number limit for how far up the tree to search (or false to disable limit)
// * Modified from @Loren - http://stackoverflow.com/a/26237214/264601
@brandonjp
brandonjp / jquery.prevParentPrev.js
Created December 18, 2014 23:33
jQuery prevParentPrev() - matches previous siblings, parent, parent prev (repeat)
// find first matching prev sibling, parent, or parent prev sibling, within 3 levels up
$form.prevParentPrev('.form-title,.panel-title,.panel-heading,:header')
(function($) {
$.fn.prevParentPrev = function(search, optionalLimit) {
// prevParentPrev(search,optionalLimit) - similar to prevOrAunt() but also searches parents
// search for matches in priority: prev siblings, parent, parent prev siblings (repeat)
// with optional number limit for how far up the tree to search (or false to disable limit)
// * Modified from @Loren - http://stackoverflow.com/a/26237214/264601
@brandonjp
brandonjp / jquery.thisOrNothin.firstOrNothin.js
Created December 19, 2014 00:22
jQuery thisOrNothin() firstOrNothin() - get a real NULL if nothing matches, current stack is empty or elem.length is zero 0
(function($) {
$.fn.thisOrNothin = $.fn.thisOrNothing = function(search) {
// thisOrNothing(search) - gives back what you gave it, unless it's empty
// use the optional search to filter by selectors
// EX: $('div').thisOrNothing('.hidden')
// *Note: Don't you go chainin' this now... if it's NULL it'll blow
// First attempt to filter
var filtered = search ? this.filter(search) : this;
@brandonjp
brandonjp / insert_snippet.sh
Last active March 10, 2021 19:00
bash script for Alfred workflow to create a new snippet
#!/bin/bash
# set qry to the query (argument one)
qry="$1"
# fix SNIP_DB location in case it contains tilde (won't expand in quotes)
SNIP_DB=$( echo $SNIP_DB | sed "s:^~:$HOME:" )
# set the internal delimeter (idlm) to some char(s) that will never be used
idlm=''
@brandonjp
brandonjp / findOverflowParents.js
Last active July 14, 2024 09:59
find overflow:hidden ancestors
// when you're trying to use `position:sticky` on an element
// you'll have trouble if any parent/ancestor element has
// overflow set to anything other than "visible" (such as: auto,hidden,overlay,scroll)
// & turns out if a parent is `display:flex` it might need some love
// (to remedy this you can set the `align-self` of your sticky element)
// see here for how the display & align-self properties affect: http://bit.ly/2ZaRu4o
// so, to find those troublesome parents...
// copy & paste this into Chrome Inspector/Dev Tools console
// (and be sure to change the #stickyElement below, if needed)