Skip to content

Instantly share code, notes, and snippets.

@maricris-sn
maricris-sn / social_utils.rb
Created October 21, 2013 12:11
This is a library that pulls in shares from Facebook, Twitter, Google Plus, Pinterest, LinkedIn and StumbleUpon. If you need a more elaborate breakdown for Facebook related data, please look at: http://stackoverflow.com/questions/6137414/how-to-fetch-facebook-likes-share-comments-count-from-an-article/7707702#7707702 Inspired by https://gist.git…
require 'open-uri'
module SocialUtils
def self.get_facebook_shares(url)
f = open("http://graph.facebook.com/?id=#{url}")
response = f.read()
shares = JSON.parse(response)['shares']
return shares.nil? ? 0 : JSON.parse(response)['shares']
end
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active April 28, 2025 00:02
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@courtenay
courtenay / gist:4498771
Last active December 10, 2015 21:59
MONKEY PATCH: no "xml type=yaml" in your .to_xml dump of activerecord objects
# RAILS 2.3.15
#
# Since <tag type="yaml"> was removed from rails' xml parsing,
# but not from its to_xml method, rails can't talk to an API
# generated by rails, if you have serialized attributes.
# This can be put in config/initializers and you should probably
# upgrade to rails 3 already. Ugh.
# Three parts:
@caged
caged / scale.rb
Created November 22, 2012 04:04
Linear scale interpolation in Ruby based on d3.js's implementation
# Returns a lambda used to determine what number is at t in the range of a and b
#
# interpolate_number(0, 500).call(0.5) # 250
# interpolate_number(0, 500).call(1) # 500
#
def interpolate_number(a, b)
a = a.to_f
b = b.to_f
b -= a
lambda { |t| a + b * t }
@futuremill-ltd
futuremill-ltd / gist:2318876
Created April 6, 2012 11:00
Building Ruby 1.9.3 package for Debian Squeeze
# From a fresh install of squeeze
apt-get install ruby rubygems # Need ruby to use fpm
gem1.8 install fpm --no-ri --no-rdoc
apt-get install build-essential openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev ncurses-dev libyaml-dev
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz
tar -zxvf ruby-1.9.3-p125.tar.gz
cd ruby-1.9.3-p125
rm -rf /tmp/ruby193