Skip to content

Instantly share code, notes, and snippets.

View orangeeli's full-sized avatar

Eliseu Martinho orangeeli

  • https://fooji.com
  • Lisbon
View GitHub Profile
var vary = require(‘vary’);
var vary = require(‘cloud/lib/vary.js’);
var cors = require('cloud/lib/cors.js');
app.use(cors());
app.options('*', cors());
@orangeeli
orangeeli / include-relation.js
Created December 25, 2015 23:02
A small code snippet that shows how to return items from a relation since include is only for pointer columns (parse.com javascript SDK)
function get(req, res) {
var Foo,
query,
foos;
Foo = Parse.Object.extend("Foo", {}, {});
query = new Parse.Query(Foo);
foos = [];
@orangeeli
orangeeli / parse-handle-error.js
Created May 16, 2016 18:47
A small code snippet of the error handling function for the parse promise failure.
function handleError (res, message) {
return function (error) {
res.json(`${message} ${JSON.stringify(error)}`);
}
};
@orangeeli
orangeeli / rails.init.sh
Last active May 26, 2016 06:24
Starting a rails 5 api app
#!/bin/bash
# --api: flag to create an api only rails app
# --skip-active-record: Removes active record support
# --skip-sprockets: Removes Asset compilation support http://guides.rubyonrails.org/asset_pipeline.html
rails new api-example --api --skip-active-record --skip-sprockets
@orangeeli
orangeeli / rails.mongoid.config.sh
Created May 24, 2016 11:06
Rails config mongoid command
#!/bin/bash
rails g mongoid:config
@orangeeli
orangeeli / rvm.change.gemsets.sh
Created May 28, 2016 07:28
Just a healthy reminder of the most used rvm commands
#!/bin/bash
# Just a healthy reminder of the most used rvm commands.
# Just uncomment those you might want to use
# change gemset
# rvm use ruby-version@gemset-name
# create and change gemset
# rvm use ruby-version@gemset-name --create
@orangeeli
orangeeli / routes.rb
Last active July 15, 2016 16:45
A routes API example
scope '/api', defaults: {format: 'json'} do
scope '/v1' do
scope '/gorilla' do
get '/' => 'api/v1/gorilla#index'
end
end
end
@orangeeli
orangeeli / gorilla_controller.rb
Last active July 15, 2016 16:51
The person controller in an API context
module Api
module V1
class GorillaController < ApplicationController
def index
@gorillas = Gorilla.all
render json: {message: 'We are not extinct. Just well hidden.'}
end
end
end
end