Skip to content

Instantly share code, notes, and snippets.

View angelbotto's full-sized avatar
🏃

Angel Celis Botto angelbotto

🏃
View GitHub Profile
@angelbotto
angelbotto / pre-commit
Created September 12, 2015 22:32
Run all test before commits :)
#!/bin/bash
git stash -q --keep-index
echo -e "👮 Wait, run all test before commit!\n"
FAILS=`rspec --format progress | grep -E '(\d*) failure(s?)' -o | awk '{print $1}'`
git stash pop -q
if [ $FAILS -ne 0 ]; then

With Heroku's JRuby support you may have already seen that you can run TorqueBox Lite on Heroku. But, that only gives you the web features of TorqueBox. What about scheduled jobs, backgroundable, messaging, services, and caching?

With a small amount of extra work, you can now run the full TorqueBox (minus STOMP support and clustering) on Heroku as well! I've successfully deployed several test applications, including the example Rails application from our Getting Started Guide which has a scheduled job, a service, and uses backgroundable and messaging.

This example uses TorqueBox 3.0.2, but the instructions may work with other TorqueBox versions.

Steps Required

  1. Create a JRuby application on Heroku, or convert an existing application to JRuby. Make sure your application works on JRuby on Heroku before throwing TorqueBox into the mix.
  2. Add th
@angelbotto
angelbotto / neo.nginx.conf
Created February 6, 2015 00:18
Configuracion para proxy con seguridad de auth
server {
listen 80;
server_name neo.cheersapp.io;
access_log /var/log/nginx/neo4j.access.log;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@angelbotto
angelbotto / init-deb.sh
Created February 5, 2015 19:35
nginx sh
#! /bin/sh
## Move the script to the init.d directory & make executable
#sudo mv init-deb.sh /etc/init.d/nginx
#sudo chmod +x /etc/init.d/nginx
## Add nginx to the system startup
#sudo /usr/sbin/update-rc.d -f nginx defaults
PATH=/opt/nginx/sbin:/sbin:/bin:/usr/sbin:/usr/bin
@angelbotto
angelbotto / nginx.conf
Created February 5, 2015 19:32
Cheers passenger recipe
#user nobody;
worker_processes 1;
events {
worker_connections 1024;
}
http {
passenger_root /usr/local/rvm/gems/jruby-1.7.18@cheers/gems/passenger-4.0.58;
@angelbotto
angelbotto / vineapi.md
Created October 20, 2014 21:59
vine api

Vine.app API Reference

The one and only public documentation of Vine.app 1.0.3

Common headers

user-agent: com.vine.iphone/1.0.3 (unknown, iPhone OS 6.1.0, iPhone, Scale/2.000000)
vine-session-id: <userid>-1231ed86-80a0-4f07-9389-b03199690f73
accept-language: en, sv, fr, de, ja, nl, it, es, pt, pt-PT, da, fi, nb, ko, zh-Hans, zh-Hant, ru, pl, tr, uk, ar, hr, cs, el, he, ro, sk, th, id, ms, en-GB, ca, hu, vi, en-us;q=0.8
//Invite all you friends in facebook :)
var elements = document.getElementsByClassName('uiButton');
for(var i=0;i<=elements.length;i++) { console.log(elements[i].click()); }
$.fn.textkolor = function(str) {
var hash = 0;
for (var i = 0; i < str.length; i++) {
hash = str.charCodeAt(i) + ((hash << 5) - hash);
}
var colour="#";
for (var j = 0; j < 3; j++) {
var value = (hash >> (j * 8)) & 0xFF; colour += ('00' + value.toString(16)).substr(-2);
$(element).textkolor("Something string");

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