-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assignment stuff #1
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,22 @@ | ||
require 'github_api' | ||
require "#{Dir.pwd}/config" | ||
|
||
github = Github.new basic_auth: "#{USERNAME}:#{PASSWORD}" | ||
github = Github.new basic_auth: "#{USERNAME}:#{PASSWORD}" | ||
|
||
github_gen = Github.new | ||
|
||
repos = github_gen.repos.list 'AJLeonardi' #THIS DOES NOT DO WHAT I EXPECT, no idea where it's getting those repos from | ||
repos.each do |repo| | ||
puts repo['name'] | ||
end | ||
|
||
repos = github.repos.list 'AJLeonardi' #This returns my repos! | ||
repos.each do |repo| | ||
puts repo['name'] | ||
end | ||
|
||
repos = github.repos.list 'chrisvans' #this STILL returns my repos -- wtf?? | ||
repos.each do |repo| | ||
puts repo['name'] | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,6 @@ def self.run(count=1) | |
end | ||
nil | ||
end | ||
end | ||
end | ||
|
||
LolcatViewer.run(2) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require 'nokogiri' | ||
require 'open-uri' | ||
|
||
class LolcatViewer | ||
def self.run(n = 1) | ||
return_catz = Hash.new | ||
url = 'http://www.lolcats.com' | ||
links = [] | ||
Nokogiri::HTML(open(url + "/gallery/new.html")).css('.gallery-item a').each do |link| | ||
links << link | ||
end | ||
n.times do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice, I like it! Cool way to not have to iterate through a bunch of urls to grab the direct link to the image, you only do it for the ones you select. I wish I had thought of this :) |
||
arr_length = links.length | ||
rand_index = rand(arr_length -1) | ||
url_ext = links[rand_index]['href'] | ||
image_obj = Nokogiri::HTML(open(url + url_ext)).css('.picture-container>a>img')[0] | ||
title = image_obj['alt'] | ||
img_url = url + image_obj['src'] | ||
return_catz[title] = img_url | ||
end | ||
return_catz.each do |title, link| | ||
puts "title: " + title +" Link: " + link | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
require 'nokogiri' | ||
require 'open-uri' | ||
|
||
class NewOnionArticles | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice, you might imagine doing this if you wanted to have on your blog or app a list of 'trending news articles'...you'd need some kind of model to back it up, but this would be an example of a model you wouldn't need to persist. |
||
def self.run() | ||
return_news = Hash.new | ||
url = 'http://www.theonion.com' | ||
Nokogiri::HTML(open(url)).css('section.recent-news a').each do |link| | ||
title = link.content | ||
link_url = link['href'] | ||
return_news[title] = url + link_url | ||
end | ||
return_news.each do |title, address| | ||
puts 'Title: ' + title + ' Link: ' + address | ||
end | ||
end | ||
end | ||
|
||
NewOnionArticles.run() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a logic branch in the api code which is the culprit...in
repos.rb
:so when you're authenticated, aka have your parameters specified in the
Github
object, it will default to grabbing your own repos, regardless of what params you give it (I think). To see the other list, you'd have to use thegithub_gen
object you create.