Skip to content

Instantly share code, notes, and snippets.

View raulmangolin's full-sized avatar
🐴
always from home

Raul Mangolin raulmangolin

🐴
always from home
View GitHub Profile
@raulmangolin
raulmangolin / Run in LOCAL terminal...
Created December 8, 2016 00:00 — forked from jswartwood/Run in LOCAL terminal...
Automatic Git deploys on Dreamhost
# Replace any brackets with real values
# Try to ssh in to DREAMHOST (ensure it no longer asks for a PW); you may want to restart Terminal
ssh [user]@[host]
cd ~
mkdir [mydomain_com].git
cd [mydomain_com].git
git init --bare
vi hooks/post-receive
# Enter the code from the "post-receive" file (in this gist); save + quit
@raulmangolin
raulmangolin / json.js
Last active July 29, 2016 19:51
Get Facebook Likes On Page
var access_token = ''; //Please, set an access token
var activeAjaxConnections = 1;
var likes = {};
function parseLikes() {
var names = document.getElementsByClassName('fcb');
activeAjaxConnections = names.length;
for(var i = 0; i < names.length; i++){
var a = names[i].childNodes[0];

Keybase proof

I hereby claim:

  • I am raulmangolin on github.
  • I am raulmangolin (https://keybase.io/raulmangolin) on keybase.
  • I have a public key ASD030J4Lpp3NFDtVWFOLpwp4C5hLNBpcGMt1DzTLkehwgo

To claim this, I am signing this object:

@raulmangolin
raulmangolin / get-social-shares
Created July 6, 2016 19:03 — forked from ihorvorotnov/get-social-shares
Get number of shares from social platforms
Facebook*:
https://api.facebook.com/method/links.getStats?urls=%%URL%%&format=json
+ works, returns shares, likes, comments and total
Twitter:
http://urls.api.twitter.com/1/urls/count.json?url=%%URL%%&callback=twttr.receiveCount
+ v1 API but still works
Reddit:
http://buttons.reddit.com/button_info.json?url=%%URL%%
@raulmangolin
raulmangolin / safadao.py
Last active December 6, 2015 20:29
Descobre seu nivel de anjo e safadeza de acordo com o wesley_safadao
from decimal import *
def wesley_safadao(dia, mes, ano):
ano = ano % 100;
safadeza = sum(range(mes + 1)) + (Decimal(ano) / 100) * (50 - dia)
anjo = 100 - safadeza
print "Safadeza = {:.2f}".format(safadeza)
print "Anjo = {:.2f}".format(anjo)
wesley_safadao(23, 8, 1990);
@raulmangolin
raulmangolin / gist:88726c477f2ba18675c3
Created November 10, 2015 17:55 — forked from jonathanmoore/gist:2640302
Get the share counts from various APIs

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

if( /Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent) ) {
var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
var is_iphone = navigator.userAgent.toLowerCase().indexOf('iphone') > -1;
var is_ipod = navigator.userAgent.toLowerCase().indexOf('ipod') > -1;
var ww = ( window.screen.availHeight > window.screen.availWidth ) ? window.screen.availWidth : window.screen.availHeight; //get proper width
var mw = 480; // min width of site
var ratio = ww / mw; //calculate ratio
if( ww < mw ){ //smaller than minimum size
@raulmangolin
raulmangolin / gist:65c58fe8cad27a105f40
Last active August 29, 2015 14:17
List all files from a dir
<?php
$path = "uploads/";
$dir = dir($path);
echo "<p>List all files from '<strong>{$path}</strong>':</p>";
while ($file = $dir->read()) {
echo "<p><a href='" . $path . $file . "'>" . $file . "</a></p>";
}
$dir->close();
<?php
// Open the XML
$handle = fopen('file.xml', 'r');
// Get the nodestring incrementally from the xml file by defining a callback
// In this case using a anon function.
nodeStringFromXMLFile($handle, '<item>', '</item>', function($nodeText){
// Transform the XMLString into an array and
print_r(getArrayFromXMLString($nodeText));
#!/bin/bash
if [ $# -ne 0 ]; then
project_name=${1}
else
echo "usage: makecake.sh [project_name]"
exit
fi
if [ -e ${project_name} ]; then