This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/database.rb | |
config_file = Padrino.root("config", "mongoid.yml") | |
if File.exists?(config_file) | |
settings = YAML.load(ERB.new(File.read(config_file)).result)[Padrino.env.to_s] | |
::Mongoid.from_hash(settings) if settings.present? | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
es: | |
errors: | |
messages: | |
expired: "has expired, please request a new one" | |
not_found: "not found" | |
already_confirmed: "was already confirmed, please try signing in" | |
not_locked: "was not locked" | |
not_saved: | |
one: "1 error prohibited this %{resource} from being saved:" | |
other: "%{count} errors prohibited this %{resource} from being saved:" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Jekyll | |
require 'haml' | |
class HamlConverter < Converter | |
safe true | |
priority :low | |
def matches(ext) | |
ext =~ /haml/i | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'rss' | |
p 'Downloading rss index' | |
rss_string = open('http://feeds.feedburner.com/railscasts').read | |
rss = RSS::Parser.parse(rss_string, false) | |
videos_urls = rss.items.map { |it| it.enclosure.url }.reverse | |
videos_filenames = videos_urls.map {|url| url.split('/').last } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this give us activerecord like commands for events, also extend the object with the respective methods | |
# | |
# example | |
# | |
# @cachedevent.reservations return all reservations in a hash | |
# {"15"=>#<BSON::OrderedHash:0x-2581ca5a {values}} | |
# | |
# also extends the object with | |
# | |
# @cachedevent.reservations.extend(ReportAgregator::Reservations) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Date | |
def self.to_mongo(value) | |
if value.nil? || value == '' | |
nil | |
else | |
date = value.is_a?(::Date) || value.is_a?(::Time) ? value : ::Date.parse(value.to_s) | |
::Time.utc(date.year, date.month, date.day, date.try(:hour), date.try(:min), date.try(:sec)) | |
end | |
rescue | |
nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [[ -n "$PS1" ]]; then | |
PS1='\[\033[01;30m\][ \[\033[01;31m\]\u \[\033[01;30m\]]\[\033[01;34m\]\w\[\033[00m\]\$ ' | |
eval "`dircolors -b`" | |
if [ -f ~/.bash_aliases ]; then | |
. ~/.bash_aliases | |
fi | |
fi | |
xhost +LOCAL: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# natcmp.rb | |
# | |
# Natural order comparison of two strings | |
# e.g. "my_prog_v1.1.0" < "my_prog_v1.2.0" < "my_prog_v1.10.0" | |
# which does not follow alphabetically | |
# | |
# Based on Martin Pool's "Natural Order String Comparison" originally written in C | |
# http://sourcefrog.net/projects/natsort/ | |
# | |
# This implementation is Copyright (C) 2003 by Alan Davies |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("li.month").click(function(e){ | |
e.preventDefault(); | |
var selected_month = $(this).closest('li').index(); | |
$("#slider-range").slider("values",[Math.abs(moment([moment().year()]).diff(moment([moment().year()]).month(selected_month-1),'month')),Math.abs(moment([moment().year()]).diff(moment([moment().year()]).month(selected_month),'days'))]); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# File forked from github.com/kete/kete.. not my work | |
# what this does: | |
# * prepares google map accordingly for request type | |
# (form for baskets_controller#choose_type with empty map, display for index_page_controller#index, | |
# all other controllers#show, new, etc.) | |
# * adds view helpers for loading api js lib and initializing google map js and escaping js (i18n_js(key)) | |
# * adds helpers for ExtendedFieldsHelper editor (including geocoding address form) and display | |
# * validates extended field ftype for map or map with address | |
module GoogleMap |
OlderNewer