Skip to content

Instantly share code, notes, and snippets.

View glarizza's full-sized avatar

Gary Larizza glarizza

  • Open Infrastructure Services
  • Portland, Oregon
View GitHub Profile
@glarizza
glarizza / gist:4108367
Created November 19, 2012 00:42
Auto Time Zone
property_list_key { 'Auto Timezone':
ensure => present,
path => '/Library/Preferences/com.apple.timezone.auto.plist',
key => 'Active',
value => true,
value_type => 'boolean',
}
@glarizza
glarizza / gist:3948432
Created October 24, 2012 19:57
Disable Autocorrect
# http://github.com/glarizza/puppet-property_list_key
property_list_key { 'Disable Ducking Autocorrect':
ensure => present,
path => "${my_homedir}/Library/Preferences/.GlobalPreferences.plist",
key => 'NSAutomaticSpellingCorrectionEnabled',
value => false,
value_type => 'boolean',
}
@glarizza
glarizza / gist:3915050
Created October 18, 2012 22:05
Chainletter math
Now....Make A wish!! I hope you made your wish!
Now then, if you send to:
1 person --- your wish will be granted in 1 year
3 people --- 6 months
5 people --- 3 months
6 people --- 1 month
7 people --- 2 weeks
8 people --- 1 week
@glarizza
glarizza / gist:3747543
Created September 19, 2012 03:45
Dirty hacky world-writability check
def world_writable?(write_bit)
if write_bit > 3
write_bit -= 4
return false if write_bit == 0
write_bit % 2 == 0 ? true : false
elsif write_bit < 4
return false if write_bit == 0
write_bit % 2 == 0 ? true : false
end
end
@glarizza
glarizza / gist:3707084
Created September 12, 2012 14:41
Macauthorization
class osx_management::macauth_datetime {
require osx_management::macauth_sysprefs
macauthorization { 'system.preferences.datetime':
ensure => 'present',
allow_root => 'true',
auth_class => 'user',
auth_type => 'right',
comment => 'Changed by Puppet',
group => 'staff',
@glarizza
glarizza / gist:3492838
Created August 27, 2012 22:16
Facter Facts
## Simple Shell Fact
Facter.add('role') do
setcode('cat /etc/role')
end
## More complex Ruby fact
Facter.add('ruby_stuff') do
setcode do
@glarizza
glarizza / gist:3363581
Created August 15, 2012 20:54
Setting the password in 10.7 by editing the plist
require 'puppet'
require 'facter/util/plist'
require 'stringio'
require 'base64'
def convert_xml_to_binary(plist_data)
# This method will accept a hash that has been returned from Plist::parse_xml
# and convert it to a binary plist (string value).
Puppet.debug('Converting XML plist to binary')
Puppet.debug('Executing: \'plutil -convert binary1 -o - -\'')
@glarizza
glarizza / gist:3354042
Created August 14, 2012 23:59
Setting the password with dsimport
require 'puppet'
require 'facter/util/plist'
require 'stringio'
require 'base64'
def convert_xml_to_binary(plist_data)
# This method will accept a hash that has been returned from Plist::parse_xml
# and convert it to a binary plist (string value).
Puppet.debug('Converting XML plist to binary')
Puppet.debug('Executing: \'plutil -convert binary1 -o - -\'')
@glarizza
glarizza / gist:3346062
Created August 14, 2012 03:27
Apple's new Warranty Status changes
# I apologize to The Baby Jesus for the atrocities I'm about to commit
require 'net/http'
require 'net/https'
require 'uri'
# Contact Apple
uri = URI.parse('https://selfsolve.apple.com/wcResults.do')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
@glarizza
glarizza / gist:3332629
Created August 12, 2012 16:27
XML versus YAML
>> hash = { 'key' => 'value' }
=> {"key"=>"value"}
>> hash.to_yaml
=> "--- \nkey: value\n"
>> Plist::Emit.dump(hash)
=> "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>key</key>\n\t<string>value</string>\n</dict>\n</plist>\n"
## Here's YAML:
---