Thomas von Deyen tvdeyen

View alchemy_models_protected_attributes.rb
1 2 3 4 5 6 7 8 9 10
module Alchemy
Attachment.attr_accessible :file,
:name,
:file_name,
:tag_list
Cell.attr_accessible :page_id, :name
Content.attr_accessible :do_not_index,
:element_id,
:essence_id,
:essence_type,
View elements.yml
1 2 3 4 5 6 7 8 9 10
- name: team_member
contents:
- name: name
type: EssenceText
- name: position
type: EssenceText
- name: linkedin
type: EssenceLink
- name: bio
type: EssenceRichtext
View char_converter.rb
1 2 3 4 5 6 7 8 9 10
# config/initializers/char_converter.rb
require 'uri'
 
module Support
class CharConverter
 
SANITIZE_ENV_KEYS = [
#"HTTP_COOKIE", # including this will give -> WARNING: Can't verify CSRF token authenticity and kill you session cookies
"HTTP_REFERER",
"PATH_INFO",
View elements_controller.rb
1 2 3 4 5 6 7 8 9 10
module Alchemy
module Admin
class ElementsController < Alchemy::Admin::BaseController
 
cache_sweeper Alchemy::ContentSweeper, :only => [:create, :update, :destroy]
 
def index
@page = Page.find(params[:page_id], :include => {:elements => :contents})
@cells = @page.cells
if @cells.blank?
View gist:3246525
1 2 3 4 5 6 7 8 9 10
def truncate_all_tables
config = ActiveRecord::Base.configurations[::Rails.env]
connection = ActiveRecord::Base.connection
connection.disable_referential_integrity do
connection.tables.each do |table_name|
next if connection.select_value("SELECT count(*) FROM #{table_name}") == 0
case config["adapter"]
when "mysql", "mysql2", "postgresql"
connection.execute("TRUNCATE #{table_name}")
when "sqlite", "sqlite3"
View order_decorator.rb
1 2 3 4 5 6 7 8 9 10
StateMachine::Machine.ignore_method_conflicts = true
 
module Spree
Order.class_eval do
 
# customize the checkout state machine
Order.state_machines[:state] = StateMachine::Machine.new(Order, :initial => 'cart') do
 
event :next do
transition :from => 'cart', :to => 'address'
View gist:2774577
1 2 3 4 5 6 7 8
$(document).ready(function(){
$(window).on('resize', function() {
var padding = 0;
var width = $(window).width() - (2 * padding);
var ratio = 9/16;
$('iframe').css({width: width, height: width*ratio});
});
});
View gist:2711329
1 2 3 4 5 6 7 8 9
# Install with:
# bash < <(curl -L https://raw.github.com/gist/2711329)
#
# Reference: http://blog.wyeworks.com/2011/11/1/ruby-1-9-3-and-ruby-debug
 
echo "Installing ruby-debug with ruby-1.9.3-p194 ..."
 
curl -OL http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem
curl -OL http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem
View selectbox-blur.html
1 2 3 4 5 6 7 8 9 10
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script type="text/javascript" src="https://github.com/revsystems/jQuery-SelectBox/raw/master/jquery.sb.min.js"></script>
<link rel="stylesheet" href="https://github.com/revsystems/jQuery-SelectBox/raw/master/jquery.sb.css" type="text/css" media="screen" title="no title" charset="utf-8">
</head>
<body>
<form action="#" method="get" accept-charset="utf-8">
<p>
View width.html
1 2 3 4 5 6 7 8 9 10
<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript" src="https://github.com/revsystems/jQuery-SelectBox/raw/master/jquery.sb.min.js"></script>
<link type="text/css" rel="stylesheet" media="screen" href="https://github.com/revsystems/jQuery-SelectBox/raw/master/jquery.sb.css">
<style type="text/css" media="screen">
select.long {
width: 150px;
}
a.display.long {
Something went wrong with that request. Please try again.