Git rollback to particular commit

Use gitk to find out which commit you want to rollback and do the following:

git reset --hard 53c309929253a2a

Read the content of zip archive without extraction

unzip -l archive.zip

Alter pdf file with Gimp

gimp document.pdf

1. click ‘Select All’ and open and edit it

2. When you are about to save, gimp can’t save multipages pdf directly. You’ll need to use an intermediate file format

3. Install ImageMagick

sudo apt-get install imagemagick

4. Save in Gimp
File -> Export -> document.mng

5. Export to pdf in a command line

convert -reverse document.mng document.pdf

Rename files in folder

for i in *.png; do mv "$i" "${i/.png/t.png}"; done

Fastest example to output image

$file = 'myimage.png';
$size = getimagesize($file);
 
$fp = fopen($file, 'rb');
 
if ($size and $fp)
{
    header('Content-Type: '.$size['mime']);
    header('Content-Length: '.filesize($file));
    fpassthru($fp);
}

git new branch

git checkout -b new_branch_name

git remove remote branch

git push origin --delete feature/login
git push origin :feature/login

Run command on Ubuntu startup as superuser

vi /etc/rc.local

Flush Redis cache

redis-cli flushall

Joomla check if admin logged-in

<?php
define( '_JEXEC', 1 );
define( 'JPATH_BASE', realpath(dirname(__FILE__).'/../../..' ));
 
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
 
$mainframe =& JFactory::getApplication('administrator');
$mainframe->initialise();
 
$app =& JFactory::getApplication();
$user =& JFactory::getUser();
 
if($app->isAdmin() && !$user->id) {
header('Location: /administrator');
exit();
}
?>