Skip to content

Instantly share code, notes, and snippets.

View michaelminter's full-sized avatar

Michael Minter michaelminter

View GitHub Profile
<a href="#" onclick="$('#more-info').toggle(); return false;">Show Details</a>
<div id="more-info" style="display:none;">This content will show when the link above is clicked.</div>
@michaelminter
michaelminter / JQuery Event Change based on select drop-down
Created May 9, 2011 00:15
JQuery Event Change based on select drop-down
var events = [];
events[0] = ["Display content notification box 1"];
events[1] = ["Display content notification box 2"];
events[2] = ["Display content notification box 3"];
function updateEventDescription(){
for(var i = 0; i < events.length; i++){
if($('#prospect_event option:selected').val() == events[i][0]){
$("#event_description").html(events[i][1]);
i = events.length;
@michaelminter
michaelminter / JQuery - Select at least one option to continue form.
Created May 9, 2011 00:18
JQuery - Select at least one option to continue form.
$(function(){
if($("body.0 form:first").submit(function() {
if (
$('#indian_answer0').is(':checked') == false &&
$('#asian_answer0').is(':checked') == false &&
$('#hispanic_answer0').is(':checked') == false &&
$('#black_answer0').is(':checked') == false &&
$('#white_answer0').is(':checked') == false &&
$('#hawaiian_answer0').is(':checked') == false
) {
@michaelminter
michaelminter / JQuery : Show or hide other page elements based on form selection
Created May 9, 2011 00:28
JQuery : Show or hide other page elements based on form selection
$(function(){
checkCollege();
$("#prospect_grad_before_2010").change(function(){
checkCollege();
});
});
function checkCollege(){
($("#prospect_grad_before_2010").val() == "yes") ? $(".field_row_college_after_hs:first").show() : $(".field_row_college_after_hs:first").hide();
}
@michaelminter
michaelminter / JQuery : take filename from file input and append to text input box
Created May 9, 2011 00:30
JQuery : take filename from file input and append to text input box
$("#site_file_file").change(function(){
file_name = $("#site_file_file").val().split("\\").pop().split(".");
file_name.pop();
$("#site_file_label").val(file_name);
$("#site_file_label").focus();
});
@michaelminter
michaelminter / Limit input box characters to defined Count
Created May 20, 2011 18:18
Limit input box characters to defined Count
$(document).ready(function(){
$('#myInput').keyup( function() {
var $this = $(this);
if($this.val().length > 20)
$this.val($this.val().substr(0, 20));
});
});
@michaelminter
michaelminter / ReadablePin
Created May 31, 2011 17:09
Return a random string of numbers and letters using only characters that read unique.
#! /usr/bin/ruby
class ReadablePin
def new( len = 8 )
pin = ''
chars = ("a".."z").to_a + ("0".."9").to_a
remove_each = ["i", "o"]
remove_each.each do |each|
@michaelminter
michaelminter / calc
Created June 15, 2011 13:51
Tinyized version of a scholarship calculator
<div id="schol_result">Please fill in your information and click CALCULATE</div>
<input type="text" id="act" />
<input type="text" id="gpa" />
<input type="submit" id="calculate-button" value="CALCULATE" />
<script type="text/javascript">
$(document).ready(function(){
$('#calculate-button').click(function() {
if (notEmpty($('#act')) && notEmpty($('#gpa'))) {
calc();
@michaelminter
michaelminter / Ruby date constants
Created July 2, 2011 18:08
Ruby: How to get day / month names from date
day = Date.today
Date.constants
>["MONTHS", "ABBR_DAYS", "DAYNAMES", "ENGLAND", "DATE_FORMATS", "PARSE_DAYPAT", "ABBR_MONTHNAMES", "ABBR_MONTHS", "ITALY", "PARSE_MONTHPAT", "MONTHNAMES", "GREGORIAN", "DAYS", "ZONES", "ABBR_DAYNAMES", "JULIAN"]
@michaelminter
michaelminter / GetFractal
Created July 27, 2011 15:03
Simple RESTful API for getfractal.com
class Email
.
.
.
def get_fractal
require 'net/http'
require 'uri'
api_key = 'yourAPIKey'
response = Net::HTTP.post_form(URI.parse('http://getfractal.com/api/v1/validate'), {'api_key'=>"#{api_key}", 'html'=>self.html.html_safe})