Skip to content

Instantly share code, notes, and snippets.

View alieseparker's full-sized avatar

Aliese Parker alieseparker

View GitHub Profile
@alieseparker
alieseparker / API Versioning
Created November 11, 2014 22:31
Rails API Research
# Api Versionioning
Ok, so we want to version our app. But which one is the best? This led me down the rabbit hole and into the depths of the darkest parts of the internet.
Here: http://stackoverflow.com/questions/389169/best-practices-for-api-versioning
the admins of stackoverflow closed this very question since as they put it
```
Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise.
```
Once I saw this I was better able to grasp the idea of versioning your API. I found this blog post by Troy Hunt who describes the three wrong ways to version your API and points out that you must merely choose the one that makes the most since to you and fits your app the best. So, going from here lets talk a bit about API Versioning.
@alieseparker
alieseparker / Floyd-Warshall
Last active January 1, 2018 14:26
Floyd-Warshall - Find shortest path
# Floyd-Warshall Algorithm
## Introduction:
Finds Shortest Path (or longest path) among all pairs of nodes in a graph.
Complexity: O(|n|³)
## How does it work?
- There can be more than one route between two nodes.
- The number of nodes in the route isn’t important (Path 4 has 4 nodes but is shorter than Path 2, which has 3 nodes)
- There can be more than one path of minimal length
@alieseparker
alieseparker / That's so Meta
Created November 11, 2014 18:14
Ruby Meta Programming
# First a primer on Meta Programming:
Meta programming happens all the time under the surface. You are meta programming whenever you are writting code that operates on code rather then data. A great example in Ruby is anytime you use a generator, you are using a bit of code to write new code. This is metaprogramming. But of course we can use meta programming outside of just using a generator. A great example is the String Class, out of the box it doesn't have a way to split a sentence into individual words within an array. We can reopen the String class and write our own method in.
```Ruby
Class String
def split_words
split(' ')
end
end
```
class Queue
attr_accessor :data, :next, :head, :tail, :size
def enqueue (data)
@data = data
if head.nil?
@head = @data
@tail = @data
@size = 1
ANGULAR VOCABULARY:
Scope: The range that an object may be accessed.
Controller: The logic behind views of sectoins of the DOM Tree
Data Binding: Syncs data between the model and view
Dependency Injection: Writes and connects objects to the dom
class Warshall
def initialize(adjacencyMatrix)
@adjacencyMatrix=adjacencyMatrix
end
def getPathMatrix
numNodes=@adjacencyMatrix[0].length
pathMatrix=Array.new(@adjacencyMatrix)
for k in 0...numNodes
for i in 0...numNodes
<h2>My Portfolio</h2>
<ul>
<% @projects.each do |project| %>
<li class="project" id="<%= dom_id(project) %>">
<h3><%= project.name %></h3>
<p><%= project.technologies_used %></p>
<div class="project_nav", id="project_nav_<%= dom_id(project)%>" >
<%= link_to 'Show', project %> |
<%= link_to 'Edit', edit_project_path(project) %> |
<%= link_to 'Destroy', project, method: :delete, data: { confirm: 'Are you sure?' } %>
require 'test_helper'
feature 'Deleting a Project' do
scenario 'Project is deleted with a click' do
visit projects_path
page.find("div#project_nav_project_1").click_on 'Destroy'
page.text.must_include 'Project was successfully deleted.'
page.wont_have_content 'Code Fellows Portfolio'
end
end
development:
adapter: sqlite3
database: development
pool: 5
timeout: 5000
production:
adapter: mysql
database: depot_production
encoding: utf8
forrestparker@Ferdinand ForrestPortfolio (master) $host forrestaparker.com
forrestaparker.com has address 8.5.1.1
forrestaparker.com mail is handled by 10 p.nsm.ctmail.com.
forrestparker@Ferdinand ForrestPortfolio (master) $dig www.forrestaparker.com
; <<>> DiG 9.8.3-P1 <<>> www.forrestaparker.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 18405