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 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 git.log.with.lines.changed.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
# See colored 'git log' with lines changes in Terminal on Mac | |
# => * 1234567 - 2001-01-01 - NNNNN - description <user> | |
# Based on http://www.jukie.net/bart/blog/pimping-out-git-log | |
# git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative" | |
# To install as 'gl' alias (not overriding 'git log'): | |
# 1) save this as ~/.gitlog.rb | |
# 2) add to ~/.bash_profile: 'alias gl="ruby ~/.gitlog.rb | more -r"' |
View s3-delete-bucket.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
#!/usr/bin/env ruby | |
# s3-delete-bucket.rb | |
# Fog-based script for deleting large Amazon AWS S3 buckets (~100 files/second) | |
# Forked from this excellent script: https://github.com/SFEley/s3nuke | |
require 'rubygems' | |
require 'thread' | |
require 'fog' |
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 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 how-to-disable-multi-touch-on-apple-magic-mouse.bash
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
# 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 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", |
OlderNewer