Skip to content

Instantly share code, notes, and snippets.

View joostvanveen's full-sized avatar

Joost van Veen joostvanveen

View GitHub Profile
@joostvanveen
joostvanveen / capslockCheck.html
Created October 8, 2015 09:03
jQuery script that displays a warning if capslock is on. Handy for password inputs.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Capslock check</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<style>
@joostvanveen
joostvanveen / .htaccess
Last active April 22, 2021 20:12
Force SSL in .htaccess
# Force SSL, but only for a certain domain
# At the same time, redirect http non-www ad www to https://www
# Replace example\.com and example.com with your domain
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$
RewriteRule (.*) https://www.example.com/$1 [R=301,L]
@joostvanveen
joostvanveen / .htaccess
Last active November 15, 2015 11:14
Canonical redirect in .htaccess - force www. prefix on domain
# Canonical redirect - force www. prefix on domain
RewriteCond %{HTTP_HOST} ^mydomain\.nl$ [NC]
RewriteRule ^(.*)$ https://www.mydomain.nl/$1 [R=301,L]
@joostvanveen
joostvanveen / .htaccess
Last active September 10, 2023 02:37
.htaccess Security
######################################################################
## Word to the wise ##
## It is best to keep your htaccess files as clean as possible ##
## and set as many specs in your Apache config as you can. ##
## Htaccess slows down Apache. ##
## Review the entire file before use, especially the TODO sections. ##
######################################################################
Options -MultiViews
Options +FollowSymLinks
@joostvanveen
joostvanveen / .gitignore
Last active April 10, 2019 08:54
Default gitignore entrances for IDEs, OS specific hidden files, tarballs and compressed files. Use this for new projects.
############ Project specific rules ###############
# Project specific rules go here...
# To ignore a folder, add asterix -> folder/*
# This way, unignored files like .keep and .gitkeep will still be added to git
################# Global rules ####################
## Never ignore .gitignore
!.gitignore
## Dependencies
@joostvanveen
joostvanveen / .htaccess
Last active April 1, 2020 05:26
Force trailing slash for SEO purposes using htaccess 301 redirects (mod_rewrite) - but on GET requests only, to avoid losing POST data on a POST request to a URI without a trailing slash.
# Force trailing slash for SEO purposes
RewriteEngine On
# For GET and HEAD requests only. We do not want to redirect posted forms and such, or we'll lose all POST data!
RewriteCond %{REQUEST_METHOD} ^(GET|HEAD)$
# Not for actual files. We do not want to redirect urls like test.jpg to test.jpg/
RewriteCond %{REQUEST_FILENAME} !-f
# Redirect to trailing slash if no slash is present in URI
@joostvanveen
joostvanveen / get-magento-version-number.sh
Created January 25, 2016 14:47
Get Magento version number from command line
# Echo Magento version number
cd /path/to/magento/webroot
php -r "include 'app/Mage.php'; echo 'Magento version is: ', Mage::getVersion(); "
# purge varnish cache in Varnish 3
varnishadm "ban.url ."
# purge varnish cache in Varnish 4
varnishadm "ban req.url ~ /"
@joostvanveen
joostvanveen / remove_big_files-from_git_history.sh
Created March 17, 2016 17:24
Remove big files from git history to avoid error
# This command removes any sql.gz SQL backup file from history, even if it was committed a few commits ago.
# Handy for big files that throw an error when trying to push. As always, rewriting git history is a
# dangerous action! Do not rewrite for commits that have already been fetched by fellow developers.
git filter-branch --prune-empty -d /path/to/tmp/scratch/dir --index-filter "git rm --cached -f --ignore-unmatch *.sql.gz" --tag-name-filter cat -- --all
@joostvanveen
joostvanveen / delete_products_and_categories_from_magento.sql
Created March 25, 2016 12:58
Delete all products and categories from Magento 1.9.2
-- Foreign key check will cascade-delete all related data
-- Delete all products
DELETE FROM catalog_product_entity;
-- Reset the autoincrement for products
ALTER TABLE catalog_product_entity AUTO_INCREMENT = 1;
-- Delete all categories
DELETE FROM catalog_category_entity WHERE `entity_id` > 2;