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 List<Label> GetLabels() | |
{ | |
/* | |
* use linq's lazy loading feature to enumerate an unlimited number of page requests. so i created AggregateUntil() to | |
* take in a Func() which will inform when to stop iterating - in this case, we want to stop after the entries count | |
* exceeds the totalNumEntries value, which Google Adwords returns from the first query | |
*/ | |
var labels = Enumerable | |
.Range(0, Int32.MaxValue) //range generates a list of integers, from 1 to practically infinity | |
.AggregateUntil( |
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 labelsPage = Enumerable | |
.Range(0, 5) | |
.Select(pageAttempt => | |
{ | |
Thread.Sleep(2500 * pageAttempt * pageAttempt); | |
try | |
{ | |
var labelsAwql = "select LabelId,LabelName,LabelStatus limit 0,100"; | |
var attemptedlabelsPage = Config.LabelService.query(labelsAwql); |
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 page = require('webpage').create(); | |
page.open('http://davidgallmeier.com', function() { | |
page.includeJs("http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js", function() { | |
var results = page.evaluate(function() { | |
var firstlinktext = $('a.post-link:first'). | |
text(). | |
toString(); | |
var firstlinkhref = $('a.post-link'). | |
map(function () { | |
return $( this ).attr('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
require 'net/http' | |
require 'nokogiri' | |
#you need Nokogiri for this to work: gem install 'nokogiri' | |
#fetch html if not cached | |
html_cache_file = 'blackjack-chart.html' | |
if File.exist? html_cache_file | |
html = File.read(html_cache_file) | |
else |
NewerOlder