This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Dictionary<string, List<string>> ConvertToDictionaryOptimized(List<Tuple> actorMovies) | |
{ | |
var result = new Dictionary<string, List<string>>(); | |
foreach (Tuple actorMovie in actorMovies) | |
{ | |
if (result.ContainsKey(actorMovie.Actor)) | |
{ | |
var movies = result[actorMovie.Actor]; | |
movies.Add(actorMovie.Movie); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal class QuickUnionUF | |
{ | |
private readonly int[] _id; | |
private readonly int[] _size; | |
public QuickUnionUF(int n) | |
{ | |
_id = new int[n + 1]; | |
_size = new int[n + 1]; | |
for (int i = 0; i < n; i++) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class DemoMain { | |
constructor() { | |
this.goodReadsURL = `https://www.goodreads.com/shelf/list.xml`; | |
this.q = `key=${apiConfig.goodreadsKey}&user_id=${apiConfig.goodreadsUserID}&page=1`; | |
this.url = `${this.goodReadsURL}?${this.q}`; | |
} | |
logResult(url) { | |
axios.get(url, { params: { format: "json" } }) | |
.then((yqlResponse) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var proxify = require('proxify-url'); | |
... | |
thirdAttempt() { | |
// GoodReads API returns result in "XML" format. | |
// "XML" is the "input" format fed into YQL | |
let proxyUrl = proxify(this.url, { inputFormat: 'xml' }); | |
this.logResult(proxyUrl); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import YqlAjax from './yql_ajax'; | |
... | |
secondAttempt() { | |
let yqlAjax = new YqlAjax(); | |
yqlAjax.ajax(this.goodReadsURL) | |
.then((yqlResponse) => { | |
// DefiantJS XPath query for user shelf for "read" section. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var axios = require('axios'); | |
var apiConfig = require('../apikey.js'); | |
export default class YqlAjax { | |
ajax(url) { | |
const yqlUrl = "http://query.yahooapis.com/v1/public/yql"; | |
let goodReadsURL = `${url}?key=${apiConfig.goodreadsKey}&user_id=${apiConfig.goodreadsUserID}&page=1`; | |
let q = `select * from xml where url="${goodReadsURL}"`; | |
return axios.get(yqlUrl, { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get reddit links | |
var divs = document.querySelectorAll('a[data-event-action="title"]'); | |
// Open all links | |
for (i = 0; i < divs.length; i++) { window.open(divs[i].href); }; | |
// Move to next page | |
window.location.href= document.querySelector('.next-button a').href; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import apiConfig from '../../apikeys'; | |
... | |
getShelfBooksURL() { | |
// https://www.goodreads.com/api/index#reviews.list | |
let goodReadsURL = ` https://www.goodreads.com/review/list`; | |
let q = `v=2&key=${apiConfig.goodreadsKey}&id=${apiConfig.goodreadsUserID}&shelf=read&sort=date_started`; | |
return {goodReadsURL, q}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiKeys.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
"goodreadsKey": "your developer key", | |
"goodreadsSecret": "secrete", | |
"goodreadsUserID": 12345 | |
} |
OlderNewer