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
#
@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}}
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
@loopj
loopj / batman-layoutcontroller.coffee
Created October 8, 2012 21:44
Batman.js controller which adds rails-style layouts to controllers
class Batman.LayoutController extends Batman.Controller
render: (options = {}) ->
layout = options.layout ? @layout ? Batman.helpers.underscore(@get('routingKey'))
if layout
# Prefetch the action's view in parallel
source = options.source || Batman.helpers.underscore(@get('routingKey') + '/' + @get('action'))
Batman.View.store.prefetch source
# Fetch the layout's view and apply context
@mrrooijen
mrrooijen / example.html
Created October 21, 2012 20:36
Batman.js data-foreach with index.
<!-- Show the <hr /> if the `account.viewIndex` is greater than `0` -->
<!-- Note: The `gt` function is a custom filter I made, see the `helpers.js.coffee` file -->
<div data-foreach-account="currentUser.accounts | withIndex">
<hr data-showif="account.viewIndex | gt 0" />
<span data-bind="account.email"></span>
</div>
@mrrooijen
mrrooijen / filters.coffee
Created October 28, 2012 11:41
Batman.js Even/Odd CSS trick for iterations.
Batman.mixin Batman.Filters,
indexOf: (set, iteration) -> set?.toArray().indexOf(iteration)
isEven: (input) -> input % 2 == 0