Skip to content

Instantly share code, notes, and snippets.

View 66Ton99's full-sized avatar
🇺🇦

Ton Sharp 66Ton99

🇺🇦
View GitHub Profile
@66Ton99
66Ton99 / void-wsl.sh
Last active April 3, 2024 16:31 — forked from JucaRei/void-wsl.sh
Install Void Linux on WSL2
# Based on https://gist.github.com/kmatt/71603170556ef8ffd14984af77ff10c5
# prompt ">" indicates Powershell commands
# prompt "$" are Linux shell commands
# https://learn.microsoft.com/en-us/windows/wsl/install
> dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
> dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
# No need for Windows 11, but for Windows 10 install https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi
@66Ton99
66Ton99 / licenses.sh
Last active June 21, 2022 23:30
Allow to export license files from RPMs
#!/usr/bin/env bash
# RPM license exporter
# Copyright 2022 66Ton99@gmail.com
extract_file() {
# echo "$1"
# echo "$2"
rpm2cpio "$1" | cpio -iv --to-stdout ".$2" 1> license.tmp 2> /dev/null
ENCODING=$(uchardet license.tmp)
# echo "$ENCODING"
@66Ton99
66Ton99 / virt-manager-osx-macports
Last active October 6, 2016 10:24 — forked from LuisPalacios/virt-manager-osx
Install virt-manager OSX with MacPorts
sudo port -v install intltool py27-pygtk py27-gobject3 libvirt gtk3 libvirt
cd $HOME
# Sources:
# compile what you need from here https://github.com/jeffreywildman/homebrew-virt-manager
cd $HOME
git clone https://github.com/virt-manager/virt-manager
# Change destination install directory instead of /usr, due to
@66Ton99
66Ton99 / logging_to_str.py
Created August 28, 2015 16:26
Capturing Python Log Output In A Variable
import logging
from StringIO import StringIO as StringBuffer
logger = logging.getLogger('basic_logger')
logger.setLevel(logging.DEBUG)
### Setup the console handler with a StringIO object
log_capture_string = StringBuffer()
# log_capture_string.encoding = 'cp1251'
ch = logging.StreamHandler(log_capture_string)
@66Ton99
66Ton99 / Enum.php
Last active August 29, 2015 14:10
OOP enum realisation
<?php
use InvalidArgumentException;
use ReflectionClass;
/**
* Base Enum class
* Require PHP >= 5.3
*
* @author Ton Sharp <66ton99@gmail.com>
@66Ton99
66Ton99 / DataBundle.php
Last active August 29, 2015 14:02
DataBundle with Enums
<?php
namespace MyNamespace;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Doctrine\DBAL\Types\Type;
class DataBundle extends Bundle
{
/**
@66Ton99
66Ton99 / DateTime.php
Last active May 16, 2024 05:31
DateTime
<?php
namespace MyNamespace;
/**
* @author Ton Sharp <66Ton99@gmail.com>
*/
class DateTime extends \DateTime
{
/**
* @param int|null $year
@66Ton99
66Ton99 / drop_data.sql
Last active December 14, 2015 02:38
Drop all data in the current DB
-- Server version 5.5.20
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
@66Ton99
66Ton99 / gist:3833001
Last active October 11, 2015 08:47
It adds ; befor ?>
(['"A-z\)])(?!;) ?\?>
$1;?>
@66Ton99
66Ton99 / delete_tables.sql
Last active October 10, 2015 15:58
Deletes all tables in current DB
delimiter $$
create procedure drop_tables_like(pattern varchar(255), db varchar(255))
begin
select @str_tables:=group_concat(table_name)
from information_schema.tables
where table_schema=db and table_name like pattern;
IF @str_tables IS NOT NULL THEN
SET @str_sql := concat('drop table ', @str_tables);
prepare stmt from @str_sql;