Skip to content

Instantly share code, notes, and snippets.

Avatar

Aliese Parker alieseparker

View GitHub Profile
View API Versioning
# 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 Jan 1, 2018
Floyd-Warshall - Find shortest path
View Floyd-Warshall
# 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 Nov 11, 2014
Ruby Meta Programming
View That's so Meta
# 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
```
View gist:6ba769990b223d54bf31
class Queue
attr_accessor :data, :next, :head, :tail, :size
def enqueue (data)
@data = data
if head.nil?
@head = @data
@tail = @data
@size = 1
View gist:ec84b70077c7d171178d
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
View gist:45838d838f3593aea3f5
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
View gist:5ce635289234dad89c58
<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?' } %>
View gist:a7e660d24cb6a146e1fe
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
View Ch2
development:
adapter: sqlite3
database: development
pool: 5
timeout: 5000
production:
adapter: mysql
database: depot_production
encoding: utf8
View gist:24b375e0f0a947ba7f83
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
You can’t perform that action at this time.