Skip to content

Instantly share code, notes, and snippets.

View maricris-sn's full-sized avatar
😺

Maricris Nonato maricris-sn

😺
View GitHub Profile
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Collapsible Tree Example</title>
<style>
.node circle {
@maricris-sn
maricris-sn / ghost-sitemap.rb
Last active August 29, 2015 13:56
Walking a sticko-themed blog to create sitemap links
require 'nokogiri'
require 'open-uri'
home = 'http://your-blog.com'
sitemap_file = File.open('sitemap.xml', 'wb')
sitemap_file.puts('<?xml version="1.0" encoding="UTF-8"?>
<urlset
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@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
@maricris-sn
maricris-sn / gist:7051895
Last active December 25, 2015 22:39 — forked from jonathanmoore/gist:2640302
Modified original gist to correct Pinterest call to get shares (pins).

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

@maricris-sn
maricris-sn / streamzoo.rb
Created September 7, 2013 03:21
Fetch Streamzoo photos as thumbnails and display in your site
$ rails g model StreamzooPhotos url:string
##lib/tasks/streamzoo.rake
require 'hpricot'
require 'open-uri'
namespace :streamzoo do
desc "refresh thumbnails"
task :update_thumbs => :environment do
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
def smiley(str)
str = str.sub(':)', "<img src='/images/emoticons/1.gif' alt='smile'/>")
str = str.sub(':(', "<img src='/images/emoticons/2.gif' alt='sad'/>")
str = str.sub(';)', "<img src='/images/emoticons/3.gif' alt='wink'/>")
str = str.sub(':D', "<img src='/images/emoticons/4.gif' alt='grin'/>")
str = str.sub(':P', "<img src='/images/emoticons/5.gif' alt='tongue'/>")
end
## Think Geek Code (controller) [ruby]
def thinkGeek
require 'rss'
rss = RSS::Parser.parse(open('http://www.thinkgeek.com/xml/app/wishlist/id/').read, false)
@output = "" + rss.channel.description + ""
@output += ""
## Controller for Blackbook fix [ruby]
if (request.post?) or (!params["contact_type"].nil?)
#get contacts
@contacts = []
@type = params["contact_type"]
if ["gmail", "yahoo", "hotmail", "aol"].include?(params["contact_type"])
begin
username = "#{params["username"]}@#{params["contact_type"]}.com"
## a simple remarkable test script
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe Feedback, 'A Feedback instance' do
VALID = {
:name => "firstname lastname",
:email => "email.email@email.com",
:topic => "some topic",
:message => "some message"