Skip to content

Instantly share code, notes, and snippets.

@fabiomaggio
fabiomaggio / delete-remote-tags
Last active January 4, 2021 10:38
Delete all the remote tags of a Git repo
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 October 20, 2022 08:48
Use git filter-branch to move all projects files to a subdir and rewrite all commits
  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 January 22, 2016 19:10
Make inserted images in CKEditor automatically responsive
// 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 October 29, 2014 00:21
Setup SSH tunnel for MySQL connection in HeidiSQL
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 August 29, 2015 14:05
Shell provisioner for a Whitelight screen
#!/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 August 29, 2015 14:02
Simple feature detection for modern browsers
// HTML5 browser
if('querySelector' in document
&& 'localStorage' in window
&& 'addEventListener' in window
&& Array.prototype.forEach) {
}