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 Base54 | |
L = %w{0 1 2 3 4 5 6 7 8 9 | |
A B C D E F G H K L | |
M N P Q R T U V W X | |
Y a b c d e f g h i | |
j k m n p q r s t u | |
v w x z} | |
WHITESPACE = [' ', '-', '_', '.', '+'] |
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
function enableReorder() { | |
$('*[data-reorder-path]').sortable({ | |
update: function(event, ui) { | |
var ul = $(this); | |
var ids = ul.children("*[data-child-id]").map(function(){ | |
return $(this).data("child-id"); | |
}).toArray().join(","); | |
$.ajax(ul.data('reorderPath'), { | |
data: {ids: ids} | |
}); |
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
# Aus dem Controller kommen: | |
# - @employee | |
# - @context (alle infos, die Liquid benutzen soll/darf) | |
# - @template (Das Ding von oben) | |
- content_for :header do | |
= Liquid::Template.parse(@template.header).render(@context) | |
- content_for :submenu do | |
= Liquid::Template.parse(@template.submenu).render(@context) |
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
# Normally if you do | |
class A < ActiveRecord::Base | |
belongs_to :c | |
end | |
class B < A | |
end | |
b = B.new | |
b.c = C.new |
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 Hash | |
def &(*ks) | |
kk = self.keys | |
ks = ks.flatten | |
self.reject{ |k,v| !ks.member?(k) } | |
end | |
end | |
> {a:1, b:2} & 1 | |
=> {} |
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
Tabulatr.config do |config| | |
#... | |
config.column_presets({ | |
config.column_presets({ | |
:action_column => {:width => '100px'}, | |
:smallint => { :width => '55px', :filter_width => '30px', :align => 'right' }, | |
:id => :smallint, | |
:sid => { :width => '200px', :filter_width => '170px', :filter => :like }, | |
:title => { :filter => :like }, | |
:count => { :map => false, :width => '40px', :filter => false, :align => 'right' }, |
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
see https://github.com/metaminded/time_period |
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 PgTable < ActiveRecord::Base | |
SystemSchemaNames = ['public', 'information_schema', 'pg_catalog'] | |
def self.each_schema_execute(&block) | |
tenant_schemas.each do |schemaname| | |
set_search_path(schemaname) | |
yield(self.connection) | |
end | |
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
# First, I put this into the application helper | |
module ApplicationHelper | |
class T | |
instance_methods.each { |m| undef_method m unless m =~ /^((object_id$)|(__))/ } | |
def method_missing(sym, *args, &block) | |
@str = @str ? "#{@str}.#{sym}" : sym.to_s | |
self |