Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Creating new open source stuff that you will like

Daniele Scasciafratte Mte90

🎯
Creating new open source stuff that you will like
View GitHub Profile
@Mte90
Mte90 / rss.opml
Created Dec 15, 2020
My RSS feed
View rss.opml
<?xml version="1.0" encoding="UTF-8"?>
<opml version="2.0">
<head>
<title>FreshRSS</title>
<dateCreated>Tue, 15 Dec 2020 12:05:01</dateCreated>
</head>
<body>
<outline text="Altro">
<outline text="MGMT Magazine" type="rss" xmlUrl="http://feeds.feedburner.com/MgmtMagazine" htmlUrl="https://mgmtmagazine.com/" description=""/>
<outline text="Synthesia Updates" type="rss" xmlUrl="https://www.synthesiagame.com/forum/app.php/feed/news" htmlUrl="https://www.synthesiagame.com/forum/index.php" description=""/>
@Mte90
Mte90 / bbb-register-merge.php
Last active Jan 25, 2021
WP integration with BBB to start/stop and download a video call recording
View bbb-register-merge.php
<?php
/*
Plugin Name: BBB Register
Plugin URI:
Description: Add support to start/stop and download videos from the BBB instance of Merge-IT.
Author: Daniele Mte90 Scasciafratte
Version: 1.0.0
Author URI:
*/
@Mte90
Mte90 / gitlab-ci.yml
Last active Aug 12, 2020
GitLab CI version for WPBP
View gitlab-ci.yml
image: jakzal/phpqa:alpine
cache:
paths:
- vendor/
stages:
- Code Quality
coding-standards:
@Mte90
Mte90 / backup.sh
Created Jul 7, 2020
Backup to webdav files and WordPress DB
View backup.sh
#!/bin/sh
today=$(date +"%Y-%m-%d")
path=$(date +"%Y/%m/%d")
rm -rf ./backups
mkdir ./backups
tar --exclude='./public_html/cgi-bin' --exclude='*.zip' --exclude='./public_html/wp-content/cache' -zcvf ./backups/$today.tar.gz ./public_html > /dev/null
./wp db export --add-drop-table --path=./public_html/ - | gzip > "./backups/$today.sql.gz"
curl --user "user:pass" -T "./backups/$today.tar.gz" "https://domain.com/remote.php/webdav/folder/$path/domain-$today.tar.gz"
@Mte90
Mte90 / remove_gutenberg_block.php
Created Jun 11, 2020
Remove WordPress Gutenberg block in content
View remove_gutenberg_block.php
<?php
function remove_block_gutenberg( $content, $blockname ) {
$blockname = str_replace('/', '\/',preg_quote($blockname));
return preg_replace('/\<\!\-\- ' . $blockname . '[^)]+\/' . $blockname . ' \-\-\>/', '', $content);
}
// Based on this ticket https://wordpress.org/support/topic/strip-table-of-content-from-excerpt/
// There is a block that we don't want on excerpt automatically generated,
// Automatic excerpt cut the content and this can generate a broken content
@Mte90
Mte90 / snippet.php
Created Apr 30, 2020
W3TC generate minified filename by checksum
View snippet.php
<?php
// Based on https://wordpress.org/support/topic/how-to-change-minified-css-file-name/
// Get all the files, read them, concat them, get a md5 hash, cut at 10 and generate a new filename
// Why?
// W3TC generate the hashname based on the filenames so not invalidate the cache if there are changes
add_filter('w3tc_minify_urls_for_minification_to_minify_filename', 'w3tc_filename_filter', 20, 3);
function w3tc_filename_filter($minify_filename, $files, $type ){
$path_parts = pathinfo( $minify_filename );
$content = '';
@Mte90
Mte90 / clean.sh
Created Mar 17, 2020
Clips dataset parser and cleaner
View clean.sh
#!/usr/bin/env bash
function extract() {
echo "Estraggo $1.rar"
unrar e "./$1.rar" \*.txt \*.wav './clips-mitads/' -o+
}
if [ ! -d './clips-mitads' ]; then
mkdir './clips-mitads'
fi
@Mte90
Mte90 / Customfile
Last active Jan 15, 2020
2 new commands for VVV
View Customfile
class VVVScripts < Vagrant.plugin(2, :command)
def self.synopsis
"Execute script from /config/homebin/"
end
def execute
with_target_vms(nil, single_target: true) do |vm|
@env.ui.output "#{$yellow}Executing #{$red}#{ARGV[1]}#{$creset}\n"
vm.action(:ssh_run, ssh_run_command: "/srv/config/homebin/#{ARGV[1]}" )
end
@Mte90
Mte90 / alter-login.php
Created Dec 3, 2019
Send email to user if not logged after 3 weeks
View alter-login.php
<?php
/**
* Plugin Name: Alert Last Login
* Plugin URI:
* Description:
* Version: 1.0.0
* Author: Codeat
* Author URI: http://codeat.it
* License: GPL-2.0+
@Mte90
Mte90 / block-wprestapi-loggedonly-orbykeyword.php
Created Nov 26, 2019
Block WordPRess rest api except logged user or if there is a parameter in the url
View block-wprestapi-loggedonly-orbykeyword.php
<?php
add_filter('rest_authentication_errors', function ($result) {
if (!empty($result)) {
return $result;
}
$access = is_user_logged_in();
if ( !$access ) {
if ( !isset($_GET['iwantthem']) || isset($_GET['iwantthem']) && $_GET['iwantthem'] !== 'yes' ) {