Skip to content

Instantly share code, notes, and snippets.

@mjtko
mjtko / layout.html.haml
Created September 30, 2011 10:27
Asset pipeline customization
= stylesheet_link_tag 'application', :media => 'all'
= stylesheet_link_tag 'app/print', :media => 'print'
-# implement the however you want obviously, just here as an eg.
- unless @theme.nil?
= stylesheet_link_tag "theme/#{@theme}"
- if controller_specific_styles?
= stylesheet_link_tag "app/#{params[:controller]}"
@mjtko
mjtko / Gemfile
Created September 23, 2011 19:59
Rails + DataMapper Gemfile
source 'http://rubygems.org'
RAILS_VERSION = '3.1.0'
DM_VERSION = '~> 1.1.0'
RSPEC_VERSION = '~> 2.5.0'
gem 'activeresource', RAILS_VERSION, :require => 'active_resource'
gem 'activesupport', RAILS_VERSION, :require => 'active_support'
gem 'actionpack', RAILS_VERSION, :require => 'action_pack'
gem 'actionmailer', RAILS_VERSION, :require => 'action_mailer'
@mjtko
mjtko / sync_middleware.rb
Created September 21, 2011 13:19
Synchronous middleware for Faye
require 'faye'
require 'json'
require 'rack'
require 'cgi'
module Faye
class SyncMiddleware
include ::Faye::Logging
@mjtko
mjtko / application.css
Created September 21, 2011 11:26
Less with assets pipeline
/*
*= require bootstrap
*/
locales.en.yml
for_further_info_html: 'For further information, please view the %{link}.'
for_further_info: 'For further information, please view the %{link}.'
info_link: 'the info link'
view:
# works with 'magic suffix'
t '.for_further_info_html', :link => link_to(t('.info_link'), '/info', target: '_blank')
# doesn't work, wtf?
namespace :wtp do
namespace :jsroutes do
desc "Regenerate routes for users"
task :users do
puts "Recreating routes for users..."
JsRoutes.generate!({})
end
end
end
@mjtko
mjtko / application.rb
Created September 6, 2011 08:38
patched sprockets railtie in application.rb
require File.expand_path('../boot', __FILE__)
# Frameworks
# I don't use activerecord, but if you did, you'd want the following line too:
# require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "rails/test_unit/railtie"
#require "sprockets/railtie"
@mjtko
mjtko / linked.rb
Created September 5, 2011 19:53
Application wide token/secret
module LinkedSecrets
class << self
def token
"XXXX"
end
def secret
"YYYY"
end
end
end
<%= simple_form_for([@pacient, @retetum]) do |f| %>
<%= f.error_notification %>
<div class="inputs">
<%= f.input :data %>
<%= f.input :cantitate %>
<%= f.input :serie %>
<%= f.input :medicamente_id do %>
<%# select(:retetum, :medicamente_id, Medicamente.pastile) %>
<%= select(:retetum, :medicamente_id, Medicamente.clase,
@mjtko
mjtko / mail-message-word-wrap.rb
Created September 4, 2011 13:40
Monkey patch Mail to word wrap every body before delivery
module Mail
class Message
include ActionView::Helpers::TextHelper
def deliver_with_word_wrap
self.body = word_wrap(self.body, :line_width => 70)
deliver_without_word_wrap
end
alias_method_chain :deliver, :word_wrap