Skip to content

Instantly share code, notes, and snippets.

View dougireton's full-sized avatar

Doug Ireton dougireton

View GitHub Profile
#djDebug *{color:#888;float:none;margin:0;padding:0;position:static;text-align:left;}
#djDebug code{color:#333;}
#djDebug h3 code{color:#fff;}
#djDebug a{color:#ccc;}
#djDebug a:hover{color:#aaa;}
#djDebugToolbar{background:#333;height:30px;z-index:100000000;border-bottom:2px solid #222;position:absolute;top:0;left:0;right:0;}
#djDebugToolbarHandle{background:#555;height:30px;z-index:100000000;position:absolute;top:0;left:0;right:0;width:16px;}
#djDebugToolbarHandle ul li{padding:3px 0px 0px 3px;}
#djDebugToolbarHandle ul li a{font-size:16px;font-weight:bold;}
#djDebugToolbar ul{margin:0;padding:0;list-style:none;}
<%= flash.each do |key, msg| %>
<%= content_tag :div, msg, :class => key %>
<% end %>
class ApplicationController < ActionController::Base
protect_from_forgery
require 'rack/mobile-detect'
use Rack::MobileDetect
# set the Rails request.format (MIME type) to :iphone for iPhone/iPod Touch
# This allows us to serve separate layouts/views for iPhone/iPod
case request.headers['X_MOBILE_DEVICE']
@dougireton
dougireton / gist:2023820
Created March 12, 2012 18:32
Chef cookbook
# stop and delete the default site
iis_site 'Default Web Site' do
action [:stop, :delete]
end
# create and start a new site that maps to
# the physical location C:\inetpub\wwwroot\testfu
iis_site 'Testfu Site' do
protocol :http
port 80
@dougireton
dougireton / chefspec_windows_rights_attributes
Created October 1, 2012 20:56
Chefspec doesn't seem to support Windows 'rights' attributes
When I run this spec, I get errors saying undefined method `rights' for Chef::Resource::CookbookFile since I'm using the [Windows 'rights' attribute](http://wiki.opscode.com/display/chef/Improved+Windows+File+Security)
Does chefspec support the Windows 'rights' attribute?
```ruby
require 'chefspec'
describe 'hosts_file::windows' do
@dougireton
dougireton / pre-commit
Created December 11, 2012 05:22
git pre-commit hook for linting Chef cookbooks
#!/usr/bin/env ruby
# check for whitespace errors
git_ws_check = `git diff-index --check --cached HEAD --`
unless $?.success?
puts git_ws_check
exit 1
end
COOKBOOK_PATH = File.split `git rev-parse --show-toplevel`
@dougireton
dougireton / chef.vim
Created February 8, 2013 06:25
(Broken) chef Syntastic syntax checker
function! SyntaxCheckers_chef_IsAvailable()
return executable('foodcritic')
endfunction
function! SyntaxCheckers_chef_GetLocList()
" let exe = expand(g:syntastic_ruby_exec)
" if !has('win32')
" let exe = 'RUBYOPT= ' . exe
" endif
# https://github.com/moserke/diskpart-cookbook
diskpart_partition "create_#{disk[:letter]}:/" do
disk_number disk[:number]
align disk[:align]
letter disk[:letter]
action :create
end
diskpart_partition "format_#{disk[:letter]}:/" do
chef_gem "chef-vault"
require 'chef-vault'
# given a 'passwords' data bag
vault = ChefVault.new("passwords")
# get the 'Administrator' data bag item
user = vault.user("Administrator")
Ohai::Config[:disabled_plugins] = [
# The following plugins are disabled as they are either not needed,
# have poor performance, or do not apply to the Windows configuration
# we use.
"c", "cloud", "ec2", "rackspace", "eucalyptus", "command", "dmi",
"dmi_common", "erlang", "groovy", "ip_scopes", "java", "keys",
"lua", "mono", "network_listeners", "passwd", "perl",
"php", "python", "ssh_host_key", "uptime", "virtualization",
"windows::virtualization", "windows::kernel_devices"