Skip to content

Instantly share code, notes, and snippets.

View ngugijames's full-sized avatar
🇰🇪
.

James Ngugi ngugijames

🇰🇪
.
View GitHub Profile
@ngugijames
ngugijames / scrape.php
Created December 22, 2015 20:22 — forked from ziadoz/scrape.php
Scraping Google using PHP and Goutte:
<?php
/**
* Todo: Send a random user agent string and sleep a random amount between requests.
*/
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// Extract and sanatize input:
$domain = filter_input(INPUT_POST, 'domain', FILTER_SANITIZE_URL);
$terms = filter_input(INPUT_POST, 'terms', FILTER_SANITIZE_STRING);
// Setup Goutte (which also includes Guzzle):
@ngugijames
ngugijames / simplepolling.js
Created October 28, 2015 07:23 — forked from handerson/simplepolling.js
Simple AJAX Polling jQuery Plugin
//Simple AJAX Polling jQuery Plugin
// example usage:
/* $.ajaxPoll({
url: "/path",
type: "GET",
interval: 250,
maxAttempts: 25,
successCondition: function(result) {
return result != "processing";
},
@ngugijames
ngugijames / longPolling.js
Created October 28, 2015 07:22 — forked from jasdeepkhalsa/longPolling.js
Simple Long Polling Example with JavaScript and jQuery by Tian Davis (@tiandavis) from Techoctave.com (http://techoctave.com/c7/posts/60-simple-long-polling-example-with-javascript-and-jquery)
// Long Polling (Recommened Technique - Creates An Open Connection To Server ∴ Fast)
(function poll(){
$.ajax({ url: "server", success: function(data){
//Update your dashboard gauge
salesGauge.setValue(data.value);
}, dataType: "json", complete: poll, timeout: 30000 });
})();