Skip to content

Instantly share code, notes, and snippets.

Avatar

Brian Matovu mtvbrianking

View GitHub Profile
@scrubmx
scrubmx / Application.php
Created Oct 25, 2017
Register custom model events in laravel 5.5
View Application.php
<?php
namespace App\Models;
class Application extends Model
{
/**
* The attributes that should be mutated to dates.
*
* @var array
@james2doyle
james2doyle / dd.php
Last active Oct 25, 2021
A implementation of "dump and die" (dd) for WordPress
View dd.php
<?php
if (!function_exists('dd')) {
function dd($data)
{
ini_set("highlight.comment", "#969896; font-style: italic");
ini_set("highlight.default", "#FFFFFF");
ini_set("highlight.html", "#D16568");
ini_set("highlight.keyword", "#7FA3BC; font-weight: bold");
ini_set("highlight.string", "#F2C47E");
View boost example of threads and interrupts.cpp
#include <boost/thread.hpp>
#include <iostream>
using namespace std;
void ThreadFunction()
{
int counter = 0;
for(;;)
@mgirouard
mgirouard / guzzle-exceptions.md
Created Jul 17, 2016
GuzzleHttp Exception Hierarchy
View guzzle-exceptions.md
  • GuzzleException
    • SeekException
    • TransferException
      • RequestException ( RequestInterface ; ResponseInterface | null )
        • TooManyRedirectsException
        • ConnectException
        • BadResponseException
          • ServerException
          • ClientException
View ObjectListener.php
<?php
namespace Fry;
use JsonStreamingParser\Listener;
/**
* This implementation allows to process an object at a specific level
* when it has been fully parsed
*/
class ObjectListener implements Listener
{
@mcaskill
mcaskill / Function.Array-Group-By.php
Last active Sep 7, 2021
PHP : Groups an array by a given key
View Function.Array-Group-By.php
<?php
if (!function_exists('array_group_by')) {
/**
* Groups an array by a given key.
*
* Groups an array into arrays by a given key, or set of keys, shared between all array members.
*
* Based on {@author Jake Zatecky}'s {@link https://github.com/jakezatecky/array_group_by array_group_by()} function.
* This variant allows $key to be closures.
@tureki
tureki / json_encode-null-to-empty-string-1.php
Last active Mar 31, 2021
json_encode null to empty string.
View json_encode-null-to-empty-string-1.php
$value = array(
"deep"=>1,
"data"=>null,
"node"=>array(
"deep"=>2,
"data"=>null,
"node"=>array(
"deep"=>3
)
),
@josephok
josephok / client.c
Last active Sep 6, 2018
a stream socket server & client demo
View client.c
/*
** client.c -- a stream socket client demo
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <netdb.h>
@tdebatty
tdebatty / delete_older_than.php
Last active Oct 14, 2021
A simple PHP function to delete files older than a given age. Very handy to rotate backup or log files, for example...
View delete_older_than.php
<?php
/**
* A simple function that uses mtime to delete files older than a given age (in seconds)
* Very handy to rotate backup or log files, for example...
*
* $dir String whhere the files are
* $max_age Int in seconds
* return String[] the list of deleted files
*/