Skip to content

Instantly share code, notes, and snippets.

@lajosbencz
lajosbencz / ConsoleParameters.php
Last active May 3, 2019 09:18
Command line parameters helper class
<?php
use ArrayAccess;
class ConsoleParameters implements ArrayAccess
{
/**
* Prefix for flag names
* @var string
*/
@lajosbencz
lajosbencz / ConvertByteSize.php
Created September 17, 2015 21:57
Convert between byte size units
<?php
namespace LajosBencz;
class ConvertByteSize
{
const FORMAT_BYTE_SIZE_PATTERN = '(yotta|zetta|exa|peta|tera|giga|mega|kilo|y|z|e|p|t|g|m|k)\s*(bit|byte|b)?';
public static $formatByteSize_Unit = 'mB';
public static $formatByteSize_Format = '%0.2f %s';
<?php
interface TaskInterface
{
/**
* Assign the first number
* @param int $value
* @return $this
*/
public function setA($value);
<html>
<head>
<script src="https://code.jquery.com/jquery-2.2.2.min.js" integrity="sha256-36cp2Co+/62rEAAYHLmRCPIych47CvdM+uTBJwSzWjI=" crossorigin="anonymous"></script>
<script>
$(function(){
$('#add_default').click(function(){
$('#list').append($('<li><a>Default</a></li>'));
});
$('#add_clickable').click(function(){
$('#list').append($('<li><a class="clickme">Clickable</a></li>'));
@lajosbencz
lajosbencz / ProgressBar.php
Created May 1, 2016 21:58
Multi-line progress bar for terminal
<?php
class ProgressBar
{
const NL = PHP_EOL;
/** Pattern used to match placeholders in message formats */
const PATTERN_FORMAT = "/%(?'name'[^\\s%:]+)(:(?'format'[^%]+))?%/";
/** Default format for progress update message */
@lajosbencz
lajosbencz / amdgpu-pro-wizard.sh
Created September 19, 2017 13:07
Downloads and installs latest AMDGPU-PRO drivers from the official AMD website
#!/bin/bash
# amdgpu-pro-wizard.sh
# Downloads and installs latest AMDGPU-PRO drivers from the official AMD website
URL="http://support.amd.com/en-us/kb-articles/Pages/AMDGPU-PRO-Driver-for-Linux-Release-Notes.aspx"
DIR="/tmp/.amdgpu-pro-install-9811a15y85p71m/"
HTML="list.html"
PAT="www2.ati.com/drivers/linux"
REF="http://support.amd.com"
use Phalcon\Session\AdapterInterface;
use Phalcon\Cache\Backend\Redis as RedisCache;
use Phalcon\Cache\Frontend\None as FrontendNone;
class Redis implements \SessionHandlerInterface, AdapterInterface
{
const SESSION_ACTIVE = 2;
const SESSION_NONE = 1;
@lajosbencz
lajosbencz / gitpub.php
Last active November 7, 2018 11:15
Script for bumping semantic versioned packages to git remote
<?php
/**
* Script for bumping semantic versioned packages to git remote
*
* @version 0.1.0
* @author Lajos Bencz <lazos@lazos.me>
* @license MIT
*/
if (!is_dir('.git')) {
@lajosbencz
lajosbencz / create-swap.sh
Created December 18, 2021 15:28
Ubuntu 20 create swap space on disk
#!/bin/bash
SIZE="$1"
FILE="/var/swap.img"
SWPS=10
CHPR=50
if [ -z "$SIZE" ]; then
echo "first argument must be size (fallocate -l)"
exit
@lajosbencz
lajosbencz / disable-snapd.sh
Last active December 18, 2021 15:42
Ubuntu 20 disable snapd
#!/bin/bash
systemctl stop snapd && systemctl disable snapd && systemctl mask snapd && \
apt purge snapd -y && \
rm -fr ~/snap /snap /var/snap /var/lib/snapd /var/cache/snapd /usr/lib/snapd