Skip to content

Instantly share code, notes, and snippets.

View mattiasghodsian's full-sized avatar
🏠
Working from home

mattiasghodsian

🏠
Working from home
View GitHub Profile
@mattiasghodsian
mattiasghodsian / readme.md
Created May 10, 2021 16:53
Setup RAIDZ on Ubuntu Server 20.04 LTS

Setup RAIDZ on Ubuntu Server 20.04 LTS

In this walkthrough we'll be using 4 brand new Seagate IronWolf Pro 10TB 7200rpm 256MB hard drives to setup a ZFS storage pool (RAIDZ 10).

1. ZFS

If you don't have ZFS already installed go ahead and run

sudo apt install zfsutils-linux

2. Disk Identifier & Sector sizes

Before we do anything with the drives we need the disk identifier and sector size for each drive for step 3.

@mattiasghodsian
mattiasghodsian / thumbnail-grid-generator.ps1
Created April 15, 2024 22:15
[PowerShell] Thumbnail Grid Generator with ffmpeg
# Author: Mattias Ghodsian
# Donate Eth: 0xBBB96204E45D11C9799c6B12E6eE6F0d4A071Ef5
# Donate coffee: https://www.buymeacoffee.com/mattiasghodsian
$ffmpeg = ".\ffmpeg.exe"
$directory = $PWD.Path
$video = ".\video.mkv"
$filenameWithExtension = Split-Path -Leaf $video
# Specify the starting time offset
@mattiasghodsian
mattiasghodsian / readme.md
Last active April 14, 2024 16:13
How to create a Windows application Installer with NSIS

Nullsoft Scriptable Install System is also known as NSIS open-source system to create Windows application installers. NSIS is a script-based system allowing you to create the logic behind your installer/setup file in a complex way to install tasks. NSIS offers plug-ins and other scripts, for example, to download/install 3rd-party files or communicate with Windows.

The tutorial application

This tutorial will guide you through installing and creating your first Windows installer with Nullsoft Scriptable Install System and how to compile your project. Captura Portable will be used as "our application" for the sake of this tutorial.

Installation

Head to NSIS official site and download the latest release and install it. Run NSIS and you will be welcomed with a menu like below, It's always a good practice to read the Documentation before jumping in t

@mattiasghodsian
mattiasghodsian / readme.md
Last active March 19, 2024 23:35
Valheim Dedicated Server Setup on Ubuntu 20.04.1 LTS

Port forwarding

Open ports (udp)

2456 2457 2458 27060

Uncomplicated Firewall

sudo ufw allow 2456/udp
@mattiasghodsian
mattiasghodsian / readme.md
Last active February 27, 2024 16:42
Install Go Lang on Ubuntu/Pop!_OS 20.04 LTS (zsh)

Install Go Lang on Ubuntu/Pop!_OS 20.04 LTS (zsh)

  • Get Go lang from golang.org
  • Extract the archive sudo tar -xvf go1.15.6.linux-amd64.tar.gz
  • Move the go directory to /usr/local directory sudo mv go /usr/local
  • Add global variable to your shell (zsh) nano ~/.zshrc
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
@mattiasghodsian
mattiasghodsian / readme.md
Created November 6, 2019 16:22
How to install and use youtube-dl

Ever needed a tutorial or just download non copyrighted material from YouTube to watch or listen offline?

YouTube-dl is a command-line tool which is open source and can be used to download videos from YouTube, Facebook, and other popular sites, see the full list here.


NOTE: Keep in mind some media contains copyrighted material.


@mattiasghodsian
mattiasghodsian / readme.md
Created August 31, 2023 12:02
[Laravel] Removing API Prefix for API Subdomains

If you are utilizing Laravel as a backend platform serving API routes via a subdomain https://api.example.com/, you may find that the default routing configuration for the api route is not needed.

Edit /app/Providers/RouteServiceProvider.php and locate the prefix('api') line and comment it out or remove it altogether, in my case i don't need the web route group so i commented that part out.

<?php

namespace App\Providers;

use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
@mattiasghodsian
mattiasghodsian / .bash_aliases
Last active August 31, 2023 07:58
My bash aliases
###########################################################################
# #
# ------- Aliases -------- #
# --------- #
# ------- https://gist.github.com/mattiasghodsian ------- #
# #
# # Usage: #
# dpanic : FBI panic remove containers (0.0) #
# dex <container>: execute shell inside <container> #
# dnames : names of all running containers #
@mattiasghodsian
mattiasghodsian / wc-kco-validate-customer-age-modded.php
Last active April 28, 2023 08:39
Update code snippet of wc-kco-validate-customer-age.php to only accept purchases from people over 18 years
<?php
/**
* Title: WooCommerce - Klarna payment gateway (Modded)
* Author Niklas Hogefjord
* Editor: Mattias Ghodsian
* Description: Only accept purchases from customer over 18 years of age.
* Source: https://gist.github.com/NiklasHogefjord/07e60a4f08799c3cfdb0870fb5481f71
* Klarna: https://developers.klarna.com/en/se/kco-v2/checkout-api
* Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian
**/
@mattiasghodsian
mattiasghodsian / woocommerce-group-products.php
Last active April 28, 2023 08:39
Group simple/variations and group all variations that had same parent
/**
* Title: Group simple/variations
* Author Mattias Ghodsian
* Description: Group simple/variations and group all variations that had same parent
* Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian
**/
function wooGroupProducts(){
$args = array( 'post_type' => 'product', 'posts_per_page' => -1 );
$loop = new WP_Query( $args );