Skip to content

Instantly share code, notes, and snippets.

View tvdeyen's full-sized avatar
🎧

Thomas von Deyen tvdeyen

🎧
View GitHub Profile
@tvdeyen
tvdeyen / seeds.rb
Last active March 9, 2022 11:52
n Alchemy pages randomly nested
# frozen_string_literal: true
require "alchemy/test_support"
FactoryBot.definition_file_paths.append(Alchemy::TestSupport.factories_path)
FactoryBot.reload
lang_root = FactoryBot.create(:alchemy_page, :language_root)
page_levels = ENV.fetch("PAGE_LEVELS", 10).to_i
pages_per_level = ENV.fetch("PAGES_PER_LEVEL", 100).to_i
parent_ids = []
@tvdeyen
tvdeyen / .travis.yml
Created February 2, 2017 06:27
Downgrade bundler on Travis CI
before_install:
- rvm use @global
- gem uninstall bundler -x
- gem install bundler --version=1.13.7
- bundler --version
@tvdeyen
tvdeyen / keybase.md
Created February 8, 2017 15:12
Keybase proof

Keybase proof

I hereby claim:

  • I am tvdeyen on github.
  • I am tvdeyen (https://keybase.io/tvdeyen) on keybase.
  • I have a public key ASBPRvz2kxC1Twc76KaVRVNhklmqAP4woehRSWE7_e99bgo

To claim this, I am signing this object:

@tvdeyen
tvdeyen / Capfile
Created November 3, 2016 09:57
AlchemyCMS deployment with Capistrano
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
require 'capistrano/alchemy'
# Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
@tvdeyen
tvdeyen / elements.yml
Last active December 25, 2015 08:29
Creating a "Meet the team page" in Alchemy
- name: team_member
contents:
- name: name
type: EssenceText
- name: position
type: EssenceText
- name: linkedin
type: EssenceLink
- name: bio
type: EssenceRichtext
# 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",
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?
@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"
@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: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});
});
});