Skip to content

Instantly share code, notes, and snippets.

View voltechs's full-sized avatar

Dale voltechs

  • Notion, Twilight Coders
  • Denver
View GitHub Profile
@voltechs
voltechs / gist:59849ce491a5e1179e09
Created June 16, 2014 00:41
my stack trace for nsevent leak
0 libsystem_malloc.dylib malloc_zone_calloc
1 libsystem_malloc.dylib calloc
2 libobjc.A.dylib class_createInstance
3 libobjc.A.dylib +[NSObject allocWithZone:]
4 AppKit -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:]
5 sfml-window +[SFApplication processEvent]
6 sfml-window -[SFWindowController processEvent]
7 sfml-window sf::priv::WindowImpl::popEvent(sf::Event&, bool)
8 sfml-window sf::Window::pollEvent(sf::Event&)
9 Galaxer Client::run()
scope :roles_in_group, lambda { |g| { :conditions => { :roles => {:memberships => {:group => g.ancestors}}}}}
class Membership < ActiveRecord::Base
# attr_accessible :title, :body
set_primary_keys :user_id, :group_id
belongs_to :user
belongs_to :group
# Weird that we have to say "belongs_to", but it works.
belongs_to :role
has_many :members, :through => :memberships, :source => :user, :include => { :memberships => :role }, :order => 'roles.rank'
SELECT `users`.* FROM `users`
INNER JOIN `memberships`
ON `users`.`id` = `memberships`.`user_id`
INNER JOIN `roles`
ON `roles`.`id` = `memberships`.`role_id`
WHERE `memberships`.`group_id` = 'NUCC' AND (expiration > '2012-07-02')
ORDER BY `roles`.`rank` DESC
class Group < ActiveRecord::Base
set_primary_key :id
belongs_to :type, class_name: "GroupType"
belongs_to :parent, class_name: "Group", foreign_key: "parent_id"
has_many :children, class_name: "Group", foreign_key: "parent_id"
# Haven't played around with this part too much yet.
accepts_nested_attributes_for :children
@voltechs
voltechs / query.sql
Created July 8, 2012 23:45
Memberships ordered by the rank of membership's role.
SELECT `memberships`.* from `memberships`
INNER JOIN `groups` ON `groups`.id = `memberships`.group_id
INNER JOIN `roles` ON `memberships`.role_id = `roles`.id
INNER JOIN `roles` `role_cat` ON `role_cat`.id = `roles`.type_id
WHERE `groups`.id = "HHC" AND `memberships`.expiration > CURDATE()
ORDER BY `role_cat`.rank DESC, `roles`.rank DESC
irb(main):019:0> u.permissions
Permission Load (0.8ms) SELECT `permissions`.* FROM `permissions` INNER JOIN `groups` ON `permissions`.`group_id` = `groups`.`id` INNER JOIN `memberships` ON `groups`.`id` = `memberships`.`group_id` WHERE `memberships`.`user_id` = 1160 AND (expiration = "0000-00-00" OR expiration > '2012-07-10')
ActiveRecord::DangerousAttributeError: create is defined by ActiveRecord
from /usr/local/lib/ruby/gems/1.9/gems/activerecord-3.2.5/lib/active_record/attribute_methods.rb:91:in `instance_method_already_implemented?'
from /usr/local/lib/ruby/gems/1.9/gems/activemodel-3.2.5/lib/active_model/attribute_methods.rb:263:in `block in define_attribute_method'
from /usr/local/lib/ruby/gems/1.9/gems/activemodel-3.2.5/lib/active_model/attribute_methods.rb:260:in `each'
from /usr/local/lib/ruby/gems/1.9/gems/activemodel-3.2.5/lib/active_model/attribute_methods.rb:260:in `define_attribute_method'
from /usr/local/lib/ruby/gems/1.9/gems/activemodel-3.2.5/lib/act
@echo off
cls
set x86=”%SYSTEMROOT%\System32\OneDriveSetup.exe”
set x64=”%SYSTEMROOT%\SysWOW64\OneDriveSetup.exe”
echo Closing OneDrive process.
echo.
@voltechs
voltechs / CombustionEngine.md
Last active December 4, 2020 15:23
Combustion Engine

For those of you who might be using your engine as a git submodule in a bigger project, here is what I've settled on (riffed a bit from pat/combustion#13 (comment)). I will admit that a bit of the final result is due to trail/error. For instance, I don't really know what the task :environment block does, but I know when I run rake db:migrate, it executes that block, and thus requires additional requires.

If someone else has a clearer understanding of how everything is fitting together, please let me know and I'll update

We do not need to modify db paths in the Rakefile because we've set those up as initializers in the engine.rb so that the main app pulls migrations and schema.rb from the core project. (Bonus points for loading FactoryBot factories to be reused in the main app!)