How To: Mac OS X and Midnight Commander “Insert” Key fix

After moving from Linux (Ubuntu) to OS X, one of the most annoying things i’ve ran into, was not having the Insert Key work as it was intended inside Midnight Commander. In Linux, while in mc, you can hit the Ins key to select or tag an individual file or folder. This is very useful when you want to cleanup and folder or move/copy stuff around. While there is the Ctrl + T shortcut (i’ve found that via: http://austringer.net/wp/index.php/2008/06/07/mac-os-x-and-midnight-commander-the-missing-insert-key/), it’s pretty annoying to use it when the muscle memory keeps going to the Ins key.

I was using BetterTouchTool to get the back/forward mouse buttons working on Yosemite, so i’ve looked around if i can setup a keyboard shortcut. And you can: I’ve setup under “Keyboard” options, an entry for iTerm (my Terminal app of choice on the mac), if the Ins key is pressed to trigger the Ctrl + T shortcut. Works like a charm in mc 🙂
Screen Shot 2015-01-27 at 5.41.10 PM

How To: Delete ALL older kernels

If you are using Ubuntu, there is a good chance you get kernel upgrades once in a while. There is no reason, after you’ve booted the new kernel and verified that everything is working properly, why you should not delete all older kernels. This will free up a bit of that root partition. If you are like me and mount / on a small SSD partition, every MB counts. For me the modules for each kernel version are around 160MB.

Here is a CLI one-liner to delete all order kernels, leaving only the latest on the system:

sudo apt-get remove --purge $(dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d')

Remove MS Word formatting using PHP regular expressions

Recently i’ve had a client which would only paste into the CMS text from MS Word. Normally a JS should have been in place to automatically strip the crazy tags Word adds, but on this project this was not the case. Here’s hos to remove MS Word formatting using PHP regular expressions:

// it will remove all  comments
preg_replace('//i', '', $string);

or 

// it will remove all  comments
preg_replace('//i', '', $string);

Print a text file to PDF from CLI on Linux

It is nice how modern text editors have that feature to “print” a file to PDF. I wanted to do the same from CLI and after a bit of looking around i’ve found this solution:

sudo apt-get install enscript
enscript lorem.txt -o - | ps2pdf - lorem.pdf

There is also the unoconv, which converts between any document format that OpenOffice understands. It uses OpenOffice’s UNO bindings for non-interactive conversion of documents.
Supported document formats include Open Document Format (.odt), MS Word (.doc), MS Office Open/MS OOXML (.xml), Portable Document Format (.pdf), HTML, XHTML, RTF, Docbook (.xml), and more.

Features:

Converts between different document formats that OpenOffice understands
OpenOffice can export to about 100 different document formats
Can be used for batch processing
Combines with asciidoc and docbook2odf/xhtml2odt to create PDF or Word (.doc) files
Can apply custom style templates during conversion (to enforce corporate identity)
Autostarts OpenOffice for processing if necessary
Can be used in a client/server environment to process documents centrally
Can influence OpenOffice filters during import and export
Supports OpenOffice on Linux, Windows and MacOSX

How to: Replace OpenOffice.org with LibreOffice on Ubuntu

Here are a few easy steps to replace openoffice.org with libreoffice on ubuntu:

CLI instructions (these will take care of removing OpenOffice.org and installing LibreOffice):

Add the PPA and install LibreOffice:

sudo add-apt-repository ppa:libreoffice/ppa
sudo apt-get update
sudo apt-get install libreoffice 

For GNOME integration (for people running default Ubuntu):

sudo apt-get install libreoffice-gnome

or for KDE Integration (for people running Kubuntu):

sudo apt-get install libreoffice-kde

As of Ubuntu 11.04, LibreOffice will replace by default OpenOffice.

Fix gitk ugly fonts in Ubuntu

I’ve recently started playing around with git and found out the power of gitk. Gitk is a small tool built using tcl/tk that helps the user visualize the changes he’s done in a graphical, easy to follow manner. By default Ubuntu 10.10 ships with tk8.4 installed by default and that makes gitk look really ugly, as tk8.4 doesn’t support antialiased fonts. To fix this problem simply install tk8.5 and make it default on your machine:

sudo apt-get install tk8.5
sudo update-alternatives --config wish
# a list will show up and you need to type in the number that corresponds to tk8.5 (in my case was 3) then hit enter.

That’s it. You can now reopen gitk and see the difference.

CD Emulation in Linux

In Linux, most of the time you don’t need any special tool to mount an image. You can just mount an .iso file using the mount tool:

sudo mount -oloop Image.iso /mnt

Unfortunately if you want to play a game that needs the CD inside the drive, mounting using the mount tool won’t make the CD available for the game (unless it didn’t worked for me). So i looked around and found that CDEmu can do the job. To install on Ubuntu add the repos from ppa:cdemu/ppa them install:

sudo add-apt-repository ppa:cdemu/ppa
sudo apt-get update
sudo apt-get install gcdemu

This will install and applet which you can use with your Gnome panel, and all the other libs that it needs. In order for the applet to work you need to start the cdemud daemon, which depends on the vhba kernel module. To start those run:

sudo modprobe vhba; cdemud &

Now you can mount images using your CDEmu applet 🙂

Install Adobe® Flash® Player “Square” on Linux

Adobe® Flash® Player “Square” is a preview release that enables native 64-bit support on Linux, Mac OS, and Windows operating systems, as well as enhanced support for Microsoft Internet Explorer 9 beta.

I’m glad to see Adobe has is finally embracing the way it should the 64 bit Platform. This release is a milestone as far as i know, as is the first one that’s released in the same time for win, mac and linux. I’ve put together a small tutorial on
how to install adobe flash player square on linux:

#!/bin/bash
# Script  created by
# Romeo-Adrian Cioaba [email protected]

echo "Stopping any Firefox that might be running"
sudo killall -9 firefox

echo "Removing any other flash plugin previously installed:"
sudo apt-get remove -y --purge flashplugin-nonfree gnash gnash-common mozilla-plugin-gnash swfdec-mozilla libflashsupport nspluginwrapper
sudo rm -f /usr/lib/mozilla/plugins/*flash*
sudo rm -f ~/.mozilla/plugins/*flash*
sudo rm -f /usr/lib/firefox/plugins/*flash*
sudo rm -f /usr/lib/firefox-addons/plugins/*flash*
sudo rm -rfd /usr/lib/nspluginwrapper

echo "Installing Flash Player Square"
cd ~
# 64 bit
wget http://download.macromedia.com/pub/labs/flashplayer10/flashplayer_square_p1_64bit_linux_091510.tar.gz
tar zxvf flashplayer_square_p1_64bit_linux_091510.tar.gz
# 32 bit
# wget http://download.macromedia.com/pub/labs/flashplayer10/flashplayer_square_p1_32bit_linux_091510.tar.gz
# tar zxvf flashplayer_square_p1_32bit_linux_091510.tar.gz
sudo cp libflashplayer.so /usr/lib/mozilla/plugins/

echo "Linking the libraries so Firefox and apps depending on XULRunner (vuze, liferea, rsswol) can find it."
sudo ln -sf /usr/lib/mozilla/plugins/libflashplayer.so /usr/lib/firefox-addons/plugins/
sudo ln -sf /usr/lib/mozilla/plugins/libflashplayer.so  /usr/lib/xulrunner-addons/plugins/

# now doing some cleaning up:
sudo rm -rf libflashplayer.so
sudo rm -rf flashplayer_square_p1_64bit_linux_091510.tar.gz

To check if the install did it’s job, you need to check about:plugins in your address bar. It should show you this for flash player:

Shockwave Flash

File: libflashplayer.so
Version:
Shockwave Flash 10.2 d161
MIME Type Description Suffixes Enabled
application/x-shockwave-flash Shockwave Flash swf Yes
application/futuresplash FutureSplash Player spl Yes

As usual, I’ve wrapped everything mentioned before into a script to easily install flash player square on Linux

If this version doesn’t work out that well for you, you can still check my other tutorial on how to install native 64bit flash player on Linux
Happy browsing!

Magento create custom order statuses

This post is just a reminder for myself. It’s taken from http://www.magentocommerce.com/boards/viewthread/9976/P30/ . The code below was tested and works just fine on magento 1.4.0.1

So to recapitulate, I did the following (citing the other guys, thanks to atlasit, ajayksh and rune00):

1) write a list of the additional statuses that you want

2) download and open the file Magento\app\code\core\Mage\Sales\etc\config.xml
(do not upload it again as soon as you’re done, you need to place it into a different folder, see below)

3) find this code:

and after that add your own new custom status

4) Now find this code, a few lines below:


  
    
    
      
    
  

and under or above this block create a new block with your own custom status:



  
    
    
      
    
  

  
    
    
      
    
  

repeat this (step 3 and 4) for each new custom status

5) So that you can change your status from the admin interface back and forth
from any current status, you need to edit again each of the status code block
as follows.

change this


    
    
      
    
  

to this


    
    
      
      
      
      
      
      
      
    
    
  

you need to do this with all of the existing statuses and the new custom statuses that you’ve just created

so that these new statuses do not only become available and visible to the admin, but also to the customer
on his “my account” page (order history, current status), you need to make the new statues visible (thanks to rune00)
with the tag , as described above.

6) After you saved your changes, upload the new config.xml file to
/app/code/local/Mage/Sales/etc/ (you will need to create that folder structure)

7)Create a file named Mage_Sales.xml with the following content (thanks to atlasit)



    
        
            true
            local
        
    

Upload it to /app/etc/modules/

that’s pretty much it.

If you got it running successfully as well, let us know so that it will help others as well.