Skip to content

Instantly share code, notes, and snippets.

View dylanjha's full-sized avatar

Dylan Jhaveri dylanjha

  • Mux
  • San Francisco
View GitHub Profile
@dylanjha
dylanjha / script.js
Created July 16, 2013 23:21
a little javascript flash message. see demo at: http://jsfiddle.net/dylanjha/kca9p/
<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>
</ul>
</div>
<div id='flash-container' class='flash-container'>
</div>
<div id='content'>
Here is some content.
@xaviershay
xaviershay / repro.rb
Created July 5, 2013 21:31
Unexpected behaviour defining Ruby classes anonymously.
true
repro.rb:16:in `block in <main>': uninitialized constant B (NameError)
from repro.rb:13:in `initialize'
from repro.rb:13:in `new'
from repro.rb:13:in `<main>'
@dylanjha
dylanjha / css3-mixins.css.scss
Last active December 19, 2015 09:49
A bunch of handy mixins for SASS. Who ever thought vendor prefixes were a good idea, anyway?
// 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
dylanjha / super.rb
Last active December 17, 2015 13:09
verifying how Ruby inheritance works
# 2.0.0dev :175 > @three = Three.new
# => #<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>
// 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.
;(function($){
$.fn.fontResize = function(options){
var spans = $('span:visible', this);
var heightMax = parseInt($(this).css('max-height'), 10),
#!/usr/bin/env ruby
require 'em-proxy'
TARGET = ARGV[0] ? ARGV[0].to_sym : :mysql
puts "Starting proxy on port 4000."
puts "Passing requests port 4100 (mysql) and port 4200 (postgres). Responses are returned from #{TARGET}."
Proxy.start(:host => "0.0.0.0", :port => 4000, :debug => true) do |conn|
@start = Time.now
@data = Hash.new("")
@bkeepers
bkeepers / usage.coffee
Last active June 25, 2021 14:57
Keep two HTML5 video elements in sync.
videos = document.getElementsByTagName('video')
new VideoSync(videos[0], videos[1])
@dylanjha
dylanjha / jquery-ui-tabs-1.9.2-patch.js
Created January 9, 2013 19:15
Patch for bug with jquery-ui-tabs api when <head> has a <base href> tag. http://bugs.jqueryui.com/ticket/4941 http://bugs.jqueryui.com/ticket/8637
//this is to patch a bug with the jquery.ui.tabs API
// http://bugs.jqueryui.com/ticket/4941
// http://bugs.jqueryui.com/ticket/8637
// 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() {
@robinsloan
robinsloan / langoliers.rb
Last active April 7, 2024 13:22
The Langoliers, a tweet deletion script
require "rubygems"
require "twitter"
require "json"
# things you must configure
TWITTER_USER = "your_username"
MAX_AGE_IN_DAYS = 1 # anything older than this is deleted
# get these from dev.twitter.com
CONSUMER_KEY = "your_consumer_key"
@kenkeiter
kenkeiter / text_extents.js
Created July 12, 2012 22:30
Resize text to fit a min/max.
;(function($){
$.fn.textExtents = function(options){
var spans = $('span:visible', this);
var heightMax = parseInt($(this).css('max-height'));
var widthMax = parseInt($(this).css('max-width'));
var fontSize = parseInt($(this).css('font-size')); /* max font size */
do{
var textHeight = 0;
var textWidth = 0;
$(spans).each(function(){