Skip to content

Instantly share code, notes, and snippets.

View jbrowning's full-sized avatar

Jeff Browning jbrowning

View GitHub Profile
@jbrowning
jbrowning / Sidecar.scpt
Created December 1, 2020 14:22
AppleScript to toggle Sidecar in macOS 11 Big Sur
property iPadName : "The iPad Name"
activate application "SystemUIServer"
tell application "System Events"
tell application process "ControlCenter"
set displayMenu to (menu bar item 1 of menu bar 1 whose title contains "Display")
click displayMenu
delay 0.1
click checkbox iPadName of scroll area 1 of group 1 of window "Control Center"
click displayMenu
@jbrowning
jbrowning / Gemfile
Created June 27, 2014 01:59
ActiveRecord rename index error for MariaDB 10
source 'https://rubygems.org'
gem 'activerecord', '4.1.2'
gem 'mysql2'
@jbrowning
jbrowning / some_spec.coffee
Last active April 25, 2016 23:38
Angular & CoffeeScript: Error: [ng:areq] Argument 'fn' is not a function, got Object
# The $provide service is used to override an injected dependency
# Bad - results in Error: [ng:areq] Argument 'fn' is not a function, got Object
module 'someModule', ($provide) ->
$provide.value "SomeService", SomeMock
# Good
module 'someModule', ($provide) ->
$provide.value "SomeService", SomeMock
null
@jbrowning
jbrowning / parallel_assignment_demo.rb
Created November 1, 2013 16:41
Demo of array/block parallel assignment
def parallel_assignment_test(array, &block)
block.call array
end
animals = ["pig", "cow", "dog"]
# One
parallel_assignment_test(animals) { |one, two, three|
puts "One: #{one}"
puts "-------"
@jbrowning
jbrowning / user.rb
Created December 26, 2011 16:12
A Devise user#update_with_password which only requires the current password if changing the password
def update_with_password(params={})
result = nil
current_password = params.delete(:current_password)
if params[:password].blank?
params.delete(:password)
params.delete(:password_confirmation) if params[:password_confirmation].blank?
result = self.update_without_password(params)
else
result = if valid_password?(current_password)