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 / unzip.bat
Last active April 28, 2023 08:34
UnRAR/UnZip files in sub directory's + rename + move
::Title: UnRAR/UnZip files in sub directory's + rename + move
::Author: Mattias Ghodsian
::Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian
::Donate Eth: 0xBBB96204E45D11C9799c6B12E6eE6F0d4A071Ef5
SETLOCAL ENABLEEXTENSIONS
FOR /D /r %%F in ("*") DO (
pushd %CD%
cd %%F
@mattiasghodsian
mattiasghodsian / functions.php
Last active April 28, 2023 08:34
[WooCommerce] Add missing Schema
/**
* Title: Add missing Schema WooCommerce
* Author: Mattias Ghodsian
* Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian
* Donate Eth: 0xBBB96204E45D11C9799c6B12E6eE6F0d4A071Ef5
**/
function woo_missing_schema_fields($data) {
global $product;
@mattiasghodsian
mattiasghodsian / readme.md
Last active December 19, 2019 15:02
[Wordpress] Manually backup WordPress

Export database with wp-cli

SSH to your site and go to the root folder of the WordPress installation and do

wp db export

Compress site

Move outside the root folder of WordPress and compress the folder (The db fils is located in the root folder and will be included).

@mattiasghodsian
mattiasghodsian / functions.php
Last active April 28, 2023 08:34
[Wordpress] SVG upload
/**
* Title: SVG upload
* Author: Mattias Ghodsian
* Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian
* Donate Eth: 0xBBB96204E45D11C9799c6B12E6eE6F0d4A071Ef5
**/
add_filter( 'upload_mimes', 'cc_mime_types' );
function cc_mime_types( $mimes ) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
@mattiasghodsian
mattiasghodsian / functions.php
Last active April 28, 2023 08:34
[FacetWP] Set custom min/max value for Single Slider
/**
* Set custom min/max value for Single Slider in FacetWP (Replace ID-HERE)
*
* Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian
* Donate Eth: 0xBBB96204E45D11C9799c6B12E6eE6F0d4A071Ef5
**/
add_filter( 'facetwp_render_output', function( $output, $params ) {
if ( isset( $output['settings']['ID-HERE'] ) ) {
$output['settings']['ID-HERE']['range'] = [
'min' => [0],
@mattiasghodsian
mattiasghodsian / size.js
Last active April 28, 2023 08:34
Get Window Width and Height on resize
/**
* Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian
* Donate Eth: 0xBBB96204E45D11C9799c6B12E6eE6F0d4A071Ef5
*/
$(window).resize(function () {
windowWidth = $(window).outerWidth();
windowHeight = $(window).height();
booking_height = $('#element').outerHeight();
scrollpos = $('.grid').height() + 85;
@mattiasghodsian
mattiasghodsian / thumbnails.ps1
Last active December 1, 2019 21:12
Generate thumbnail with ffmpeg | https://www.ffmpeg.org/download.html
Write-Host "################################ `n### Thumbnail generator by https://github.com/mattiasghodsian ### `n################################`n" -ForegroundColor Red
./ffmpeg -y -ss 00:00:10 -i input.mp4 -frames 1 -vf "drawtext=text='%{pts\:hms}': x=(w-tw)-20: y=(h-th)-20: fontcolor=white: fontsize=43: shadowcolor=black:shadowx=2:shadowy=2,fps=1/10,scale=-1:120,tile=4x4" out.png
start out.png
PAUSE
@mattiasghodsian
mattiasghodsian / tv-rename.ps1
Created December 1, 2019 21:05
Renames TV files
Write-Host "################################ `n### TV File renamer by https://github.com/mattiasghodsian ### `n################################`n" -ForegroundColor Red
$series = Read-Host -Prompt 'Enter Series name (no end space)'
Write-Host "Set $series" -ForegroundColor Red -BackgroundColor Yellow
$season = Read-Host -Prompt 'Enter Season (example 01)'
Write-Host "Set $season" -ForegroundColor Red -BackgroundColor Yellow
Write-Host "Processing"
$path = Get-Location
$int = 1
Get-ChildItem -Path $path -Recurse -Exclude *.ps1,*.zip -Filter "*" -file | %{
@mattiasghodsian
mattiasghodsian / hello.sh
Last active December 3, 2019 23:26
Terminal Welcome message
#!/bin/bash
# vars
os=$(lsb_release -sd)
codename=$(lsb_release -sc)
id=$(lsb_release -si)
pubip=$(dig @resolver1.opendns.com A myip.opendns.com +short -4)
locip=$(hostname -I | cut -d " " -f1)
ut=$(awk '{print int($1/86400)"days "int($1%86400/3600)":"int(($1%3600)/60)":"int($1%60)}' /proc/uptime)
qt=$(fortune -n 25 -s)
@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.