Skip to content

Instantly share code, notes, and snippets.

@madmanlear
madmanlear / ubuntu_rails_mysql.txt
Created June 20, 2012 18:28
Setting up a new Ubuntu Server for Git, Ruby on Rails, and MySql
User setup
http://articles.slicehost.com/2010/4/30/ubuntu-lucid-setup-part-1
(follow all the steps up until ipTables)
Install essentials and compilers
# sudo aptitude update
# sudo apt-get install build-essential zlib1g zlib1g-dev
Install CURL
# sudo apt-get install curl
@madmanlear
madmanlear / foundation.txt
Created May 15, 2012 16:47
Foundational Website Elements & Practices
//Websites: Foundational Elements
//SEO
* Unique Title and Meta Description for each page
* Use of Schema.org to mark-up relevant content, large or small (http://schema.org/docs/schemas.html)
//Sharing
* For sites/pages that are meant to be shared (all?), use Facebook OG Tags (http://developers.facebook.com/docs/opengraphprotocol/)
* Test and optimize product/portfolio pages for sharing via Facebook and Pinterest
@madmanlear
madmanlear / vanilla.js
Created March 5, 2012 20:13
Vanilla jQuery
/*
This is a small class for replicating the most often-used (by me, at least) jQuery functionality in 2kb. Tested in newest browsers and IE8. Examples follow.
Includes:
* Find elements
* Create element
* Update attributes for element
* Iterate through elements with callback
* Bind events with callback
* Empty children from element
* Load script
@madmanlear
madmanlear / jquery.hint.js
Created February 2, 2012 15:09
Hint.js with fixes
/**
* Includes a fix for using the back button
* Title default to placeholder for HTML5 support
* @author Remy Sharp
* @url http://remysharp.com/2007/01/25/jquery-tutorial-text-box-hints/
*/
(function ($) {
$.fn.hint = function (blurClass) {
@madmanlear
madmanlear / jquery.custom_select.js
Created January 20, 2012 14:10
A custom select class for jQuery
/*
* Converts form selects to style-able elements using a span for the value, a ul for the options and a wrapper for extra control
* Keeps default form methods intact (automatically updates select, doesn't effect submit, uses label)
* Updates based on selected value on page load
*/
(function ($) {
$.fn.selectGui = function () {
var z = 1000;
return this.each(function () {
@madmanlear
madmanlear / splitnav.js
Created December 20, 2011 14:18
Split Nav
var splitNav = (function() {
var that = {};
that.container = null;
that.lean = 'left';
that.min = 10;
that.sumArr = function(arr) {
z = 0;
for(var i in arr) {
z += arr[i];
}
@madmanlear
madmanlear / jquery.swipe.js
Created November 14, 2011 19:27
jSwipe Edits
/*
* Edits to the jSwipe jquery plugin to better handle swiping without losing default scroll functionality on mobile devices
* jSwipe - jQuery Plugin
* http://plugins.jquery.com/project/swipe
* http://www.ryanscherf.com/demos/swipe/
* Replace the touchMove function with the following:
*/
function touchMove(event) {
finalCoord.x = event.targetTouches[0].pageX // Updated X,Y coordinates
@madmanlear
madmanlear / titanium_migrations.js
Created March 9, 2011 22:10
Rails-like migrations for Titanium
/*
Model methods below requires Joli.js: https://github.com/xavierlacot/joli.js
Requires a tables named 'migrations' with columns id & version
Database migrations
Each migration is attached to a timestamp
When the migration is run, a record is added to the migrations table so it isn't run again
The rollback function takes a string date and rolls back all migrations since that date and deletes the migration record
Usage:
@madmanlear
madmanlear / joliHABTM.js
Created February 24, 2011 16:30
Add HABTM support to joli
//Joli is a lightweight js ORM built for Titanium Apps:
//https://github.com/xavierlacot/joli.js
//Add this to joli.query.prototype
/*
Create HABTM query
Assume standard relationship table naming standards
Attempt to create local and foreign key from relationship table if none is declared
*/
fromThrough: function(table, relation_table, local_key, foreign_key, local_table, foreign_table) {
@madmanlear
madmanlear / animatedPie.js
Created February 24, 2011 14:54
Animating pie chart slices in Raphaeljs
var r = Raphael("holder");
r.customAttributes.segment = function (x, y, r, a1, a2) {
var flag = (a2 - a1) > 180,
clr = (a2 - a1) / 360;
a1 = (a1 % 360) * Math.PI / 180;
a2 = (a2 % 360) * Math.PI / 180;
return {
path: [["M", x, y], ["l", r * Math.cos(a1), r * Math.sin(a1)], ["A", r, r, 0, +flag, 1, x + r * Math.cos(a2), y + r * Math.sin(a2)], ["z"]],
fill: "hsb(" + clr + ", .75, .8)"
};