Skip to content

Instantly share code, notes, and snippets.

@bcalloway
bcalloway / Google Map API - kml.js
Created February 23, 2009 15:30
Google Map API - toggle layer
<div id="map"></div>
<div id="controls">
<p class="legend"><strong>Toggle a Checkbox to Show Map Points</strong></p>
<ul>
<li><input type="checkbox" id="layer1" onClick="boxclick(this, layer1);"/><label> Layer 1 </label></li>
<li><input type="checkbox" id="layer2" onClick="boxclick(this, layer2);"/><label> Layer 2 </label></li>
<li><input type="checkbox" id="layer3" onClick="boxclick(this, layer3);"/><label> Layer 3</a></label></li>
@bcalloway
bcalloway / Google Map API - map.js
Created February 23, 2009 15:31
Google Map API
<div id="map"></div>
<script type="text/javascript">
// Create a base icon
var baseIcon = new GIcon();
baseIcon.image = "images/red_marker.png";
baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
baseIcon.iconSize = new GSize(20, 34);
baseIcon.shadowSize = new GSize(37, 34);
baseIcon.iconAnchor = new GPoint(9, 34);
@bcalloway
bcalloway / jQuery form validate.js
Created February 23, 2009 15:37
jQuery form validation
//contact-form validation
$("form#contact-form").validate({
errorPlacement: function(error, element) {
//appends error message to the p tag of the form field
error.appendTo( element.parent("p") );
}
});
@bcalloway
bcalloway / jQuery hover.js
Created February 23, 2009 15:38
jQuery hover class
$('#main-nav ul li').each(function() {
$(this).hover(function() {
$(this).addClass('nav-on');
}, function() {
$(this).removeClass('nav-on');
});
});
@bcalloway
bcalloway / jQuery rollover.js
Created February 23, 2009 15:38
jQuery rollover image nav
$(document).ready(function() {
// Preload all rollovers
$("#tabs img").each(function() {
// Set the original src
rollsrc = $(this).attr("src");
rollON = rollsrc.replace(/.jpg$/ig,"2.jpg");
$("<img>").attr("src", rollON);
});
// Navigation rollovers
@bcalloway
bcalloway / us-states-rails-migration.rb
Created February 23, 2009 15:39
MySQL for US States table
class CreateStates < ActiveRecord::Migration
def self.up
create_table :states do |t|
t.string :name
t.string :abbreviation
end
State.create :name => 'Alabama', :abbreviation => 'AL'
State.create :name => 'Alaska', :abbreviation => 'AK'
State.create :name => 'Arizona', :abbreviation => 'AZ'
@bcalloway
bcalloway / ruby1.9.sh
Created February 23, 2009 15:40
Ruby 1.9 install alongside 1.8
#!/bin/sh
mkdir -p /usr/local/src && cd /usr/local/src
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p0.tar.bz2
tar -xjvf ruby-1.9.1-p0.tar.bz2
cd ruby-1.9.1-p0
./configure --prefix=/usr --program-suffix=19 --enable-shared
make && make install
@bcalloway
bcalloway / sifr.js
Created February 23, 2009 15:40
sIFR embed code
<script type="text/javascript" charset="utf-8">
if(typeof sIFR == "function"){
sIFR.replaceElement(named({sSelector:"h1", sFlashSrc:"<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/swf/sifr.swf", sColor:"#404e1c", sWmode:"transparent"}));
sIFR.replaceElement(named({sSelector:"h2.contentheading, #content h2, #content h3", sFlashSrc:"<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/swf/sifr.swf", sColor:"#404e1c", sWmode:"transparent"}));
};
</script>
@bcalloway
bcalloway / swfobject-embed.js
Created February 23, 2009 15:41
swfobject embed code
var flashvars = {};
var params = {
menu: "false",
wmode: "transparent"
};
var attributes = {};
swfobject.embedSWF("swf/slideshow.swf", "flash-header", "1000", "317","9.0.0", "", flashvars, params, attributes);
@bcalloway
bcalloway / git-color.sh
Created February 23, 2009 15:51
Git color coding
git config --global color.status auto
git config --global color.diff auto git config --global color.diff auto
git config --global color.branch auto