Skip to content

Instantly share code, notes, and snippets.

@swooningfish
swooningfish / rpi_img_bkup.md
Last active September 25, 2026 20:13
backup and restore sd card images (rpi)

Backup and Restore SD Card

Identify your SD card

Insert your SD card into your Linux PC and check its device name by listing all connected

sudo fdisk -l

Look for your card based on its size (e.g., 16GB, 32GB, 64GB). It will look something like /dev/sdb or /dev/mmcblk0.

Git filter repo

Install

pip install git-filter-repo

Remove files

git filter-repo --invert-paths --path "database/large-file.sql"

Rewrite author email

@swooningfish
swooningfish / php8.0-fpm-nginx-ubuntu-20.04
Last active August 17, 2022 19:35
How to install PHP 8.0.x fpm with nginx on ubuntu 20.04
# source : https://linuxize.com/post/how-to-install-php-8-on-ubuntu-20-04/
# Enableging the PHP Repo
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
# Nginx cconfig to specify which php fpm sock to use.
/etc/nginx/sites-enabled/site.local
@swooningfish
swooningfish / security.conf
Created February 24, 2021 14:03 — forked from ambroisemaupate/security.conf
Nginx CSP example
# config to don't allow the browser to render the page inside an frame or iframe
# and avoid clickjacking http://en.wikipedia.org/wiki/Clickjacking
# if you need to allow [i]frames, you can use SAMEORIGIN or even set an uri with ALLOW-FROM uri
# https://developer.mozilla.org/en-US/docs/HTTP/X-Frame-Options
add_header X-Frame-Options SAMEORIGIN;
# when serving user-supplied content, include a X-Content-Type-Options: nosniff header along with the Content-Type: header,
# to disable content-type sniffing on some browsers.
# https://www.owasp.org/index.php/List_of_useful_HTTP_headers
# currently suppoorted in IE > 8 http://blogs.msdn.com/b/ie/archive/2008/09/02/ie8-security-part-vi-beta-2-update.aspx
@swooningfish
swooningfish / get-order-detail-by-order-id.php
Created September 18, 2019 19:22 — forked from web-hat/get-order-detail-by-order-id.php
Works with WooCommerce 3.x or above
<?php
if (!function_exists('getOrderDetailById')) {
//to get full order details
function getOrderDetailById($id, $fields = null, $filter = array()) {
if (is_wp_error($id))
return false;
@swooningfish
swooningfish / yoast_seo_canonical_change_home_url_slash.php
Created February 20, 2019 13:46 — forked from amboutwe/yoast_seo_canonical_change_woocom_shop.php
Code snippets for the Yoast SEO canonical output
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Add Trailing Slash to Home Canonical - Yoast SEO
* Credit: Unknown
* Last Tested: Unknown
*/
add_filter( 'wpseo_canonical', 'yoast_seo_canonical_change_home_url_slash' );
function yoast_seo_canonical_change_home_url_slash( $canonical_url ) {
@swooningfish
swooningfish / .gitignore
Created February 18, 2019 09:58 — forked from octocat/.gitignore
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@swooningfish
swooningfish / cs-repeater-download.php
Created August 16, 2018 11:26
Make an ACF repeater field downloadable as a CSV file (without titles)
<?php
/**
* Plugin Name: CS Repeater Download
* Plugin URI: https://casperschultz.dk
* Description: Plugin for downloading repeater field data.
* Author: Casper Schultz
* Author URI: https://casperschultz.dk
* Text Domain: cs-repeater-download
* Domain Path: /lang/
* Version: 1.0
@swooningfish
swooningfish / wordpress-hide-editor-on-pages.php
Created January 4, 2018 15:10 — forked from atomtigerzoo/wordpress-hide-editor-on-pages.php
Wordpress: Hide the editor on defined pages
/**
* Hide the main editor on specific pages
*/
define('EDITOR_HIDE_PAGE_TITLES', json_encode(array()));
define('EDITOR_HIDE_PAGE_TEMPLATES', json_encode(array('template-cars.php')));
/**
* Hide the main editor on defined pages
*