Skip to content

Instantly share code, notes, and snippets.

View nicinabox's full-sized avatar

Nic Haynes nicinabox

View GitHub Profile
$('form').submit(function() {
// get all the inputs into an array.
var $inputs = $('#form :input');
// get an associative array of just the values.
var values = {};
$inputs.each(function() {
values[this.name] = $(this).val();
if ($(this).val() == "") {
alert("You haven't filled out all the fields");
users = []
xml.search('//dc:creator').each do |user|
unless users.include?(user)
users << user.inner_text
end
end
@nicinabox
nicinabox / gist:955514
Created May 4, 2011 16:24
Padrino Rakefile
# Rakefile
require File.dirname(__FILE__) + '/config/boot.rb'
require 'thor'
require 'padrino-core/cli/rake'
PadrinoTasks.init
class AddAreasPortfolioEntries < ActiveRecord::Migration
def self.up
create_table "areas_portfolio_entries", :id => false do |t|
t.references :portfolio_entry
t.references :area
end
add_index :areas_portfolio_entries, :portfolio_entry_id
add_index :areas_portfolio_entries, :area_id
end
<!DOCTYPE html>
<html>
<head>
<title><%= browser_title(yield(:title)) %></title>
<meta charset='<%= ::Refinery::Application.config.encoding %>' />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<%= raw "<meta name=\"description\" content=\"#{@meta.meta_description}\" />" if @meta.meta_description.present? -%>
<%= raw "<meta name=\"keywords\" content=\"#{@meta.meta_keywords}\">" if @meta.meta_keywords.present? -%>
# $ deploy dev // Deploys to staging
# $ deploy // Deploys to production
function deploy() {
if [[ $@ != "" ]]; then
git push staging $@:master
else
git push production
fi
}
-(id)initWithName:(NSString *)n description:(NSString *)d url:(NSString *)u;
<!DOCTYPE html>
<html>
<head>
<title><%= browser_title(yield(:title)) %></title>
<% unless Rails.env == "production" %>
<meta name="robots" content="noindex" />
<% end %>
<meta charset='<%= ::Refinery::Application.config.encoding %>' />
#!/usr/bin/env ruby
# Created by _zsh for r/trees
require 'rubygems'
require 'hpricot'
require 'open-uri'
require 'growl'
class CanonicalRedirect
def initialize(app)
@app = app
end
def call(env)
request = Rack::Request.new(env)
if request.host =~ /^example.com/
[301, {"Location" => request.url.sub("//", "//www.")}, self]