This file contains hidden or 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
scope :roles_in_group, lambda { |g| { :conditions => { :roles => {:memberships => {:group => g.ancestors}}}}} |
This file contains hidden or 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 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 |
This file contains hidden or 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
has_many :members, :through => :memberships, :source => :user, :include => { :memberships => :role }, :order => 'roles.rank' |
This file contains hidden or 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
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 |
This file contains hidden or 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 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 |
This file contains hidden or 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
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 |
This file contains hidden or 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
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 |
This file contains hidden or 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
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() |
This file contains hidden or 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
@echo off | |
cls | |
set x86=”%SYSTEMROOT%\System32\OneDriveSetup.exe” | |
set x64=”%SYSTEMROOT%\SysWOW64\OneDriveSetup.exe” | |
echo Closing OneDrive process. | |
echo. |
This file contains hidden or 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
#!/usr/bin/env ruby | |
# Usage: no_automount /Volumes/My\ Disk | |
diskinfo = `diskutil info '#{ARGV[0]}'`.gsub("\n\n", "\n").split("\n").collect { |b| | |
b.strip.split(/:\s+/) | |
}.to_h | |
disk_uuid = diskinfo['Volume UUID'] | |
disk_type = diskinfo['Type (Bundle)'] |
OlderNewer