Skip to content

Instantly share code, notes, and snippets.

View tvdeyen's full-sized avatar
🎧

Thomas von Deyen tvdeyen

🎧
View GitHub Profile
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,
@tvdeyen
tvdeyen / _tinymce_enable.html.erb
Created April 10, 2015 15:50
Enable Alchemy CMS build in TinyMCE for Spree text areas.
<!-- app/views/admin/shared/_tinymce_enable.html.erb -->
<script charset="utf-8">
var tinyMCEPreInit = {
base: '<%= asset_path('tinymce') %>',
suffix: '.min'
};
$(function() {
@tvdeyen
tvdeyen / error.log
Last active August 29, 2015 14:25
Passenger spawn error
App 849 stdout:
App 849 stderr: sh: 1: env: not found
App 849 stdout:
[ 2015-07-21 22:27:38.9884 801/7f8e3c182700 App/Implementation.cpp:303 ]: Could not spawn process for application /var/www/<username>/html/current: An error occured while starting up the preloader.
Error ID: c03be446
Error details saved to: /tmp/passenger-error-tAHB0D.html
Message from application: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
/var/www/<username>/html/shared/bundle/ruby/2.2.0/gems/execjs-2.5.2/lib/execjs/runtimes.rb:48:in `autodetect'
/var/www/<username>/html/shared/bundle/ruby/2.2.0/gems/execjs-2.5.2/lib/execjs.rb:5:in `<module:ExecJS>'
/var/www/<username>/html/shared/bundle/ruby/2.2.0/gems/execjs-2.5.2/lib/execjs.rb:4:in `<top (required)>'
window.tinyMCE_GZ = {
loaded: true
}; (function(c) {
var a = /^\s*|\s*$/g,
d;
var b = {
majorVersion: "3",
minorVersion: "3.2",
releaseDate: "2010-03-25",
_init: function() {
@tvdeyen
tvdeyen / width.html
Created January 14, 2011 15:45
Example for the calculated width of an select element.
<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 {
<!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>
@tvdeyen
tvdeyen / gist:2711329
Created May 16, 2012 15:32 — forked from dx7/gist:1333785
Installing ruby-debug with ruby-1.9.3-p194
# 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
@tvdeyen
tvdeyen / gist:2774577
Created May 23, 2012 11:05
Responsive iframe resizing
$(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});
});
});
@tvdeyen
tvdeyen / order_decorator.rb
Created July 3, 2012 18:56
Spree tax calculation patch
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'
@tvdeyen
tvdeyen / gist:3246525
Created August 3, 2012 10:28
Fast rails database truncation with sqlite support
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"