Skip to content

Instantly share code, notes, and snippets.

Avatar
🇰🇪
.

James Ngugi ngugijames

🇰🇪
.
View GitHub Profile
@ngugijames
ngugijames / remote-git.md
Created Jul 11, 2017 — forked from Integralist/remote-git.md
Basic set-up of remote git repository on a standard server
View remote-git.md

Set-up remote git repository on a standard server

The first thing to do is to install Git on the remote server.

Once you do that the rest of the process is split into three sections:

  1. Server set-up
  2. Local set-up (push commits)
  3. Server (pull commits)
@ngugijames
ngugijames / PHP Weighted Round Robin Scheduling
Created May 16, 2016
A simple implementation of the Weighted Round-Robin Scheduling in PHP ( PHP >= 5.3 )
View PHP Weighted Round Robin Scheduling
<?php
/**
* @author Alexis Gruet
*
* A simple implementation of the Weighted Round-Robin Scheduling in PHP 5.3+
*
* The weighted round-robin scheduling is designed to better handle servers with different
* processing capacities. Each server can be assigned a weight, an integer value that
* indicates the processing capacity. Servers with higher weights receive new connections
@ngugijames
ngugijames / scrape.php
Created Dec 22, 2015 — forked from ziadoz/scrape.php
Scraping Google using PHP and Goutte:
View scrape.php
<?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 Oct 28, 2015 — forked from handerson/simplepolling.js
Simple AJAX Polling jQuery Plugin
View simplepolling.js
//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 Oct 28, 2015 — 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)
View longPolling.js
// 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 });
})();
You can’t perform that action at this time.