Skip to content

Instantly share code, notes, and snippets.

View maedi's full-sized avatar

maedi

View GitHub Profile
#!/bin/sh
MYSQLDUMP_DIR='/Users/blah/Sites/db_backups'
CURDATE=`date +%F`
for SITE in $(ls sites/)
do
if [[ -f sites/${SITE}/settings.php ]]
then
# Retreive DB information from settings.php file
DBURL=$(grep '^$db_url' sites/${SITE}/settings.php | sed "s#.*'\(.*\)'#\1#")
require 'nokogiri'
require 'open-uri'
gem 'maca-fork-csspool'
require 'csspool'
module InlineStyle
module Rack
class Middleware
#
@ddemaree
ddemaree / application.js.coffee
Created June 12, 2011 21:54
Simple Google Maps API v3 integration in CoffeeScript, with non-JS Static Maps fallback
#= require jquery
#= require jquery_ujs
#= require lib/modernizr
#= require lib/jquery.lettering
#= require_tree .
$ ->
$('*[data-googlemap]').googleMap()
true
@scottjehl
scottjehl / jqm-self-init-a-widget.js
Created July 8, 2011 14:29
Self-init a jQuery Mobile plugin
// First, let's define a widget/plugin called "foo"
// Either using jQuery's $.fn plugin namespace, for simple stateless plugins...
$.fn.foo = function(){
// In this scope, this refers to the element on which the plugin foo() was called
// manipulate it and return this at the end, so it can be chainable
};
@netshade
netshade / american _why
Created August 24, 2011 18:52
_catch the lucky whiff's tribute to _why
A long, long time ago...
I can still remember
How his blog used to make me smile.
And I knew that if he had his chance
That he could make their code enhance
And, maybe, they’d be happy for a while.
But August made me shiver
With every code line I’d deliver.
Bad news on the doorstep;
@tdegrunt
tdegrunt / batman.secure.rest.coffee
Created December 11, 2011 22:08
Batman - SecureRestStorage, using HMAC Authorization
# Needs
# http://crypto-js.googlecode.com/files/2.3.0-crypto-sha256-hmac.js
pad = (n) -> if n < 10 then "0" + n else n
# Sat, 08 Oct 2011 16:55:39 GMT
timestamp = () ->
now = new Date()
year = now.getUTCFullYear()
month = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][now.getUTCMonth()]
dow = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'][now.getUTCDay()]
@petervandenabeele
petervandenabeele / 1_README.md
Created December 13, 2011 12:37 — forked from josevalim/1_README.md
FSSM based FileWatcher for Rails

Rails 3.2 ships with a simple FileWatcher that only reloads your app if any of the files changed.

Besides, it also provides a mechanism to hook up your own file watcher mechanism, so we can use tools like FSSM that hooks into Mac OS X fsevents. This is an example on how to hook your own mechanism (you need Rails master, soon to be Rails 3.2):

  1. Copy the 2_file_watcher.rb file below to lib/file_watcher.rb

  2. Add the following inside your Application in config/application.rb

if Rails.env.development?

@timgremore
timgremore / index.html.haml
Created January 3, 2012 21:13
Ember.js, document collection and polling...written in CoffeeScript
- title "#{@game.name}"
%h1= yield(:title)
#documents
= form_tag(assessment_game_documents_path(@game)) do
%ul
%script{ type: "text/x-handlebars" }
{{#collection Game.DocumentsCollectionView contentBinding="Game.documentsController"}}
%li {{content.name}}
{{/collection}}
@mdp
mdp / ajax.coffee
Created February 2, 2012 22:54
Backbone AJAX Rails CSRF token hack
app.csrf_token = $('meta[name="csrf-token"]').attr('content')
$.ajaxSetup
beforeSend: (xhr, settings) ->
return if (settings.crossDomain)
return if (settings.type == "GET")
if (app.csrf_token)
xhr.setRequestHeader('X-CSRF-Token', app.csrf_token)
class OfFitnessCampLocationValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
unless record.time_slot.fitness_camp.location_id.to_s == record.user.location_id.to_s
record.errors[attribute] << (options[:message] || "A user and time slot must share the same location")
end
if record.time_slot.fitness_camp.time_slots.map{|ts| ts.registrations}.flatten.map(&:user_id).include?(record.user.id)
record.errors[attribute] << (options[:message] || "A user can only register for one time_slot in a camp")
end
end
end