Skip to content

Instantly share code, notes, and snippets.

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

Rotsen Mark Acob webdevsuperfast

🏠
Working from home
View GitHub Profile
@webdevsuperfast
webdevsuperfast / convert.sh
Created October 13, 2021 01:53
Convert Apple Lossless to FLAC
#!/bin/sh
for f in *.m4a; do ffmpeg -i "$f" -c:a flac "${f%.m4a}.flac"; done
@webdevsuperfast
webdevsuperfast / cdparanoia.sh
Created October 13, 2021 01:05
Rip Audio CDs with CDParanoia & FFMpeg
#!/bin/sh
cdparanoia -Q 2>&1 |
grep "^ *[1-9]" |
sed -e 's/^ *\|\..*//g' |
while read t; do
cdparanoia $t - | ffmpeg -i pipe: -c:a 128k -ar 44100 -ac 2 -y "rip $t.mp3";
done
@webdevsuperfast
webdevsuperfast / zsh.md
Last active April 20, 2024 21:48
Install ZSH using Homebrew and set as default shell in Linux/WSL

Install ZSH via HomeBrew

brew install zsh

Add ZSH to /etc/shells

echo $(which zsh) | sudo tee -a /etc/shells

Set ZSH as default user shell

sudo chsh -s $(which zsh) $USER

Execute Shell or just restart terminal to take effect

@webdevsuperfast
webdevsuperfast / doh.rsc
Created June 3, 2021 01:33 — forked from Lillecarl/doh.rsc
MikroTik Cloudflare anti phising DOH
{
/tool fetch url=https://curl.haxx.se/ca/cacert.pem
/certificate import file-name=cacert.pem passphrase=””
/ip firewall layer7-protocol
add name=security.cloudflare-dns.com regexp=security.cloudflare-dns.com
/ip dns
set allow-remote-requests=yes cache-max-ttl=1h servers=1.1.1.2,1.0.0.2,2606:4700:4700::1112,2606:4700:4700::1002 use-doh-server=https://security.cloudflare-dns.com/dns-query verify-doh-cert=yes
/ip firewall filter
add action=drop chain=output comment="drop dns output if not looking for cloudflare DOH servers." dst-port=53 layer7-protocol=!security.cloudflare-dns.com out-interface-list=WAN protocol=tcp
add action=drop chain=output comment="drop dns output if not looking for cloudflare DOH servers." dst-port=53 layer7-protocol=!security.cloudflare-dns.com out-interface-list=WAN protocol=udp
@webdevsuperfast
webdevsuperfast / functions.php
Created April 14, 2021 01:07
Redirect posts within a date range to new URL
<?php
/**
* Redirect posts within a date range to new URL with wp_redirect()
* @url https://paulund.co.uk/get-posts-between-certain-dates-wordpress-rest-api
*/
add_action( 'template_redirect', function() {
$args = array(
'date_query' => array(
array(
'after' => 'November 1, 2020',
@webdevsuperfast
webdevsuperfast / functions.php
Last active April 14, 2021 01:10
FluentForms Server-side Facebook Conversions API
<?php
/**
* Functions
*
* @package Facebook Conversions API
* @since 1.0
* @link https://rotsenacob.com/
* @author Rotsen Mark Acob <rotsenacob.com>
* @copyright Copyright (c) 2020, Rotsen Mark Acob
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
@webdevsuperfast
webdevsuperfast / functions.php
Last active September 20, 2020 03:24
Validate US Phone Number Format in Contact Form 7
<?php
// Validate Phone Numbers for US
function validate_phone( $phone ) {
return preg_match( "/^\(?([0-9]{3})\)?[-.●]?([0-9]{3})[-.●]?([0-9]{4})$/i", $phone ); // @link https://www.oreilly.com/library/view/regular-expressions-cookbook/9781449327453/ch04s02.html
}
add_filter( 'wpcf7_validate_tel', 'tc_validate_tel', 20, 2 );
add_filter( 'wpcf7_validate_tel*', 'tc_validate_tel', 20, 2 );
function tc_validate_tel( $result, $tag ) {
@webdevsuperfast
webdevsuperfast / functions.php
Last active September 20, 2020 03:24
Validate US ZIP Code with Zippopotamus and Contact Form 7
<?php
/**
* Functions
*
* @package Twenty Twenty Child
* @since 1.0
* @link https://rotsenacob.com
* @author Rotsen Mark Acob <rotsenacob.com>
* @copyright Copyright (c) 2020, Rotsen Mark Acob
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
// modifys contact form 7's default select value of --- to Please select...
function my_wpcf7_form_elements($html) {
$text = 'Please select...';
$html = str_replace('<option value="">---</option>', '<option value="">' . $text . '</option>', $html);
return $html;
}
add_filter('wpcf7_form_elements', 'my_wpcf7_form_elements');
// Modify multiple selects
function my_wpcf7_form_elements($html) {