Skip to content

Instantly share code, notes, and snippets.

Brian Dunagan bdunagan

Block or report user

Report or block bdunagan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@bdunagan
bdunagan / salesforce-opportunity-field-days-since-release.txt
Last active Mar 18, 2017
Salesforce: Add an Opportunity formula field for "Days since release"
View salesforce-opportunity-field-days-since-release.txt
# Salesforce Custom Formula for "Days Since Release" based on Opportunity CloseDate
IF(
/* 2012 - Win 8, Mac 10 */
AND(
CloseDate >= DATE(2012,11,6),
CloseDate < DATE(2014,3,4)
),
CloseDate - DATE(2012,11,6),
IF(
/* 2014 - Win 9, Mac 11 */
@bdunagan
bdunagan / salesforce-opportunity-field-release-name.txt
Last active Mar 18, 2017
Salesforce: Add an Opportunity formula field for "Release Name"
View salesforce-opportunity-field-release-name.txt
# Salesforce Custom Formula for Release Name based on Opportunity CloseDate
IF(
/* 2012 - Win 8, Mac 10 */
AND(
CloseDate >= DATE(2012,11,6),
CloseDate < DATE(2014,3,4)
),
"2012 - Win 8, Mac 10",
IF(
/* 2014 - Win 9, Mac 11 */
@bdunagan
bdunagan / salesforce-report-object.rb
Created Jan 29, 2017
Salesforce: Create a Report object using Analytics API
View salesforce-report-object.rb
# Instantiate Salesforce Report using Restforce.
# Requires Salesforce Analytics API with v29.
# Usage
# report = Restforce::Report.find("1234567890")
# puts report.name
# puts report.filters
# puts report.rows
module Restforce
@bdunagan
bdunagan / salesforce-timezones.txt
Created Dec 29, 2016
Salesforce: How to Set Up US Timezones with a Custom Formula
View salesforce-timezones.txt
# Salesforce Custom Formula for US Timezones based on Billing State
# Note there are 51 because DC counts.
CASE(BillingState,
"HI","US-PST",
"AK","US-PST",
"WA","US-PST",
"OR","US-PST",
"CA","US-PST",
"NV","US-PST",
"MT","US-MST",
@bdunagan
bdunagan / salesforce-territories.txt
Created Dec 25, 2016
Salesforce: How to Set Up Sales Territories with a Read-Only Custom Formula
View salesforce-territories.txt
# Salesforce Custom Formula for Worldwide Sales Territories
IF(ISBLANK(Country),"North America",
IF(CONTAINS("US:CA:PR",Country),"North America",
IF(CONTAINS("DE:AT:CH",Country),"DACH",
IF(CONTAINS("FR:MC:NC:PF:GP:RE:MQ:GY",Country),"France",
IF(CONTAINS("ES",Country),"Spain",
IF(CONTAINS("PT",Country),"Portugal",
IF(CONTAINS("IT",Country),"Italy",
IF(CONTAINS("AG:AI:AN:AR:AW:BB:BM:BO:BR:BS:BZ:CL:CO:CR:CU:DM:DO:EC:FK:GD:GL:GT:GY:HN:HT:JM:KN:KY:LC:MS:MX:NI:PA:PE:PM:PY:SR:SV:TC:TT:UY:VC:VE:VG:VI",Country),"Latam",
IF(CONTAINS("AS:AU:CK:CN:CX:FJ:FM:GU:HK:ID:JP:KH:KI:KP:KR:LA:MH:MM:MN:MO:MP:MY:NF:NR:NU:NZ:PG:PH:PN:PW:SB:SG:TH:TK:TO:TV:TW:VN:VU:WF:WS",Country),"APAC",
@bdunagan
bdunagan / how-to-disable-multi-touch-on-apple-magic-mouse.bash
Created Dec 5, 2016
Terminal: How to Disable Multi-Touch on Apple Magic Mouse
View how-to-disable-multi-touch-on-apple-magic-mouse.bash
# Launch Terminal.
defaults write com.apple.AppleMultitouchMouse MouseMomentumScroll -bool NO
defaults write com.apple.AppleMultitouchMouse MouseHorizontalScroll -bool NO
defaults write com.apple.AppleMultitouchMouse MouseVerticalScroll -bool NO
defaults write com.apple.driver.AppleBluetoothMultitouchMouse MouseMomentumScroll -bool NO
defaults write com.apple.driver.AppleBluetoothMultitouchMouse MouseHorizontalScroll -bool NO
defaults write com.apple.driver.AppleBluetoothMultitouchMouse MouseVerticalScroll -bool NO
# Restart the computer.
View youtube-api-v3.rb
# List of all uploaded videos and playlists on a YouTube Channel
# Note that YouTube API v3 requires a key. Create a browser API key with a referer at https://console.developers.google.com.
#
# Here are the steps using "curl" that matches the Ruby code below:
#
# Get channel information.
# curl --referer "YOUR_REFERER" "https://www.googleapis.com/youtube/v3/channels?part=snippet,contentDetails,statistics,status&maxResults=50&forUsername=YOUR_USERNAME&key=YOUR_KEY"
# Find "Uploads" playlist ID at items => contentDetails => relatedPlaylists => uploads.
# Find Channel ID at items => id.
#
View missing_keys.html.erb
# views/home/missing_keys.html.erb
<h1>Localization</h1>
<ul>
<li><%= link_to "Unlocalized", "#unlocalized" %></li>
<li><%= link_to "Localized", "#localized" %></li>
</ul>
<h2 id="unlocalized">Unlocalized: <%= @missing_keys.count %> missing out of <%= @missing_keys.count + @found_keys.count %></h2>
<ul style="list-style:none; line-height:22px; margin-left:-40px">
<% @missing_keys.each do |key, value| %>
View missing_keys_controller.rb
# routes.rb
get '/missing_keys', :to => 'home#missing_keys'
# home_controller.rb
def missing_keys
finder = MissingKeys.new(I18n.backend)
@all_keys = finder.all_keys
@missing_keys = finder.find_missing_keys
@found_keys = @all_keys.collect { |key| key unless @missing_keys.keys.include?(key) }.compact
View missing_keys.rb
# models/missing_keys.rb
class MissingKeys
def initialize(backend)
@backend = backend
self.load_config
self.load_translations
end
# Returns an array with all keys from all locales
You can’t perform that action at this time.