Skip to content

Instantly share code, notes, and snippets.

package main
import (
"database/sql"
"errors"
"fmt"
_ "github.com/bmizerany/pq"
"os"
"regexp"
"strings"
@rogeriomarques
rogeriomarques / .psqlrc
Last active August 29, 2015 14:12 — forked from jaytaylor/.psqlrc
-- Found at:
-- http://www.if-not-true-then-false.com/2009/postgresql-psql-psqlrc-tips-and-tricks/
-- http://opensourcedbms.com/dbms/psqlrc-psql-startup-file-for-postgres/
\set QUIET ON
\pset pager always
\pset null 'NULL'

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

@rogeriomarques
rogeriomarques / sharetabs.rb
Last active September 6, 2015 21:13 — forked from ttscoff/sharetabs.rb
Browser tabs to Dropbox HTML list
# Share Tab Collection 1.0 | Brett Terpstra 2015 <http://brettterpstra.com>
USERID = 'XXXXX'
require 'shellwords'
require 'fileutils'
def class_exists?(class_name)
klass = Module.const_get(class_name)
@rogeriomarques
rogeriomarques / main.go
Last active September 14, 2015 20:12
Simple pool worker example
package main
import (
"fmt"
"math"
)
func isPrime(n float64) bool {
max := int(math.Sqrt(n))
for i := 2; i < max; i++ {
@rogeriomarques
rogeriomarques / unstar.js
Last active September 18, 2015 04:19
Unstar repos on Github
$('ul.repo-list').find('button.btn').filter('[title^="Unstar"]').click()

Workflows (States) in Django

I'm going to cover a simple, but effective, utility for managing state and transitions (aka workflow). We often need to store the state (status) of a model and it should only be in one state at a time.

Common Software Uses

  • Publishing (Draft->Approved->Published->Expired->Deleted)
@rogeriomarques
rogeriomarques / pbic_pricing_scraper.py
Created October 23, 2015 19:54 — forked from rdempsey/pbic_pricing_scraper.py
A simple Python web scraper to obtain pricing data from the Packt website
#!/usr/bin/env python
# encoding: utf-8
"""
pbic_pricing_scraper.py
Created by Robert Dempsey on 09-29-2015
Copyright (c) 2015 Robert Dempsey. All rights reserved.
Utility script to obtain the price information for my book: Python Business Intelligence Cookbook
http://pythonbicookbook.com/
"""
@rogeriomarques
rogeriomarques / gheap.go
Created November 1, 2015 13:38 — forked from Komosa/gheap.go
Golang doesn't need neither runtime type-assertion nor code generation to provide generics
// this package is mostly copy-pasted from golang's std container/heap
// I changed Interface, Pop and Push in order to get rid of type assertions
// usage can be found in test file, benchmarks show that we can get about 27% of speedup for 1000 elems, or 10% for 10M elems (tested on go1.4)
package gheap
type Interface interface {
Len() int
Less(i, j int) bool
Swap(i, j int)
}
@rogeriomarques
rogeriomarques / index.html
Created August 26, 2016 01:50 — forked from anonymous/index.html
Pure CSS Drop-down Responsive
<link rel="stylesheet" href="//cdn.jsdelivr.net/fontawesome/4.2.0/css/font-awesome.min.css" />
<link href='http://fonts.googleapis.com/css?family=Slabo+27px|Open+Sans' rel='stylesheet' type='text/css'>
<nav>
<ul id="header">
<a href="#" id="brand">
<li>
Pure CSS Dropdown
</li>
</a>
<label id="trigger2" for="x7"><i class="fa fa-bars"></i></label>