Skip to content

Instantly share code, notes, and snippets.

View armandofox's full-sized avatar

Armando Fox armandofox

View GitHub Profile
@armandofox
armandofox / block_example.rb
Created December 10, 2020 00:33
block_example.rb
def print_movies(movie_list)
movie_list.each do |m|
puts "#{m.title} (rated: #{m.rating})"
end
end
@armandofox
armandofox / curl_json_post.sh
Created December 10, 2020 00:33
curl_json_post.sh
# set endpoint for TMDb API
export BASE=https://api.themoviedb.org/v3
# set our API key for use in other calls
export KEY="my API key here"
# Search for a movie by keywords
curl "$BASE/search/movie?api_key=$KEY&query=Batman+Returns"
# For better legibility, pipe the output to json_pp:
curl "$BASE/search/movie?api_key=$KEY&query=Batman+Returns" | json_pp
# Start a new guest session
curl "$BASE/authentication/guest_session/new" | json_pp
@armandofox
armandofox / index_using_partial.html.erb
Created December 10, 2020 00:33
index_using_partial.html.erb
<!-- ...other code from index.html.erb here... -->
<div class="row bg-dark text-white">
<div class="col-6 text-center">Title and More Info</div>
<div class="col-2 text-center">Rating</div>
<div class="col-4 text-center">Release Date</div>
</div>
<%= render partial: 'movie', collection: @movies %>
@armandofox
armandofox / collection_example.rb
Created November 15, 2020 20:41
collection_example.rb
# find largest element in a collection
def maximum(collection)
result = collection.first
collection.each do |item|
result = item if item > result
end
result
end
maximum([3,4,2,1]) # => 4
maximum(["a","x","b"]) # => "x"
@armandofox
armandofox / basic_check_spec.js
Created November 15, 2020 20:41
basic_check_spec.js
describe('Jasmine basic check', function() {
it('works', function() { expect(true).toBe(true); });
});
@armandofox
armandofox / index_using_partial.html.erb
Created November 15, 2020 20:41
index_using_partial.html.erb
<!-- ...other code from index.html.erb here... -->
<div class="row bg-dark text-white">
<div class="col-6 text-center">Title and More Info</div>
<div class="col-2 text-center">Rating</div>
<div class="col-4 text-center">Release Date</div>
</div>
<%= render partial: 'movie', collection: @movies %>
require 'rails_helper'
describe MoviesController do
describe 'searching TMDb' do
it 'calls the model method that performs TMDb search'
it 'selects the Search Results template for rendering'
it 'makes the TMDb search results available to that template'
end
end
@armandofox
armandofox / git_prompt.txt
Created August 20, 2020 18:57
git_prompt.txt
export PS1="[`git branch --no-color 2>/dev/null | \
sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`]% "
@armandofox
armandofox / git_conflict_markers.txt
Created August 20, 2020 18:57
git_conflict_markers.txt
Roses are red,
Violets are blue.
<<<<<<< HEAD:poem.txt
I love GitHub,
=======
ProjectLocker rocks,
>>>>>>> 77976da35a11db4580b80ae27e8d65caf5208086:poem.txt
and so do you.
@armandofox
armandofox / unit_test_summary.rb
Last active August 20, 2020 18:57
unit_test_summary.rb
# 1. Pure leaf function: test critical values and noncritical regions
it 'occurs when multiple of 4 but not 100' do
expect(leap?(2008)).to be_truthy
end
it 'does not occur when multiple of 400' do
expect(leap?(2000)).to be_falsy
end
# 2. Using doubles for explicit dependencies such as collaborators
# UI.background() calls Defcon.level() to determine display color