Skip to content

Instantly share code, notes, and snippets.

View nigelr's full-sized avatar

Nigel Rausch nigelr

  • brisbane, australia
View GitHub Profile
@nigelr
nigelr / resize.sh
Last active December 10, 2015 17:18
Resizes TimeMachine sparesbundle maximum size and then locks the file
#!/bin/bash
# This script resizes a sparsebundle and locks the Info.plist to prevent timemachine resizing it.
# Usage
# resize.sh MacBook.sparsebundle 100g
# which resizes the sparse bundle to 100GB
echo "unlocking Info.plist"
SetFile -a l "${1%/}/Info.plist"
@nigelr
nigelr / song_spec.rb
Created January 14, 2013 00:14
Cheat
it "meme" do
url = "http://www2b.abc.net.au/votecentral/Client/PlaceVote.aspx?E=96&IX=0&IG=2"
doc = Nokogiri::HTML(open(url))
list = doc.at("div .IndexPageContent")
list = list.at("p")
list.css("span .artist").each do |item|
puts "#{item.text} - #{ item.next_element.next_element.text}"
end
@nigelr
nigelr / application_controller_spec.rb
Created January 15, 2013 06:23
application_controller_spec
require "spec_helper"
describe ApplicationController do
controller do
def index
render nothing: true
end
end
let(:user) { create(:user_agent) }
@nigelr
nigelr / selection.rb
Created May 10, 2013 01:55
special_report
def self.report
from_date = '20130401'
entities = Entity.unscoped.where('updated_at > ?', from_date).where('type in (?)', ['Contact', 'Deceased', 'Child']).where(culture_id: [Selection.culture_australian_aboriginal.id, Selection.culture_australian.id]).order(:site_id, :type)
p entities.length
media_items = MediaItem.unscoped.where('updated_at > ?', from_date)
p media_items.length
entities = Entity.unscoped.where('updated_at > ?', from_date).where('type in (?)', ['Contact', 'Deceased', 'Child']).where(referral_source_id: [Selection.referral_source_internet.id, Selection.referral_source_information_session.id]).order(:site_id, :type)
p entities.length
entities = Entity.unscoped.where('updated_at > ?', from_date).where('type in (?)', ['Contact', 'Deceased', 'Child']).where(relation_id: [Selection.relation_friend.id, Selection.relation_support_1.id]).order(:site_id, :type)
@nigelr
nigelr / select.html
Created May 16, 2013 02:03
sample HTML dropdown
<select name="ticket[priority_id]">
<option value="low">Low</option>
<option value="medium">Medium</option>
<option value="high">High</option>
</select>
create_table :priorities do |t|
t.string :name
t.boolean :default
t.boolean :archived
t.integer :position
t.timestamps
end
@nigelr
nigelr / show.html.erb
Created May 17, 2013 01:30
priority show
<b>Priority:</b>
<%= @ticket.priority.try(:name) %>
<b>Priority:</b>
<%= @ticket.priority.name %>
new.html.haml
%h1 New vendor
= render 'form'
= link_to 'Cancel', vendors_path, id: :cancel_new_vendor_link
---------------------
_form.html.haml
class Company < ActiveRecord::Base
has_many :contacts
class Contact < ActiveRecord::Base
belongs_to :company