Skip to content

Instantly share code, notes, and snippets.

Dylan Jhaveri dylanjha

Block or report user

Report or block dylanjha

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View jquery-ui-tabs-1.9.2-patch.js
//this is to patch a bug with the jquery.ui.tabs API
// it has to do with the <base href> tag in <head> and jquery.ui.tabs
// being smart about figuring out weather to AJAX a tab or not
;(function() {
var tabsInitialised = false;
var _tabs = $.fn.tabs;
var updateBaseHrefs = function() {
dylanjha / cheap-conditional.js
Last active Dec 16, 2015
cheap way to do a conditional in javascript. If the first part returns a falsy value, the second part doesn't execute
View cheap-conditional.js
o = {}
o.a = 1
o.a == 1 && console.log("o is one:", o.a)
o.a == 2 && console.log("false, this won't run")
o.b && console.log("undefined is falsy, this wont run")
//it's a little nicer than wrapping if{ } statements:
if(o.a == 1) { console.log("o is one:", o.a) }
View font-resize.js
// an element with class 'font_resize' with css properties:
// * max-height
// * max-width
// * font-size
// the element has children span elements, the font size inside these spans will re resized.
$.fn.fontResize = function(options){
var spans = $('span:visible', this);
var heightMax = parseInt($(this).css('max-height'), 10),
dylanjha / super.rb
Last active Dec 17, 2015
verifying how Ruby inheritance works
View super.rb
# 2.0.0dev :175 > @three =
# => #<Three:0x007fad66054540>
# 2.0.0dev :176 > @three.my_method
# im in class three
# im in the module
# im in class two
# im in class one
# @three.my_method_2
# <Three:0x108ca55e0>
dylanjha / session-token.rb
Created Jun 11, 2013
How easy it is to decode your Rails default session encoding.
View session-token.rb
1.9.3p392 :001 > session = "BAh7CEkiD3Nlc3Npb25faWQGOgZFRkkiJTVmMGI3OTEzOTMzYzdlMzUwMjAzZTliMDk1NzNlYjkzBjsAVEkiEF9jc3JmX3Rva2VuBjsARkkiMWQ3RktCWkFJN0ZnOEJ0T0FDRmF4VnhQcXZKdFVBTnYxaHZiRFY0b3FUY2c9BjsARkkiDHVzZXJfaWQGOwBGaQY%3D--d43bf61a0997f65b5c9c1492102bf4f40fabd5fd"
=> "BAh7CEkiD3Nlc3Npb25faWQGOgZFRkkiJTVmMGI3OTEzOTMzYzdlMzUwMjAzZTliMDk1NzNlYjkzBjsAVEkiEF9jc3JmX3Rva2VuBjsARkkiMWQ3RktCWkFJN0ZnOEJ0T0FDRmF4VnhQcXZKdFVBTnYxaHZiRFY0b3FUY2c9BjsARkkiDHVzZXJfaWQGOwBGaQY%3D--d43bf61a0997f65b5c9c1492102bf4f40fabd5fd"
1.9.3p392 :002 > Marshal.load(Base64.decode64(session.split("--").first)) =>
View array.remove.js
Array.prototype.remove = function(o){
var i = this.indexOf(o)
, v = this[i];
this.splice(i, 1);
return v;
dylanjha / css3-mixins.css.scss
Last active Dec 19, 2015
A bunch of handy mixins for SASS. Who ever thought vendor prefixes were a good idea, anyway?
View css3-mixins.css.scss
// Border Radius
@mixin round($radius: 4px) {
-moz-border-radius: $radius;
-webkit-border-radius: $radius;
border-radius: $radius;
// Box Shadow
@mixin shadow($shadow1: 0 0 4px #0A0A0A, $shadow2:false, $shadow3:false, $shadow4:false, $shadow5:false) {
$params: $shadow1;
@if $shadow2
dylanjha / script.js
Created Jul 16, 2013
a little javascript flash message. see demo at:
View script.js
<div id='nav'>
<ul class='nav-list'>
<li class='nav-item'><a href="javascript://">Home</a></li>
<li class='nav-item'><a href="javascript://">There</a></li>
<div id='flash-container' class='flash-container'>
<div id='content'>
Here is some content.
View .gitconfig
ui = true
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
dylanjha / apply.js
Created Aug 1, 2013
The Apply Invocation Pattern
View apply.js
myFn = function(msg){
return msg + this.status;
o = { status: "killing it" }
myFn.apply(o, ["Your status is: "])
//>> "Your status is: killing it"
You can’t perform that action at this time.