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
@neilrackett
neilrackett / php-to-moment.js
Last active May 7, 2019
Convert PHP date string to Moment.js format
View php-to-moment.js
function phpToMoment(str) {
let replacements = {
'd' : 'DD',
'D' : 'ddd',
'j' : 'D',
'l' : 'dddd',
'N' : 'E',
'S' : 'o',
'w' : 'e',
@tdchien
tdchien / EventServiceProvider.php
Created Nov 17, 2016
Laravel 5 - Log DB query
View EventServiceProvider.php
public function boot(DispatcherContract $events)
{
parent::boot($events);
$path = storage_path().'/logs/query.log';
\Event::listen('illuminate.query', function($sql, $bindings, $time) use($path) {
// Uncomment this if you want to include bindings to queries
//$sql = str_replace(array('%', '?'), array('%%', '%s'), $sql);
//$sql = vsprintf($sql, $bindings);
$time_now = date('Y-m-d H:i:s');
@ngugijames
ngugijames / Ussd-varying-questions.php
Last active Aug 30, 2016
Ussd with varying questions and responses
View Ussd-varying-questions.php
<?php
/**
* Collaborated with http://github.com/pittgikera
*/
$text = $_GET['text'];
//$questions = "How was is it? # Was it enjoyable?# Did you have fun? # Will you come back?";
$questions = "";
@muya
muya / random_saf_ke_msisdn_faker.php
Last active Apr 6, 2017
Code for creating random Safaricom Kenya Phone numbers (accompanying blog post: https://blog.muya.co.ke/random-safaricom-kenya-phone-numbers/)
View random_saf_ke_msisdn_faker.php
<?php
// include Faker in your project (https://github.com/fzaninotto/Faker#installation)
use Faker\Factory as Faker;
$faker = Faker::create();
$regex = "/(\+?254|0){1}[7]{1}([0-2]{1}[0-9]{1}|[9]{1}[0-2]{1})[0-9]{6}/";
$samplePhoneNumber = $faker->regexify($regex);
@muya
muya / msisdn_regex.txt
Created Feb 28, 2016
Regex for Safaricom Kenya, Airtel Kenya & Tigo Tanzania Phone Numbers
View msisdn_regex.txt
# KE
SAFARICOM: "/(\+?254|0|^){1}[-. ]?[7]{1}([0-2]{1}[0-9]{1}|[9]{1}[0-2]{1})[0-9]{6}\z/"
AIRTEL: "/(\+254|0|^){1}[-. ]?[7]{1}([3]{1}[0-9]{1}|[8]{1}[5-9])[0-9]{6}\z/"
# TZ
TIGO: "/(\+?255|0|^){1}[-. ]?([7]{1}[1]{1}[2-9]{1}|[6]{1}[57]{1}[2-9]{1})[0-9]{6}\z/"
@ghprod
ghprod / laravel.js
Last active Oct 5, 2018 — forked from soufianeEL/laravel.js
You use Laravel 5 and you want to send a DELETE request without creating a form? This will handle the form-creation bits for you dynamically, similar to the Rails implementation. To use, import script, and create a link with the `data-method="DELETE"` and `data-token="{{csrf_token()}}"` attributes.
View laravel.js
/*
Taken from: https://gist.github.com/soufianeEL/3f8483f0f3dc9e3ec5d9
Modified by Ferri Sutanto
- use promise for verifyConfirm
Examples :
<a href="posts/2" data-method="delete" data-token="{{csrf_token()}}">
- Or, request confirmation in the process -
<a href="posts/2" data-method="delete" data-token="{{csrf_token()}}" data-confirm="Are you sure?">
@wesrice
wesrice / AbstractEntity.php
Last active Feb 26, 2018
Self Validating Value Objects and Entities (Laravel Implementation)
View AbstractEntity.php
<?php
abstract class AbstractEntity extends AbstractValueObject
{
/**
* Offset Set
*
* @param mixed $offset
* @param mixed $value
*
View VideoStream.php
<?php
/**
* Description of VideoStream
*
* @author Rana
* @link http://codesamplez.com/programming/php-html5-video-streaming-tutorial
*/
class VideoStream
{
private $path = "";
View App_Http_VideoStream.php
<?php
namespace App\Http;
/**
* Description of VideoStream
*
* @author Rana
* @link https://gist.github.com/vluzrmos/d5682ad426525196d069
*/
View BeforeValidException.php
<?php namespace App\Services\Jwt\Exceptions;
class BeforeValidException extends \UnexpectedValueException { }
You can’t perform that action at this time.