Friday, January 10, 2014

Installing Imapfilter

I installed Imapfilter to sort mails on the imap server (imap.domeneshop.no) I connect to into folder (The server does not support Sieve (and managesieve or sieverules plugins for Roundcube), which is an alternative that does not require a running program).

Here is how:

* Download imapfilter from github: https://github.com/lefcha/imapfilter/archive/master.zip
unzip -d imapfilter.master.zip
cd imapfilter-master/src
sudo apt-get install libssl-dev
sudo apt-get install lua5.1-dev
* Edit imapfilter.h, core.c, lua.c, pcre.c, and system.c and add lua5.1/ before lua.h, lualib.h, and lauxlib.h
sudo apt-get install libpcre3-dev
* Update Makefile to say -llua5.1 instead of -llua
make all
sudo make install



Errors I got:
auth.c:4:11: fatal error: openssl/hmac.h: No such file or directory

lua.c:5:17: fatal error: lua.h: No such file or directory
compilation terminated.
make: *** [lua.o] Error 1


pcre.c:7:18: fatal error: pcre.h: No such file or directory

cc -o imapfilter   auth.o buffer.o cert.o core.o file.o imapfilter.o list.o log.o lua.o memory.o misc.o namespace.o pcre.o regexp.o request.o response.o session.o signal.o socket.o system.o -lm -llua -lpcre -lssl -lcrypto
/usr/bin/ld: cannot find -llua
collect2: ld returned 1 exit status
make: *** [imapfilter] Error 1


All fixed by the above procedure.

Sunday, January 5, 2014

Roundcube Webmail with Domeneshop

I just set up Roundcube to fetch emails from my Domeneshop mail server and had some trouble getting it to work.
Under step 3 of the Roundcube Webmail Installer I was checking that send and receive email worked correctly and got errors. Here is the settings I used and the corresponding error I got:

Server: smtp.domeneshop.no
Port: 587


Error: SMTP send:  NOT OK(Connection failed: HELO was not accepted: )

Server: ssl://smtp.domeneshop.no
Port: 587


SMTP send:  NOT OK(Connection failed: Failed to connect socket: fsockopen(): unable to connect to ssl://smtp.domeneshop.no:587 (Unknown error))

Server: tls://smtp.domeneshop.no
Port: 587


SMTP send:  NOT OK(Connection failed: HELO was not accepted: )

I discovered, after reading through the options of main.inc.php, that you could set host for HELO. This is usually the mail servers domain (e.g. domeneshop.no) if you have an email address using your email servers domain (e.g. asmund@domeneshop.no). But, I have my email using my own domain so setting it to:

$rcmail_config['smtp_helo_host'] = 'herikstad.net';

Solved my problem. :)

Sources: http://www.domeneshop.no/faq.cgi?id=48
http://schoudhury.com/blog/articles/send-email-using-gmail-from-php-with-fsockopen/
http://stackoverflow.com/questions/13717225/email-sending-with-ci-using-hotmail
http://www.imc.org/ietf-smtp/mail-archive/msg05499.html

Tuesday, October 29, 2013

Strip HTML entities with Postable

Postable is a great little page for translating HTML code in your text into non-interpretable characters so that you can easily blog about code without parts of it disappearing because it gets interpreted as HTML tags.
Just enter the code snippet into the field. Press Make it friendly and copy/paste the result into your blog.
Great! :)

http://www.elliotswan.com/postable/

Note: It is run through PHP, so no guarantees that your text isn't stored somewhere. But then again, you're about to blog it right?

Sources: http://www.elliotswan.com/2006/03/24/allow-me-to-introduce-you-to-my-new-little-app-postable/

Linux command to take screenshot

On newer versions of KDE when you press the PrintScreen button, a dialog pops up asking you if you want to copy or save a screenshot.

You can also do screenshots from Gimp: Open Gimp, select File -> Create -> Screen Shot...

Too be cool or on older versions of Linux you might want to be able to take screen shot using a command line terminal (virtual terminal, you still need to be in X Windows).

Enter the following command:
import -window root <location to put image>
e.g.
import -window root ~/screenshot.jpg

So then you can easily press Alt + F2, enter the command above. Then you won't get the terminal window in your screenshot.
On my system, once you have done so once, the next time you start entering the text it autocompletes.

Note: You need ImageMagick installed as import is included in that package.

Source: http://www.linuxforums.org/forum/newbie/10213-print-screen-available-linux.html

Wednesday, July 31, 2013

Batch Cropping Photos

Like most people nowadays I take a lot of photos, using either my phone or a digital camera. As I don't trust electronic storage mediums and also I like paper copies, I want to have many of the photos printed.

The problem is that photos taken by modern cameras/phones don't match good old paper photo width and height (aspect ration). The solution is to crop (i.e. cut away parts of the image) that are not essential, to fit my photos to the paper.

This is relatively easily done, you can
1. Let your paper photo provider cut out a default selection (the center part of the photo usually), which is mostly ok except when the interesting part isn't centered in your image. Or
2. You go through each image an select the part you want and crop it manually, either using a program like Picasa or Photoshop, or a program provided by your photo service (like JapanPhoto CEWE which is horrible to use and navigate)

This works ok for a few images, but once you pass 100s of photos, it takes too much time.

I luckily found a great program written to help with just this thing, JPEGCrops (http://ekot.dk/programmer/JPEGCrops/). And it's free!

JPEGCrops lets you add all the images you want to crop (only JPEGs though, it crashes with PNG), select the aspect ratio (e.g. 10x15 for regular photos in Norway), and move the box around inside each image to quickly and easily select which portion you want. The program is very fast both in loading images as well as cropping. You can also select an alternative output folder so that you don't mess up your full scale images.


The program is version 0.7.5 beta so could crash in some cases (like when trying PNG, so don't do that) and doesn't seem to be in active development. But it does just what is needed and I'm very happy with the result.

If the link goes away, contact me and I'll send you a copy. :) Thanks to Toke Eskildsen for such a great program! :)

Note: If you want to select a different aspect ratio for all your images, you can change the default by going to File -> Preferences -> Default Aspect. Then all images added after that should have the new aspect ratio set.

Note2: I use FujiDirekte (http://www.fujidirekte.no/), a Norwegian photo printer which I'm very happy with, they also have quite reasonable prices I've found from my investigations. Very easy and useable online interface for ordering. They even notice which aspect ratio I probably want for each photo. For example if I have cropped some images to 10x15 and some to 13x18, those sizes are listed correctly while they are "wrong" for other size, so the 10x order option for a 13x18 cropped image would be 10x17 or something. Not matching any of the aspect ratios I have cropped to.

Thursday, June 20, 2013

Dynamics 2.0 ROM on HTC Titan WP7

My Marketplace app didn't work, so I figured I'd install a Custom ROM on my HTC Titan phone. After a bit of googling I found:

Dynamics 2.0 (http://forum.xda-developers.com/showthread.php?t=1691921)
Eburon (http://forum.xda-developers.com/showthread.php?t=1731921)
HTC Titan 7.8 Sianto Edition AL (http://forum.xda-developers.com/showthread.php?t=1908624)

Also I found that I already had DFT Eternity 24 langs Freedom V1 Pearl Edition (http://forum.xda-developers.com/showpost.php?p=26842868&postcount=46) installed from my jailbreaking

I decided to try Dynamics 2.0. Here's how I did it:
 
  1. Get the prerequisites. 
    1. Details: http://forum.xda-developers.com/showthread.php?t=1521763
      Download: http://forum.xda-developers.com/attachment.php?attachmentid=923630&d=1330440102 (1MB) 
    2. Download and Install: 
      1. Windows Mobile Device Center (WMDC) (https://www.microsoft.com/en-us/download/details.aspx?id=14) (Might already be installed if you have Windows 7 or newer). 
      2. Microsoft Visual Studio Express 2012 (https://www.microsoft.com/visualstudio/eng/downloads#d-2012-express)
        or
        Microsoft Visual Studio Express 2010 (https://www.microsoft.com/visualstudio/eng/downloads#d-2010-express) (?MB) with Microsoft Visual Studio Express 2010 Service Pack 1 (https://www.microsoft.com/en-us/download/details.aspx?id=23691) (450MB)
        If you already have it installed and the trial has expired, don't worry a license is free, all you have to do is register. I used VS Express 2010. 
      3. Windows Phone 7.1 SDK (https://www.microsoft.com/en-us/download/details.aspx?id=27570) (500MB) 
  2. Backup user content. 
    1. Download WPBackup
      Details: http://forum.xda-developers.com/showthread.php?t=2010135
      Download: rhiffsta.ch/ultrashot/WPBackup_v1.0.rar
      or
      http://uploaded.net/file/xkg2k12x
       
    2. Run backup 
      1. Usage instructions: http://forum.xda-developers.com/showthread.php?t=2010135&page=12#118 
      2. Unpack the rar file to a location of your choice. 
      3. Start Zune (can't remember if I had to quit Zune before backing up or not, might want to try that if WPBackup doesn't start). 
      4. Connect your phone and sync it with Zune.  
      5. Start WMDC on your phone (don't quit it while backing up). Press Run and get IP, doesn't matter what it is, if you don't get an IP follow the instructions on the forum (worked fine for me on the first try). 
      6. Start WPBackup. If no program window shows, you are missing some prerequisite or Zune or WMDC. 
      7. Press connect in WPBackup 
      8. Follow instructions in WPBackup to backup whatever you want. 
  3. Install Dynamics ROM. 
    1. Download ROM and instructions.
      Details: http://forum.xda-developers.com/showthread.php?t=1691921 and http://dl.xda-developers.com/attachdl/9b7772b952cedc1d300ace97fe037123/51c218cf/1/5/0/5/9/4/5/release_2.0_en.txt
      Download: rhiffsta.ch/ultrashot/Dynamics_2.0_Titan.rar (450MB) 
    2. Install ROM 
      1. Disconnect your phone from the USB cable and turn it off. Press both volume buttons and then while pressing, turn the phone on. Wait for the SPL to show (bootloader showing statistics). 
      2. Connect the USB cable and wait for the text 'Serial' to change to 'USB' on the phone. 
      3. Make sure that the phone is connected as Qualcomm CDMA Technologies MSM on your PC. 
      4. Unpack the rar file to a location of your choice. 
      5. Start TitanAdvancedRUU.exe and select regular RUU and  Dynamics_2.0_Titan.nbh, then press Next. 
      6. Check the 'I've read the readme' box and press next. 
      7. Check 'I completed the steps indicated above' and press next.
      8. Press the 'Update' button. You should get a view saying "From Image Version: To Image Version: 4.06.401.03". 
      9. Press Next. 
      10. Press Next. 
      11. Wait for the ROM to be installed. The phone will reboot and let you go through the standard WP7 setup. 
  4. Restore backup 
    1. Start Zune and set up phone there. 
    2. Start WMDC on your phone, press run. 
    3. Start WPBackup on your computer, press connect. 
    4. Select restore. Select what you want to restore (Restore seems to work even though it says "Please, setup Live account first!"). 
    5. Restore 
      1. Install the apps you want from the restore (your phone will show the Marketplace page for each app), then go back to WMDC and press OK in WPBackup. 
    6. Reboot phone
Note: You should restore the backup before setting up any accounts such as Facebook, Gmail, or Yahoo. If you don't, restored contacts and SMSes that are duplicates of the ones downloaded from your accounts will be read only and show up twice (in the case of contacts). Very annoying.

Good luck! Hopefully it will work smoothly for you. :) If you have problems, just add a comment or ask at the forums. :)

Below are some screenshots from my process.

















Wednesday, June 19, 2013

BusyBox Limited echo

BusyBox is a program incorporating the functionality of several GNU tools/programs, like for example df, grep, find, mv, and echo. This binary is usually used on embedded devices instead of a full fledged GNU/Linux install. Thus you can call it BusyBox/Linux.

However, as this program is not the exact same code as in GNU/Linux there are differences between them, and some things are not supported. One such difference is that the echo command is a bit limited. There is a flag -e which tells the program to "enable interpretation of backslash escapes". For example change swap foreground and bacground colors with:
echo -e "\e[7m" and echo -e "\e[0m"

Except this won't work on BusyBox (at least in version 1.12.1), echo doesn't accept \e and \x escape sequences. Instead you have to use the octal equivalent so the above would be:

echo -e "\033[7m" and echo -e "\033[0m".

Found at http://osdir.com/ml/linux.busybox/2003-07/msg00201.html .