Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View dustinsmith1024's full-sized avatar
🏀
⛹️

Dustin Smith dustinsmith1024

🏀
⛹️
View GitHub Profile
@dustinsmith1024
dustinsmith1024 / gist:1538180
Created December 30, 2011 06:03
Radio Inputs in Django that don't have LABEL wraps
"""
1. Inherit from the normal RadioInput and copy the RadioInput __unicode__ method. Then change it up how you please:
"""
class RadioInputNoWrap(RadioInput):
def __unicode__(self):
if 'id' in self.attrs:
label_for = ' for="%s_%s"' % (self.attrs['id'], self.index)
else:
label_for = ''
choice_label = conditional_escape(force_unicode(self.choice_label))
@dustinsmith1024
dustinsmith1024 / gist:1538333
Created December 30, 2011 06:51
JQuery disabling buttons
//jQuery UI Button:
$("a.my-button" ).button({ disabled: true });
//Normal Button:
$("#button").attr("disabled",true);
@dustinsmith1024
dustinsmith1024 / gist:1686977
Created January 27, 2012 04:24
Installing Janus VIM on fresh Ubuntu
curl -Lo- http://bit.ly/janus-bootstrap | bash
#errored out...had to install git first, derrr
sudo apt-get install git
curl -Lo- http://bit.ly/janus-bootstrap | bash
# error! had to install rake next
sudo apt-get install rake
curl -Lo- http://bit.ly/janus-bootstrap | bash
@dustinsmith1024
dustinsmith1024 / heroku_commands.txt
Created February 17, 2012 01:19
Heroku Setups Custom Domains
Links:
http://devcenter.heroku.com/articles/custom-domains
http://joshkim.org/2010/03/15/custom-domain-names-on-heroku-via-namecheap/
Run the heroku commands to add custom domains
$ heroku addons:add custom_domains:basic
Adding custom_domains to myapp...done.
$ heroku domains:add www.example.com
@dustinsmith1024
dustinsmith1024 / bootstrap-fluid-grid-mixin.css
Last active December 12, 2015 08:09
A way to mixin fluid bootstrap grids
.fluid-row {
div, section, article, li { /* Needs testing on li's */
&:first-child { /* using first child and margin-left for IE support */
margin-left: 0;
}
}
}
.fluid-column(@columns: 1, @offset: 0, @reset: default) {
.input-block-level();
@dustinsmith1024
dustinsmith1024 / _component.html.haml
Created February 26, 2013 03:53
Style guiding example
%section.component{class: defined?(main_classes) && main_classes, id: defined?(id) && id}
%h1.component-header{class: defined?(header_classes) && header_classes, id: defined?(header_id) && header_id}= header
.component-content{class: defined?(content_classes) && content_classes, id: defined?(content_id) && content_id}
=body
@dustinsmith1024
dustinsmith1024 / routes.rb
Created May 17, 2013 18:08
A way to filter a route based on query params. You can also make the module a class and then initialize it to pass in whatever you want.
module QueryParamConstraint
extend self
def matches?(request)
request.query_parameters["view"] == request.path_parameters[:action]
end
end
MyPortal::Application.routes.draw do
$(document).on("page:change", function(){
window.prevPageYOffset = window.pageYOffset;
window.prevPageXOffset = window.pageXOffset;
});
//fix-scroll want needed for me
$(document).on("page:load", function(){
window.scrollTo(window.prevPageXOffset, window.prevPageYOffset);
});
@dustinsmith1024
dustinsmith1024 / index.html
Created July 26, 2013 11:53
sample ember app
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery.min.js"></script>
<link href="http://twitter.github.io/bootstrap/assets/css/bootstrap.css" rel="stylesheet" type="text/css" />
<link href="http://twitter.github.io/bootstrap/assets/css/bootstrap-responsive.css" rel="stylesheet" type="text/css" />
<script src="http://twitter.github.io/bootstrap/assets/js/bootstrap.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0-rc.3/handlebars.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/ember.js/1.0.0-rc.6/ember.min.js"></script>
<script src="http://builds.emberjs.com.s3.amazonaws.com/ember-data-latest.js"></script>
@dustinsmith1024
dustinsmith1024 / nba_players.rb
Created October 8, 2013 03:15
A capybara script for getting all the NBA teams and players.
#!/usr/bin/env ruby
require 'rubygems'
require 'capybara'
require 'capybara/dsl'
require 'capybara/poltergeist'
require 'json'
filename = ARGV[0] || false
if filename