Skip to content

Instantly share code, notes, and snippets.

bdunagan / gtalk-jabber-subscribe.rb
Created October 29, 2011 15:25
Invite users from Google Talk using Ruby and Jabber
# gem install xmpp4r
require 'xmpp4r'
email = ADD_EMAIL
password = ADD_PASSWORD
friends_email = ADD_EMAIL
client = Jabber::Client::new(Jabber::JID::new(email))
bdunagan / gist:1325096
Created October 29, 2011 21:05
screen commands
# 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.
bdunagan / git.log.with.lines.changed.rb
Created November 13, 2011 19:05
git log with colors and lines changed
# See colored 'git log' with lines changes in Terminal on Mac
# => * 1234567 - 2001-01-01 - NNNNN - description <user>
# Based on
# 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"'
bdunagan / s3-delete-bucket.rb
Created November 21, 2011 17:23
s3-delete-bucket.rb: quickly delete large AWS S3 buckets using fog
#!/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:
require 'rubygems'
require 'thread'
require 'fog'
# models/missing_keys.rb
class MissingKeys
def initialize(backend)
@backend = backend
# Returns an array with all keys from all locales
# routes.rb
get '/missing_keys', :to => 'home#missing_keys'
# home_controller.rb
def missing_keys
finder =
@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
# views/home/missing_keys.html.erb
<li><%= link_to "Unlocalized", "#unlocalized" %></li>
<li><%= link_to "Localized", "#localized" %></li>
<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| %>
# 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
# Here are the steps using "curl" that matches the Ruby code below:
# Get channel information.
# curl --referer "YOUR_REFERER" ",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.
bdunagan / how-to-disable-multi-touch-on-apple-magic-mouse.bash
Created December 5, 2016 21:08
Terminal: How to Disable Multi-Touch on Apple Magic Mouse
# Launch Terminal.
defaults write MouseMomentumScroll -bool NO
defaults write MouseHorizontalScroll -bool NO
defaults write MouseVerticalScroll -bool NO
defaults write MouseMomentumScroll -bool NO
defaults write MouseHorizontalScroll -bool NO
defaults write MouseVerticalScroll -bool NO
# Restart the computer.
bdunagan / salesforce-territories.txt
Created December 25, 2016 17:13
Salesforce: How to Set Up Sales Territories with a Read-Only Custom Formula
# Salesforce Custom Formula for Worldwide Sales Territories
IF(ISBLANK(Country),"North America",
IF(CONTAINS("US:CA:PR",Country),"North America",