Skip to content

Instantly share code, notes, and snippets.

JP Camara jpcamara

Block or report user

Report or block jpcamara

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
jpcamara / books.php
Created Dec 15, 2014
Simple Backbone.js Example
View books.php
header('Content-Type: application/json');
print json_encode(array(
'title' => 'The Miracle Morning',
'description' => 'Embrace the day',
'isbn' => 1234567,
'read' => false
jpcamara / unique.rb
Last active Aug 29, 2015
Unique Push Tokens
View unique.rb
by_token = {}
users.each do |user|
if by_token[user.push_token]
#if the token already exists, and the user_name is non-nil and non-empty, replace the entry
if !user.user_name.nil? && !user.user_name.strip.empty?
by_token[user.push_token] = user
by_token[user.push_token] = user
View api.proxy.server.js
var express = require('express'),
httpProxy = require('http-proxy'),
app = express();
var proxy = new httpProxy.RoutingProxy();
function apiProxy(host, port) {
return function(req, res, next) {
if(req.url.match(new RegExp('^\/api\/'))) {
proxy.proxyRequest(req, res, {host: host, port: port});
View application_controller.rb
# As used with CanCan and Devise
class ApplicationController < ActionController::Base
include ErrorResponseActions
rescue_from CanCan::AccessDenied, with: :authorization_error
rescue_from ActiveRecord::RecordNotFound, with: :resource_not_found
before_filter :authenticate!
You can’t perform that action at this time.