Skip to content

Instantly share code, notes, and snippets.

Avatar

Brian Matovu mtvbrianking

View GitHub Profile
@james2doyle
james2doyle / dd.php
Last active Jun 23, 2020
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
@odan
odan / xampp_php7_xdebug.md
Last active Aug 14, 2020
Installing Xdebug for XAMPP
View xampp_php7_xdebug.md
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 Jun 23, 2020
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.
@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 May 9, 2020
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
*/
@ravibharathii
ravibharathii / Strong Password RegEx
Created Oct 29, 2012
A Regular Expression for a Strong Password
View Strong Password RegEx
Description of this regular expression is as below:
Passwords will contain at least 1 upper case letter
Passwords will contain at least 1 lower case letter
Passwords will contain at least 1 number or special character
Passwords will contain at least 8 characters in length
Password maximum length should not be arbitrarily limited
(?=^.{8,}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$
@hinnerk-a
hinnerk-a / wp_log_http_requests.php
Created May 31, 2012
WordPress filter hook for logging WP HTTP requests
View wp_log_http_requests.php
<?php
function wp_log_http_requests( $response, $args, $url ) {
// set your log file location here
$logfile = plugin_dir_path( __FILE__ ) . '/http_requests.log';
// parse request and response body to a hash for human readable log output
$log_response = $response;
if ( isset( $args['body'] ) ) {
You can’t perform that action at this time.