View missing_keys.rb
This file contains 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
# 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 |
View missing_keys_controller.rb
This file contains 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
# 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.html.erb
This file contains 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
# 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 gist:1325096
This file contains 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
# Outside screen | |
screen # Start screen. | |
screen -ls # List sessions. | |
screen -r id # Reattach to session. | |
screen -h # Help. | |
# Inside screen | |
Ctrl+a " # List sessions | |
Ctrl+a d # Detach session. | |
Ctrl+a ? # Help. |
View gtalk-jabber-subscribe.rb
This file contains 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
# https://github.com/ln/xmpp4r | |
# gem install xmpp4r | |
require 'xmpp4r' | |
email = ADD_EMAIL | |
password = ADD_PASSWORD | |
friends_email = ADD_EMAIL | |
client = Jabber::Client::new(Jabber::JID::new(email)) | |
client.connect("talk.google.com") | |
client.auth(password) | |
client.send(Jabber::Presence.new.set_type(:subscribe).set_to(friends_email)) |
View salesforce-territories.txt
This file contains 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
# 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", |
View salesforce-report-object.rb
This file contains 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
# 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 |
View youtube-api-v3.rb
This file contains 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
# 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 salesforce-opportunity-field-release-name.txt
This file contains 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
# 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 */ |
View salesforce-opportunity-field-days-since-release.txt
This file contains 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
# 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 */ |
OlderNewer