Skip to content

Instantly share code, notes, and snippets.

View daviddavis's full-sized avatar

David Davis daviddavis

View GitHub Profile
→ tar -h
tar(bsdtar): manipulate archive files
First option must be a mode specifier:
-c Create -r Add/Replace -t List -u Update -x Extract
Common Options:
-b # Use # 512-byte records per I/O block
-f <filename> Location of archive
-v Verbose
-w Interactive
Create: tar -c [options] [<file> | <dir> | @<archive> | -C <dir> ]
λ git develop → paster serve development.ini
Traceback (most recent call last):
File "/usr/bin/paster", line 9, in <module>
load_entry_point('PasteScript==1.7.5', 'console_scripts', 'paster')()
File "/usr/lib/python2.7/site-packages/paste/script/command.py", line 93, in run
commands = get_commands()
File "/usr/lib/python2.7/site-packages/paste/script/command.py", line 135, in get_commands
plugins = pluginlib.resolve_plugins(plugins)
File "/usr/lib/python2.7/site-packages/paste/script/pluginlib.py", line 82, in resolve_plugins
pkg_resources.require(plugin)
# option 1
info = CustomInfo.new(:keyname => params[:keyname], :value => params[:value])
info.informable = @informable
info.save!
# option 2
CustomInfo.create!(:keyname => params[:keyname],
:value => params[:value],
:informable_type => params[:informable_type],
:informable_id => params[:informable_id]
hesperus ~ → rpm -qa | grep java
tzdata-java-2012j-1.fc18.noarch
java-1.7.0-openjdk-1.7.0.9-2.3.5.fc18.1.x86_64
javapackages-tools-0.9.1-1.fc18.noarch
hesperus ~ → rpm -qa | grep tea
icedtea-web-1.3.1-3.fc18.x86_64
@daviddavis
daviddavis / cvef.rb
Last active December 13, 2015 22:59
FactoryGirl.define do
factory :content_view_environment do
sequence(:name) { |n| "Database#{n}" }
sequence(:cp_id) { |n| "#{n}-123"}
content_view
end
end
FactoryGirl.define do
factory :content_view_environment do
@daviddavis
daviddavis / trait.rb
Last active December 14, 2015 14:19
traits in fg
factory :user do
username "partha"
real_name "Partha Aji"
trait :admin do
username "admin"
end
end
FactoryGirl.create(:user) # <User username: partha real_name: Partha Aji>
class ContentViewDefinitionBase < ActiveRecord::Base
belongs_to :organization, :inverse_of => :content_view_definitions
has_many :content_view_definition_products, :foreign_key => "content_view_definition_id"
has_many :products, :through => :content_view_definition_products has_many :content_view_definition_repositories, :foreign_key => "content_view_definition_id"
has_many :repositories, :through => :content_view_definition_repositories
validates :organization, :presence => true
end
class Distributor
belongs_to :environment
# ...
validate name_uniq_in_org
def name_uniq_in_org
others = self.where(:name => self.name).join(:environment).
where("enivronment.organization_id" => self.environment.organization_id)
others.where("id != ?", self.id) if self.id
errors.add(:base, "name already taken") if others.any?
@daviddavis
daviddavis / nh.rb
Created April 10, 2013 15:23
update a nested hash
parameters = {:units => [
{
:name => "wat",
:blah => "ok"
},
{
:name => "foo",
:max_version => 2
}
]}
@daviddavis
daviddavis / gist:5421585
Created April 19, 2013 16:47
Options for the content view select on systems page
Easiest to hardest:
0. Show all content views and show an error if they select an env that doesn't have the view or a view not in the environment
1. Show an error if they select an environment that doesn't have the content view but limit views by environment
2. Unselect content view if they select an environment, limit content views by environment