Skip to content

Instantly share code, notes, and snippets.

View endelwar's full-sized avatar
🌋
So much time and so little to do. Wait a minute. Strike that. Reverse it.

Manuel Dalla Lana endelwar

🌋
So much time and so little to do. Wait a minute. Strike that. Reverse it.
View GitHub Profile
@mareksuscak
mareksuscak / utf8mb4.sql
Last active February 23, 2024 10:23
MySQL utf8 to utf8mb4 conversion
-- adapted from https://dba.stackexchange.com/a/104866/247902
USE information_schema;
SELECT CONCAT("SET foreign_key_checks = 0;") AS _sql UNION
SELECT CONCAT("ALTER DATABASE `",table_schema,"` CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci;") AS _sql
FROM `TABLES` WHERE table_schema LIKE "<YOUR_DATABASE>" AND TABLE_TYPE='BASE TABLE' GROUP BY table_schema UNION
SELECT CONCAT("ALTER TABLE `",table_schema,"`.`",table_name,"` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;") AS _sql
FROM `TABLES` WHERE table_schema LIKE "<YOUR_DATABASE>" AND TABLE_TYPE='BASE TABLE' GROUP BY table_schema, table_name UNION
SELECT CONCAT("ALTER TABLE `",`COLUMNS`.table_schema,"`.`",`COLUMNS`.table_name, "` CHANGE `",column_name,"` `",column_name,"` ",data_type,"(",character_maximum_length,") CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci",IF(column_default IS NOT NULL," DEFAULT \'",""),IF(column_default IS NOT NULL,column_default,""),IF(column_default IS NOT NULL,"\'",""),IF(is_nullable="YES"," NULL"," NOT NU
@mpdude
mpdude / README.md
Created January 18, 2022 20:52
Use `jq` to tweak `composer.json` requirements

Change Symfony requirements in composer.json

This took me two hours on stackoverflow.com, so I'm going to document it to future me:

In the composer.json require section, for all packages starting with symfony/, but not for symfony/monolog-bundle, change the required version to the value of the $VERSION environment variable.

Write out the updated composer.json file in a way that works _without sponge`, which is not installed on GitHub Action runners by default.

@versedi
versedi / webpack.config.js
Last active June 11, 2024 12:41
Webpack Encore + Sass + MiniCSSExtractPlugin + PurgeCSS + OptimizeCss + Babel + Typescript
/* eslint-disable no-useless-escape */
const Encore = require('@symfony/webpack-encore');
const TerserPlugin = require('terser-webpack-plugin');
const CircularDependencyPlugin = require('circular-dependency-plugin');
const HtmlCriticalWebpackPlugin = require('html-critical-webpack-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const PurgeCssPlugin = require('purgecss-webpack-plugin');
const WebpackBar = require('webpackbar');
const path = require('path');
@bjoern-r
bjoern-r / create_start_minichroot.sh
Created April 8, 2019 19:45
Script to create a minimal chroot with busybox, dropbear and dtach and allow ssh access on port 5022
#!/bin/bash
CHROOTDIR=/opt/minichroot
mkdir -p ${CHROOTDIR}/bin
mkdir -p ${CHROOTDIR}/lib64
mkdir -p ${CHROOTDIR}/etc/dropbear
mkdir -p ${CHROOTDIR}/dev
mkdir -p ${CHROOTDIR}/tmp
@tobsn
tobsn / strip_markdown.php
Created February 12, 2019 13:20
Strips Markdown from Text - PHP port of https://github.com/stiang/remove-markdown
<?php
function strip_markdown( $md = '', $options = [] ) {
// char to insert instead of stripped list leaders (default: '')
$options['listUnicodeChar'] = isset( $options['listUnicodeChar'] ) ? $options['listUnicodeChar'] : false;
// strip list leaders (default: true)
$options['stripListLeaders'] = isset( $options['stripListLeaders'] ) ? $options['stripListLeaders'] : true;
// support GitHub-Flavored Markdown (default: true)
$options['gfm'] = isset( $options['gfm'] ) ? $options['gfm'] : true;
<?php
use Predis\Client as PredisClient;
include __DIR__ . '/vendor/autoload.php';
function redis() {
global $Redis;
if ( !isset($Redis) || !$Redis instanceof PredisClient ) {
@zenxedo
zenxedo / TrueNAS Setup.md
Last active April 21, 2023 17:36 — forked from jacobblock/FreeNAS.md
Ultimate FreeNAS 11.3 iocage Setup

TrueNAS

I will be moving from FreeNAS jails to ubuntu with docker, docker compose, and portainer. FreeNAS support and updates are lacking. There are many advantages to making the switch and with ZFS on linux I think FreeNAS may be a thing of the past. Stay tuned for a new guide of my latest setup. Check out my other gists for progress on the switch. https://gist.github.com/mow4cash/626275e095f7f90898944a85d66b3be6

WARNING READ THIS: This page contains incomplete and possibly incorrect info. The page is constantly being edited and worked on. Many of these should work but some may be broken. Read the code carefully to understand what you are doing, stuff may be need to be changed for your own use. This includes but not limited too JAIL AND ROUTER IPs, YOUR FREENAS MAIN VOLUME,THE MOST RECENT RELEASE OF DOWNLOADED FILES Use at your own risk.There may be helpful info in the comments.

Find me in the FreeNAS forums

@CarlosEduardo
CarlosEduardo / Doctrine-Multi-Tenancy.md
Last active February 18, 2024 19:33
Multi-Tenancy (tenant) Strategy for Doctrine ORM
@v-jacob
v-jacob / Mailhog Bash Script (systemd)
Last active January 9, 2023 08:51
Mailhog setup with systemd
#!/usr/bin/env bash
echo ">>> Installing Mailhog"
# Download binary from github
wget --quiet -O ~/mailhog https://github.com/mailhog/MailHog/releases/download/v1.0.0/MailHog_linux_amd64
# Make it executable
chmod +x ~/mailhog
@ajaegers
ajaegers / certbot-renew
Last active December 2, 2021 23:11
Simple Certbot (Let's Encrypt) script for auto-renewal certificates
# Put this file in folder /etc/cron.d/
MAILTO="debug@example.com"
0 1 * * * root /usr/local/sbin/certbot-renew.sh