Skip to content

Instantly share code, notes, and snippets.

@hansspiess
hansspiess / terminal.sh
Last active May 2, 2020
Create .htaccess files for standard joomla install to secure folders
View terminal.sh
# 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
Rewrite joomla article urls after turning on new routing system
View .htaccess
# 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 Jun 28, 2019
Create a static copy of a phpwcms site
View .htaccess
# 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 Jun 26, 2018
update node on mac
View node, nvm
# 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 Dec 14, 2017
wordpress tweaks
View wp-tweaks.php
<?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 );
View wp-config.php
<?php
define'ABSPATH', dirname__FILE__ ;
require_onceABSPATH '../path/to/wp-config.php';
@hansspiess
hansspiess / mail.php
Last active Feb 25, 2016
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/
View mail.php
<?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 Oct 30, 2016
useful terminal commands
View terminal.ini
# 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
View reinstall-npm.txt
curl -L http://npmjs.org/install.sh | sudo sh
@hansspiess
hansspiess / Preferences.sublime-settings
Last active Aug 29, 2015
My current Sublime Text 3 User Settings
View Preferences.sublime-settings
{
"enable_tab_scrolling": true,
"ignored_packages":
[
"Vintage"
],
// theming & colors
"color_scheme": "Packages/Base16 Color Schemes/base16-ocean.dark.tmTheme",