Skip to content

Instantly share code, notes, and snippets.

View johnantoni's full-sized avatar

John Griffiths johnantoni

View GitHub Profile
@johnantoni
johnantoni / jquery-get-mouse-location.js
Created December 23, 2010 14:30
jquery - determine element clicked on, if outside the post textbox clear the value
// jquery get mouse location
// clear post when lose focus
$("*", document.body).click(function (e) {
e.stopPropagation();
var domEl = $(this).get(0);
if (!$(domEl).closest("#newsfeed_post").length > 0) {
$("#newsfeed_post textarea").css("color", "#aaa").val("Write something here...");
}
});
@johnantoni
johnantoni / postgresql + homebrew
Created February 22, 2011 23:55
postgres install with homebrew
brew install postgres
initdb /usr/local/var/postgres
psql postgres -c "create role postgres with login superuser"
psql postgres -c "alter user postgres with password 'password'"
@johnantoni
johnantoni / setAllToMaxHeight
Created April 13, 2011 13:01
setAllToMaxHeight (jquery)
$.fn.setAllToMaxHeight = function(){
return this.height( Math.max.apply(this, $.map( this , function(e){ return $(e).height() }) ) );
}
// usage: $(‘div.unevenheights’).setAllToMaxHeight()
// http://www.broken-links.com/2009/01/20/very-quick-equal-height-columns-in-jquery/
@johnantoni
johnantoni / supersleight.plugin.js
Created April 14, 2011 08:20
Supersleight jQuery Plugin for Transparent PNGs in IE6
jQuery.fn.supersleight = function(settings) {
settings = jQuery.extend({
imgs: true,
backgrounds: true,
shim: 'x.gif',
apply_positioning: true
}, settings);
return this.each(function(){
if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 7 && parseInt(jQuery.browser.version, 10) > 4) {
@johnantoni
johnantoni / LICENSE.txt
Created June 20, 2011 02:12 — forked from 140bytes/LICENSE.txt
140byt.es -- Click ↑↑ fork ↑↑ to play!
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@johnantoni
johnantoni / pngcrush.sh
Created August 15, 2011 22:07
pngcrush directory script
#!/bin/sh
for png in `find $1 -name "*.png"`;
do
echo "crushing $png"
pngcrush -brute "$png" temp.png
mv -f temp.png $png
done;
@johnantoni
johnantoni / gist:1162244
Created August 22, 2011 12:17
Amazon S3 Hot Linking Restriction Policy
{
"Version":"2008-10-17",
"Id":"preventHotLinking",
"Statement":[ {
"Sid":"1",
"Effect":"Allow",
"Principal": {
"AWS":"*"
@johnantoni
johnantoni / spree.extension.commandline.txt
Created October 28, 2011 13:11
SPREE Extension Commands
script/generate extension_controller site
script/generate extension_migration site {migration}
script/generate extension_model site
@johnantoni
johnantoni / logrotate.capify
Created January 10, 2012 21:55
Install log rotate script for Capistrano
desc "Install log rotate script"
task :rotate_logs, :roles => :app do
set :use_sudo, true
default_run_options[:pty] = true
rotate_script = %Q{#{shared_path}/log/*.log {
daily
missingok
rotate 30
compress
size 5M
@johnantoni
johnantoni / ajaxForm_with_fancybox.js
Created January 31, 2012 15:11
ajaxForm_with_fancybox - pulled from a project for dissection
$.fn.ajaxForm_with_fancybox = function(options) {
$("<input>").attr("type", "hidden").attr("name", "lightbox").val("1").appendTo(this);
var url = jQuery(this).attr("action");
this.ajaxForm({
url: url + ".json",
beforeSend: function(request){
$.fancybox.showLoading();