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 | |
| require 'nokogiri' | |
| doc = Nokogiri::HTML(open("test.html")) | |
| doc.xpath('//div[@class="level"]/strong').each {|node| puts node.text} | |
| doc.xpath('//div[@class="level"]').each {|node| puts node.text.strip} |
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/local/bin/macruby | |
| # nb. http://stackoverflow.com/questions/8738424/macruby-how-to-create-an-app-that-can-be-configured-from-the-outside | |
| framework 'Cocoa' | |
| framework 'Foundation' | |
| def set_prefs(pref) | |
| if File.exists?(pref) | |
| @config = load_plist File.read(pref) |
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 | |
| # 110224, revised with loop to accept an array | |
| # 110425, swapped order of variable definition in get_version | |
| # 120301, made more generic, removed loop, added uninstall and install | |
| require 'FileUtils' | |
| def get_version(app) | |
| if File.exists?("#{app}/Contents/Info.plist") | |
| vers = `/usr/bin/defaults read "#{app}"/Contents/Info CFBundleShortVersionString`.chomp |
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 | |
| # cf. http://puppetlabs.com/blog/facter-part-3-caching-and-ttl/ | |
| require 'rubygems' | |
| require 'rest_client' | |
| # if you're behind a proxy, define it here | |
| RestClient.proxy = "" | |
| geo_raw=(RestClient.post "http://api.hostip.info/get_html.php", :position=>"true") | |
| geo_data=Hash[*geo_raw.scan(/(.*): (.*)\n/).to_a.flatten] |
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 bash | |
| function wireless_disable () { | |
| version=`sw_vers -productVersion | cut -d "." -f 2` | |
| airport=`networksetup -listallhardwareports | awk '/Wi-Fi|AirPort/ {getline; print $2}'` | |
| case $version in | |
| "7" ) | |
| networksetup -setairportpower $airport off | |
| echo "power to $airport is off." | |
| ;; |
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
| # in cacheController.py, around line 300 | |
| # add this to enable proxy support | |
| # cf. http://stackoverflow.com/questions/1450132/proxy-with-urllib2 | |
| proxy_support = urllib2.ProxyHandler({"http" : "http://proxy.company.com:8080"}) | |
| opener = urllib2.build_opener(proxy_support) | |
| urllib2.install_opener(opener) |
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
| # | |
| # Copyright 2009 Joe Block <[email protected]> | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software |
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
| require 'FileUtils' | |
| require 'pathname' | |
| def stash_user_file(file) | |
| users = get_users | |
| users.each do |u| | |
| if File.directory?(file) | |
| if File.exist?("#{get_homedir(u)}/Library/Preferences/#{File.basename(file)}") | |
| puts "copying files to #{u}\'s homedir." | |
| system "/usr/bin/rsync -rv #{file}/ #{get_homedir(u)}/Library/Preferences/#{File.basename(file)}/" |
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
| mount -uw / | |
| Then we need to load a couple of required system modules. DirectoryServices is only required if you want networking support. | |
| launchctl load /System/Library/LaunchDaemons/com.apple.notifyd.plist | |
| launchctl load /System/Library/LaunchDaemons/com.apple.kextd.plist | |
| launchctl load /System/Library/LaunchDaemons/com.apple.diskarbitrationd.plist | |
| launchctl start com.apple.diskarbitrationd | |
| launchctl load /System/Library/LaunchDaemon/com.apple.DirectoryServices.plist |
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
| Etc.passwd { |d| users[d.name] = d.uid if d.uid > 500 } |