Skip to content

Instantly share code, notes, and snippets.

@hansspiess
hansspiess / terminal.sh
Last active May 2, 2020 16:44
Create .htaccess files for standard joomla install to secure folders
# Inside the root directory of the Joomla 3 instance, run these commands to add .htaccess files
# to joomla directories (except ./administrator) that prevent direct access to them.
# Also see https://www.joomla-security.de/dateien-verzeichnisse/htaccess-einstellungen.html
# Generally block access from outside
echo "<Files "*.*">
Deny from all
</Files>" > ./bin/.htaccess; cp -i ./bin/.htaccess ./cache/.htaccess; cp -i ./bin/.htaccess ./cli/.htaccess; cp -i ./bin/.htaccess ./includes/.htaccess; cp -i ./bin/.htaccess ./language/.htaccess; cp -i ./bin/.htaccess ./layouts/.htaccess; cp -i ./bin/.htaccess ./libraries/.htaccess; cp -i ./bin/.htaccess ./logs/.htaccess; cp -i ./bin/.htaccess ./tmp/.htaccess
# Block all except media files: First, create .htaccess file with
@hansspiess
hansspiess / .htaccess
Created May 1, 2020 16:39
Rewrite joomla article urls after turning on new routing system
# When changing joomla routing to not output article ids, google must be told where those articles are.
# Beware! This breaks if an article slug contains a number!
# https://docs.joomla.org/J3.x:New_Routing_System
RewriteRule category\/([a-z]*)\/(\d+)-([^/]*) https://www.site.example/category/$1/$3 [R=301,L]
@hansspiess
hansspiess / .htaccess
Created June 28, 2019 00:44
Create a static copy of a phpwcms site
# Redirect Query String to Html file.
<IfModule mod_rewrite.c>
RewriteCond %{QUERY_STRING} ([a-z0-9]+) [NC]
RewriteRule (.*) /%1.html? [R=301,L]
</IfModule>
@hansspiess
hansspiess / node, nvm
Created June 26, 2018 12:22
update node on mac
# node version manager: list available versions
nvm ls
# nvm: see https://github.com/creationix/nvm
# node: get active version
node -v
# activate node version via nvm
nvm use 8
@hansspiess
hansspiess / wp-tweaks.php
Last active December 14, 2017 03:00
wordpress tweaks
<?php
// remove wp generator
// https://css-tricks.com/snippets/wordpress/remove-wp-generator-meta-tag/
remove_action('wp_head', 'wp_generator');
// disable emojis
// http://wordpress.stackexchange.com/questions/185577/disable-emojicons-introduced-with-wp-4-2
function wpt_disable_emojis() {
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
<?php
define'ABSPATH', dirname__FILE__ ;
require_onceABSPATH '../path/to/wp-config.php';
@hansspiess
hansspiess / mail.php
Last active February 25, 2016 10:19
Script for sending E-Mails from Localhost for testing purposes. More (german language) at http://www.hansspiess.de/html-e-mail-entwicklung-und-testing-mit-foundation-for-emails-gmail-und-postfix/698/
<?php
// get args from command line
// http://stackoverflow.com/questions/6826718/pass-variable-to-php-script-running-from-command-line
if ( defined('STDIN') ) {
$dir = $argv[1] ? $argv[1] : './';
$ext = $argv[2] ? $argv[2] : 'html';
} else {
die( 'not on a local machine.' );
}
@hansspiess
hansspiess / terminal.ini
Last active October 30, 2016 10:10
useful terminal commands
# find all php.ini files on machine from terminal.
mdfind php.ini | grep php.ini
# copy local file to remote machine via scp
scp -P 92 /path/filename.ext user@hostname.com:~/path
# delete non-empty directory
rm -rf <dirname>
# unzip zip file in current dir
curl -L http://npmjs.org/install.sh | sudo sh
@hansspiess
hansspiess / Preferences.sublime-settings
Last active August 29, 2015 14:27
My current Sublime Text 3 User Settings
{
"enable_tab_scrolling": true,
"ignored_packages":
[
"Vintage"
],
// theming & colors
"color_scheme": "Packages/Base16 Color Schemes/base16-ocean.dark.tmTheme",