Skip to content

Instantly share code, notes, and snippets.

View deviationist's full-sized avatar

Robert S. deviationist

  • Oslo-area, Norway
View GitHub Profile
@deviationist
deviationist / .htaccess
Last active July 3, 2020 09:47
Prevent access to WP Admin and wp-login.php via .htaccess, but allow access to admin-ajax.php
# Prevent WP Admin from being accessed (except admin-ajax.php)
#RewriteCond %{HTTP_HOST} ^(|www\.)yourdomain\.(com|net|org)$ [NC] # This line is optional, but useful if you only want to apply the rules to certain domains
RewriteCond %{REQUEST_URI} ^/wp-admin/ [NC]
RewriteCond %{REQUEST_URI} !^/wp-admin/admin-ajax\.php$ [NC]
RewriteRule (.*) %{REQUEST_SCHEME}://%{HTTP_HOST}/ [L,R=301]
# Prevent the WP login form from being accessed
#RewriteCond %{HTTP_HOST} ^(|www\.)yourdomain\.(com|net|org)$ [NC] # This line is optional, but useful if you only want to apply the rules to certain domains
RewriteCond %{REQUEST_URI} ^/wp-login\.php$ [NC]
RewriteRule (.*) %{REQUEST_SCHEME}://%{HTTP_HOST}/ [L,R=301]
@deviationist
deviationist / Ghost Inspector - checkbox state checker v2
Last active September 24, 2020 00:46
A neat JS function that you can use with Ghost Inspector to check if a checkbox/radio button is checked, and it also gives a visual feedback (like the native ones from other checks)
function GI_itemHaveCheckedState(element, state, delay) {
var valid = element.checked === state;
if ( valid ) {
if ( ! delay ) delay = 0;
setTimeout(function() {
element.style.outline = '5px solid rgba(98, 191, 103, 1)';
setTimeout(function() {
element.style.outline = 'initial';
}, 500);
}, delay);
#!/bin/bash
find . -type f -name "*.flac" | while read line; do
newFilename="${line/%flac/aiff}"
ffmpeg -y -nostdin -i "${line}" -write_id3v2 1 -c:v copy "${newFilename}"
rm "${line}"
done
@deviationist
deviationist / WordPress.org Plugin Repository - delete tag from SVN
Last active April 29, 2021 09:37
A quick and easy way to delete a tag from a WP plugin using CLI.
svn delete http://plugins.svn.wordpress.org/plugin-slug/tags/1.0.0/ -m "Revert" --username your-username
@deviationist
deviationist / audio-convert.sh
Last active November 20, 2021 02:24
FFMPEG audio convert script (FLAC ➜ AIFF, WAV ➜ AIFF, M4A ➜ MP3)
#!/bin/bash
toConvertFolder="to-convert/"
convertedFolder="converted/"
mkdir -p $convertedFolder
# FLAC to AIFF
find $toConvertFolder -type f -name "*.flac" | while read line; do
newFilename="${line/%.flac/.aiff}"
@deviationist
deviationist / audio-reduce-sample-rate.sh
Last active November 20, 2021 02:23
FFMPEG reduce audio sample rate (AIFF, WAV)
#!/bin/bash
toConvertFolder="to-convert/"
convertedFolder="converted/"
maxKhz=48000
mkdir -p $convertedFolder
formats=( "aiff" "wav" )
for i in "${formats[@]}"
@deviationist
deviationist / curl-get-request-only-headers.sh
Last active December 23, 2022 13:58
cURL GET-request returning only headers
curl -v -s http://awesome-site.com 1> /dev/null
@deviationist
deviationist / JSON-data for testing
Created April 13, 2022 10:17
json-test-data.json
[
{
"name": "Ima Prohaska",
"email": "[email protected]",
"phone": "+17273931388",
"company": "Sawayn-Mueller",
"company_email": "[email protected]",
"company_phone": "1-540-346-3726",
"project_url": "pfeffer.com",
"address": "7185 Considine Shore\nNew Justyn, ID 15204"
@deviationist
deviationist / open-port-from-wsl-to-local-network.sh
Last active December 23, 2022 13:58
Open port from WSL to local network
netsh interface portproxy add v4tov4 listenport=3000 listenaddress=0.0.0.0 connectport=3000 connectaddress=192.168.0.69
wsl -- ip -o -4 -json addr list eth0 `
| ConvertFrom-Json `
| %{ $_.addr_info.local } `
| ?{ $_ }