Skip to content

Instantly share code, notes, and snippets.


James Ngugi ngugijames

Block or report user

Report or block ngugijames

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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 / scrape.php
Created Dec 22, 2015 — forked from ziadoz/scrape.php
Scraping Google using PHP and Goutte:
View scrape.php
* Todo: Send a random user agent string and sleep a random amount between requests.
// 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 / officetophp.php
Created Jan 11, 2016
View officetophp.php
/*determine th file extension
$file_name = $_FILES['image']['name'];
$file_extn = end(explode(".", strtolower($_FILES['image']['name'])));
if($file_extn == "doc" || $file_extn == "docx"){
}elseif($file_extn == "rtf"){
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
* @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 / Ussd-varying-questions.php
Last active Aug 30, 2016
Ussd with varying questions and responses
View Ussd-varying-questions.php
* Collaborated with
$text = $_GET['text'];
//$questions = "How was is it? # Was it enjoyable?# Did you have fun? # Will you come back?";
$questions = "";
ngugijames /
Created Jul 11, 2017 — forked from Integralist/
Basic set-up of remote git repository on a standard server

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 / validation.php
Created Aug 16, 2017
showing :value in laravel validation errors
View validation.php
//in controller
$validator = Validator::make(['one','two','three'], [
'*' => 'exists:table,name',
], [
'exists' => '`:value` does not exist.',
//in service provider boot
$this->app->validator->resolver(function($translator, $data, $rules, $messages, $attributes)
ngugijames / l3_log_replacer.php
Last active Nov 2, 2017
find L3 log usages and replace with L5 equivalents using PHPStorm
View l3_log_replacer.php
//Search For:
//Replace with
Log::info("$1", $2);
// Replaces Log::api_unreachable(..) with something like Log::info("api_unreachable", ..);
sudo mkdir `date '+%d-%m-%Y'`
NOW=$(date +"%d-%m-%Y")
MYSQL="$(which mysql)"
View rtf2text.php
* Special thanks to
// Function that checks whether the data are the on-screen text.
// It works in the following way:
// an array arrfailAt stores the control words for the current state of the stack, which show that
// input data are something else than plain text.
// For example, there may be a description of font or color palette etc.
You can’t perform that action at this time.