Skip to content

Instantly share code, notes, and snippets.

View julsfelic's full-sized avatar

Julian Feliciano julsfelic

View GitHub Profile
@julsfelic
julsfelic / base_controller.rb
Created May 27, 2016 23:29 — forked from dhoelzgen/base_controller.rb
CORS in Rails 4 APIs
class API::V1::BaseController < ApplicationController
skip_before_filter :verify_authenticity_token
before_filter :cors_preflight_check
after_filter :cors_set_access_control_headers
def cors_set_access_control_headers
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Allow-Methods'] = 'POST, GET, PUT, DELETE, OPTIONS'

Step One: Watch Sorting Algorithms in JavaScript DONE

Step Two: Fork this gist. ALSO DONE

Step Three: Respond to this question in your fork: "What are some of the balances and trade offs between different sorting algoritms?"

The common theme is that some sorting algorithms are very performant, but take up a ton of memory and others are slower algorithms that do not take up as much space. A good comparision is between insertion sort and merge sort. Insertion sort is O(n2) which isn't great, but when dealing with smaller datasets can be usefull when memory comes at a premium. Merge sort on the other hand is O(NlogN) which is very good but does take up more resources. They key take away is that there isn't a one size fits all solution to which sorting algorithm should be used, but you should take into account the constraints that are placed upon you.

@julsfelic
julsfelic / running_app_in_production_locally.markdown
Last active March 2, 2016 17:34 — forked from rwarbelow/running_app_in_production_locally.markdown
How to Run a Rails App in Production Locally
  1. Add gem 'rails_12factor' to your Gemfile. This will add error logging and the ability for your app to serve static assets.
  2. bundle
  3. Run RAILS_ENV=production rake db:create db:migrate db:seed
  4. Run rake secret and copy the output
  5. From the command line: export SECRET_KEY_BASE=output-of-rake-secret
  6. To precompile your assets, run rake assets:precompile. This will create a folder public/assets that contains all of your assets.
  7. Run RAILS_ENV=production rails s and you should see your app.

Remember to clobber your assets (rake assets:clobber) and re-precompile (rake assets:precompile) if you make changes. Add public/assets to your .gitignore

Setting Group Expectations

Group Member Names: Julian, Alexis, Scott & Admir

  1. When are group members available to work together? What hours can each group member work individually? Are there any personal time commitments that need to be discussed?
  • Scott: Weekends (Not too early on weekends)
  • Julian: Pretty much open at all times
  • Alex: M,W,F 4-6pm (Workout). Stay till 9-10pm normally. Saturday (Early morning chores) Sunday (past Mid-afternoon)
  • Admir: W (2:30 - 3:00 pm)
@julsfelic
julsfelic / cfu_crud_in_sinatra.markdown
Last active February 3, 2016 00:20 — forked from rwarbelow/cfu_crud_in_sinatra.markdown
CRUD in Sinatra -- Check for Understanding

Define CRUD.

CRUD stands for Create Read Update & Delete. It allows us to create resources in a database, read or 'get' the resource to display, update a resource without overwriting the original resource and delete a specific resource from the database.

There are seven verb + path combinations that are necessary in a basic Sinatra app in order to provide full CRUD functionality. List each of the seven combinations, and explain what each is for.

All resources: get '/resources' (ex. get '/tasks') => gives us a list of all the resources through a index.erb file that gets interpreted to html.

One resource: get '/resources/:id (ex. get '/tasks/1) => gives us the specific resource through a show.erb file that gets interpreted to html.