Skip to content

Instantly share code, notes, and snippets.

View jamielsharief's full-sized avatar

Jamiel Sharief jamielsharief

  • uk
View GitHub Profile
@jamielsharief
jamielsharief / profiler.php
Created January 27, 2019 10:18
I created this to see if there was a memory leak in an app. Its a quick no frills profiler. It uses Ticks so declare(ticks=1) needs to be called in every file that you want to profile. This can easily be adjusted for timing etc
/**
* Include this at the start of script, then on every FILE that you want to profile add
* declare(ticks=1);
*/
function mem()
{
$bytes = memory_get_usage(false);
if ($bytes >= 1048576) {
return number_format($bytes / 1048576, 2).' mb';
}
@jamielsharief
jamielsharief / 50-cloud-init.yaml
Last active October 17, 2018 09:42
Ubuntu 18 static Ip address configuration.
network:
version: 2
renderer: networkd
ethernets:
enp0s3:
dhcp4: no
addresses: [192.168.1.37/24]
gateway4: 192.168.1.1
nameservers:
addresses: [8.8.8.8,8.8.4.4]
@jamielsharief
jamielsharief / interfaces.static.backup
Last active October 17, 2018 09:29
Ubuntu 16 configuration file for static IP address
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
#auto lo
#iface lo inet loopback
# The primary network interface
@jamielsharief
jamielsharief / Counter.php
Created September 28, 2018 07:18
Counter Class
<?php
/**
* Counter class
* @author Jamiel Sharief
* @example $Counter = Counter::init('default',10000);
* $i = $Counter->next();
*/
class Counter
{
protected static $singleton = [];
@jamielsharief
jamielsharief / Timer.php
Last active September 28, 2018 07:19
Quick Timer Class
<?php
/**
* Timer Class
* @author Jamiel Sharief
* @example Timer::start();
* $took = $Timer::end();
*/
Class Timer
{
private static $milliseconds = false;