Skip to content

Instantly share code, notes, and snippets.

@fabiomaggio
fabiomaggio / delete-remote-tags
Last active Jan 4, 2021
Delete all the remote tags of a Git repo
View delete-remote-tags
git tag -l | xargs git tag -d && git fetch && git tag -l | xargs git push --delete origin && git tag -l | xargs git tag -d
@fabiomaggio
fabiomaggio / git-filter-branch-move-files.md
Last active Apr 13, 2021
Use git filter-branch to move all projects files to a subdir and rewrite all commits
View git-filter-branch-move-files.md
  1. Clone project

  2. Checkout all branches that contain the files that should be moved

  3. Delete the remote

  4. Run the filter-branch command:

    git filter-branch --tree-filter 'mkdir -p /path/to/tmp; mv * /path/to/tmp; mkdir subdir; mv /path/to/tmp/* subdir/' --tag-name-filter cat --prune-empty -- --all
    • All files are first copied to a temporary dir and move from there to the new destination
    • Existing tags are updated
@fabiomaggio
fabiomaggio / ckeditor-responsive-images.js
Created Jan 22, 2016
Make inserted images in CKEditor automatically responsive
View ckeditor-responsive-images.js
// If you want inserted images in a CKEditor to be responsive
// you can use the following code. It creates a htmlfilter for the
// image tag that replaces inline "width" and "style" definitions with
// their corresponding attributes and add's (in this example) the
// Bootstrap "img-responsive" class.
CKEDITOR.on('instanceReady', function (ev) {
ev.editor.dataProcessor.htmlFilter.addRules( {
elements : {
img: function( el ) {
// Add bootstrap "img-responsive" class to each inserted image
@fabiomaggio
fabiomaggio / mysql-ssh-tunnel
Created Oct 29, 2014
Setup SSH tunnel for MySQL connection in HeidiSQL
View mysql-ssh-tunnel
1. Create SSH tunnel with following command: ssh -L 3307:localhost:3306 user@host
2. Use the following settings in HeidiSQL:
- Hostname: localhost
- User: mysqluser
- Password: mysqluser password
- Port: 3307
Another method is described here: http://www.mattmuller.info/2011/04/remote-mysql-with-heidisql-and-plink/
@fabiomaggio
fabiomaggio / whitelight-provisioner
Last active Aug 29, 2015
Shell provisioner for a Whitelight screen
View whitelight-provisioner
#!/usr/bin/env bash
# Update the system
apt-get update
# Install apache
apt-get install -y apache2
# Install php
apt-get install -y php5 php-pear php5-mysql
@fabiomaggio
fabiomaggio / feature-detection.js
Last active Aug 29, 2015
Simple feature detection for modern browsers
View feature-detection.js
// HTML5 browser
if('querySelector' in document
&& 'localStorage' in window
&& 'addEventListener' in window
&& Array.prototype.forEach) {
}