Skip to content

Instantly share code, notes, and snippets.

View xZero707's full-sized avatar
🦆
Absent-Minded professor

Aleksandar Puharic xZero707

🦆
Absent-Minded professor
View GitHub Profile
@xZero707
xZero707 / virt-manager.md
Created May 18, 2020 13:10 — forked from Jiab77/virt-manager.md
Virt-Manager Installation (for ubuntu based distrib)

Virt-Manager Installation (for ubuntu based distrib)

This gist will give you all installation steps needed to install properly virt-manager with all dependencies.

Dependencies

Here is the list of all dependencies required to install properly virt-manager on your ubuntu based distrib.

  • libvirt-bin
  • qemu
@xZero707
xZero707 / alpine-docker-setup.sh
Created May 15, 2020 18:41 — forked from grownseed/alpine-docker-setup.sh
Alpine Docker Dev Host Setup
#/bin/sh
#
# The following assumes a default Alpine install using the standard Alpine image
#
# Note: for VirtualBox, you could be tempted to use the `alpine-virt` image,
# however it uses the `virtgrsec` kernel, for which there is no guest additions support
# if required, SSH root password access can be enabled by adding `PermitRootLogin yes`
# to `/etc/ssh/sshd_config`
@xZero707
xZero707 / linebreak.md
Created May 8, 2020 09:24
Line breaks in markdown
Hello  (<-- two spaces)
World

Hello
World


@xZero707
xZero707 / fake-ssl-enabled.php
Last active April 13, 2020 11:38
Fake HTTP(S) state for stubborn PHP app that won't operate over HTTP even though you desire it too. Pay attention to in-code comment.
<?php
/**
* Fake headers so it looks like request is coming from SSL
* In my case, I'm hosting app in the isolated docker container behind nginx-proxy.
* For simplicity sake, connection between nginx-proxy and the app is http.
* Connection between nginx-proxy and the client is normally SSL-only (HSTS).
* Wordpress in particular caused problems in this config.
* NOTE: DO NOT USE THIS ON WEBSITE EXPOSED TO THE INTERNET IF SSL SECURITY IS DESIRABLE!
*/
$_SERVER['HTTP_UPGRADE_INSECURE_REQUESTS'] = false;
@xZero707
xZero707 / install-php.sh
Created February 18, 2020 08:56
Install PHP on Ubuntu 18.04 from ppa:ondrej/php
# This will install PHP with enough extensions to be able to run most of the applications
# More might be needed depending of your app.
sudo add-apt-repository ppa:ondrej/php
sudo apt update
# Replace php7.4 with your arbitary version, eg. php7.1
sudo apt -y install php7.4 php7.4-{common,json,cli,curl,gd,mysqli,mysqlnd,intl,imagick,gettext,sqlite,apcu,xmlwriter,simplexml}
@xZero707
xZero707 / IPB4_Centminmod.conf
Created February 13, 2020 12:49
Invision Power Board v4 Nginx configuration file for use with Centminmod.
# IPB4 Working NGINX site conf file
# Tested on IPB 4.3+ and Centminmod 123.09beta01
# This file is for a FORCED SSL site. Non-SSL requests will be directed to SSL.
# Replace domain.com with your IP address or domain name.
# IPv6 is now included.
# Replace IPv4 and IPv6 with the actual addresses.
# Information gathered from
# Centminmod.com / Information pulled from multiple guides. Thx eva2000!
@xZero707
xZero707 / foldersize.php
Created August 7, 2019 10:29 — forked from eusonlito/foldersize.php
PHP function to get the folder size including subfolders
<?php
function folderSize ($dir)
{
$size = 0;
foreach (glob(rtrim($dir, '/').'/*', GLOB_NOSORT) as $each) {
$size += is_file($each) ? filesize($each) : folderSize($each);
}
@xZero707
xZero707 / ArrayDiffAssoc.php
Created July 12, 2019 12:27
Compares two arrays and shows exact difference between them. The ultimate function
<?php
/**
* Compares two arrays and shows exact difference between them.
*
* !!! IMPORTANT !!
* Order of two supplied arrays matters!
*
* @fix xZero707 <xzero@elite7hackers.net>: Pay attention to types as well
*
@xZero707
xZero707 / git-mv-with-history
Created March 5, 2019 12:18 — forked from emiller/git-mv-with-history
git utility to move/rename file or folder and retain history with it.
#!/bin/bash
#
# git-mv-with-history -- move/rename file or folder, with history.
#
# Moving a file in git doesn't track history, so the purpose of this
# utility is best explained from the kernel wiki:
#
# Git has a rename command git mv, but that is just for convenience.
# The effect is indistinguishable from removing the file and adding another
# with different name and the same content.
@xZero707
xZero707 / str_map.php
Last active February 11, 2019 11:02
str_replace on steroids
<?php
namespace NorthernLights\Util;
/**
* Map/replace string accordingly to supplied character map
* Note:
* There is certain overhead because we use 4 function calls main -> mapper -> array_keys -> array_values
* versus that it can be done with just single str_replace()
* However, accordingly to benchmarks, difference becomes noticeable only after 1 000 000 iterations (~300ms slower)