Skip to content

Instantly share code, notes, and snippets.

View j4rs's full-sized avatar

Jorge Rodriguez j4rs

View GitHub Profile
@j4rs
j4rs / rhyboows.js
Created June 12, 2012 19:52
Universal WebSocket with pub/sub and load balancing support...
// we made this simple library to not have to deal with
// complex implementations of websocket
var RhybooWS = {
error: "Your browser does not support native web sockets"
}
if ("WebSocket" in window) {
RhybooWS = function (options) {
@j4rs
j4rs / websocket_client.js
Created June 13, 2012 18:19
Native Web Socket Client
var ws = new WebSocket("ws://server:9876");
ws.onopen = function() { ... };
ws.onerror = function() { ... };
ws.onclose = function() { ... };
ws.onmessage = function(event) { event.data };
@j4rs
j4rs / client.js
Created July 9, 2012 22:26
NodeJS GCM Server to send message to android devices...
var GCM = require('./gcm');
var gcm = new GCM(<YOUR GOOGLE API KEY>); // https://code.google.com/apis/console
// create the message
var msg = {
registration_ids: [token], // this is the device token (phone)
collapse_key: "your_collapse_key", // http://developer.android.com/guide/google/gcm/gcm.html#send-msg
time_to_live: 180, // just 30 minutes
data: {
DecentExposure::ActiveRecordStrategy#plural? delegated to inflector.plural?, but inflector is nil: #<DecentExposure::ActiveRecordWithEagerAttributesStrategy:0x007fba64bba870 @controller=#<HomeController:0x007fba6b051338 @_routes=nil, @_action_has_layout=true, @_headers={"Content-Type"=>"text/html"}, @_status=200, @_request=#<ActionDispatch::Request:0x007fba6b051220 @env={"REMOTE_ADDR"=>"127.0.0.1", "REQUEST_METHOD"=>"GET", "REQUEST_PATH"=>"/", "PATH_INFO"=>"/", "REQUEST_URI"=>"/", "SERVER_PROTOCOL"=>"HTTP/1.1", "HTTP_VERSION"=>"HTTP/1.1", "HTTP_HOST"=>"localhost:3000", "HTTP_CONNECTION"=>"keep-alive", "HTTP_CACHE_CONTROL"=>"max-age=0", "HTTP_ACCEPT"=>"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", "HTTP_USER_AGENT"=>"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.66 Safari/537.36", "HTTP_ACCEPT_ENCODING"=>"gzip,deflate,sdch", "HTTP_ACCEPT_LANGUAGE"=>"es-ES,es;q=0.8", "HTTP_COOKIE"=>"request_method=GET; _ixclu_session=Nmp6THR
@j4rs
j4rs / Rakefile
Created January 22, 2014 15:23
Change status bar appearance in RubyMotion.
# add next to your Rakefile
app.info_plist['UIViewControllerBasedStatusBarAppearance'] = false
app.info_plist['UIStatusBarStyle'] = 'UIStatusBarStyleLightContent'
@j4rs
j4rs / instagram.rb
Last active August 5, 2020 20:16
Integrating Instagram(OAuth) using RubyMotion, Promotion, AFMotion and some SugarCube
class Instagram < PM::WebScreen
title "Instagram"
CLIENT_ID = 'your client id'
REDIRECT_URI = 'http://your.domain.com/auth/instagram/callback'
FAILURE_URL = 'http://your.domain.com/auth/failure'
AUTH_URI = "https://instagram.com/oauth/authorize/?client_id=#{CLIENT_ID}&redirect_uri=#{REDIRECT_URI}&response_type=token"
class << self
def api
@j4rs
j4rs / InstagramOAuthActivity.java
Last active July 10, 2022 11:03
Android activity to authenticate using Instagram client side auth.
/**
*
*/
package com.bwuit.app.activities;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
@j4rs
j4rs / ApplicationController.rb
Last active August 6, 2019 16:37
Signal Heroku - from your codebase - to restart the dynos.
# This snippet can be included in ApplicationController.rb
if Rails.env.production?
rescue_from StandardError do |error|
# if it is an unrecoverable error, send a signal to heroku
# to restart the infrastructure
if error.message =~ /deadlock; recursive locking/
hclient = PlatformAPI.connect_oauth(ENV["HEROKU_API_TOKEN"])
heroku_app, dyno = "name-of-your-app", hclient.dyno
# avoid sending the signal more than once
if dyno.list(heroku_app).dig(0, "state") === "up"
export PS1="\[\033[36m\]\u:\[\033[32m\]\w\[\033[33m\]\$(markup_git_branch \$(parse_git_branch))\[\033[00m\]$ "
parse_git_branch() {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* (*\([^)]*\))*/\1/'
}
markup_git_branch() {
if [[ -n $@ ]]; then
if [[ -z $(git status --porcelain 2> /dev/null) ]]; then
echo -e ":\001\033[32m\002($@)\001\033[0m\002"
@j4rs
j4rs / review_app_setup.rb
Last active March 10, 2020 17:29
Script to setup custom domains for review apps in Get on Board.
task :review_app_setup do
GOB_DEV_DOMAIN = #<our-custom-domain-for-dev>
require "dnsimple"
require "platform-api"
heroku_app_name = ENV["HEROKU_APP_NAME"]
dnsimple_account_id = ENV["DNSIMPLE_DEV_ACCOUNT_ID"]
type = { type: 'CNAME' }