Configure Exim4 to Send Email Through a Password Protected Relay Host

After installing exim4, run

sudo dpkg-reconfigure exim4-config

and use these config options:

  • General type of mail configuration: mail sent by smarthost; received via SMTP or fetchmail
  • System mail name: <your hostname>
  • IP-address to listen on for incoming SMTP connections: 127.0.0.1
  • Other destinations for which mail is accepted: <your hostname>
  • Machines to relay mail for: <leave this blank>
  • IP address or host name of the outgoing smarthost: mail.example.com::587
  • Hide local mail name in outgoing mail?
    • Yes – all outgoing mail will appear to come from your gmail account
    • No – mail sent with a valid sender name header will keep the sender’s name
  • Keep number of DNS-queries minimal (Dial-on-Demand)? No
  • Delivery method for local mail: <choose the one you prefer>
  • Split configuration file into small files? Yes (you need to edit one of the files next)

Then run

sudo gedit /etc/exim4/passwd.client

and add the following lines for your mail host, and any aliases it has (found through nslookup). Substitute <email address> and <password> with the account you want to route mail through):

mail.example.com:<email address>:<password>

Once you edit the passwd.client file, run

sudo update-exim4.conf

which will integrate your changes into your Exim4 config.

Run

sudo /etc/init.d/exim4 restart

and make sure that the service stops and starts properly.

So, type that to test,

echo "Testing." | mail -s Test example@gmail.com

Install MS Fonts in Dual boot with Linux and Windows

If you have dual boot system with Linux and Windows operating system, you can easily install the MS fonts from Windows C drive. All you have to do is mount the Windows partition (C:/Windows).

I assume you have mounted the C:/Windows partition at /Windowsdrive directory in linux.

Now, link the fonts location to your Linux system’s fonts folder as shown below.

sudo ln -s /Windowsdrive/Windows/Fonts /usr/share/fonts/WindowsFonts

After linking the fonts folder, regenerate the fontconfig cache using command:

sudo fc-cache

Alternatively, copy all Windows fonts to /usr/share/fonts directory and install the fonts using the following commands:

sudo mkdir /usr/share/fonts/WindowsFonts
sudo cp /Windowsdrive/Windows/Fonts/* /usr/share/fonts/WindowsFonts
sudo chmod 755 /usr/share/fonts/WindowsFonts/*

Finally, regenerate the fontconfig cache using command:

sudo fc-cache

Test Windows font

Open LibreOffice or GIMP after installing MS Fonts. Now, you will find the Microsoft coretype fonts.

MS Fonts in LibreOffice


Disclaimer: Microsoft has released its core fonts for free. But Please be mindful that usage of Microsoft fonts outside running Windows system is prohibited by Microsoft’s End User License Agreement. Read the EULA carefully before installing MS Fonts in any Linux operating system.


Source: Install Microsoft Windows Fonts in Ubuntu 16.04 – OSTechNix

Enabling XDebug for Netbeans and PHP

To enable XDebug, you need to edit the php.ini file in a text editor like gedit.

  • To start the gedit text editor, launch the Terminal and type the following command at the command prompt:
    sudo gedit

    If asked, enter the password specified for the root user during the installation of your operating system.

  • Open the file /etc/php5/apache2/php.ini or /etc/php/7.0/apache2/php.ini.
  • Add the following line to the file at the end of the “Dynamic Extensions” :
zend_extension=/usr/lib/php/20151012/xdebug.so
  • Add the following section in “Module Settings” before the [Date] section:
[debug]
; Remote settings
xdebug.remote_autostart=off
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=localhost
xdebug.remote_port=9000

; General
xdebug.auto_trace=off
xdebug.collect_includes=on
xdebug.collect_params=off
xdebug.collect_return=off
xdebug.default_enable=on
xdebug.extended_info=1
xdebug.manual_url=http://www.php.net
xdebug.show_local_vars=0
xdebug.show_mem_delta=0
xdebug.max_nesting_level=100
;xdebug.idekey=

; Trace options
xdebug.trace_format=0
xdebug.trace_output_dir=/tmp
xdebug.trace_options=0
xdebug.trace_output_name=crc32

; Profiling
xdebug.profiler_append=0
xdebug.profiler_enable=0
xdebug.profiler_enable_trigger=0
xdebug.profiler_output_dir=/tmp
xdebug.profiler_output_name=crc32
  • Save the php.ini file and quit gedit.

A Start Job Started by Dev-disk-by..

If you get “a start job started by dev-disk-by..” followed by a 90 second delay during each boot, complete the following steps:

  1. Install Gparted using the Software Center
  2. Open Gparted and see what partition is the swap partition.
  3. Reformat the swap partition if necessary.
  4. Copy UUID of the swap partition.
  5. Edit the fstab file using the line below.
    sudo -H gedit /etc/fstab
    
  6. Find the entry of the swap partition.
  7. Replace the UUID of the swap by the one you previously copied.
  8. Save the fstab file.
  9. Reset your computer.

Linux Mint 18 Reboots Normally Instead of Waking up From Hibernate

The reason why your system reboots normally instead of waking up from hibernate, is most likely that the configuration file “/etc/initramfs-tools/conf.d/resume” is missing the proper path to your swap partition.

To modify (or create) the proper resume entry and updating your system to reflect the changes, do the following.

Go into a terminal and switch on root access, by typing: “sudo -s” and entering your password. Then CD to the directory “/conf.d” mentioned above, and check if the file “resume” is missing. If it’s missing, create and save a new file (plain text) using the command “gedit resume” to edit or create the file.

The file “resume” must contain the text “RESUME=UUID=” + the actual UUID for your swap partition (locate it by viewing information on your swap partition using GParted). For instance my own configuration file lists (an example): “RESUME=UUID=79647610-c76d-4220-8c58-b4b9c71f9ead”. Yours should reflect the UUID that your own swap partition has.

Then save the “resume” file and check if it reflects the proper information, and use this command to update the system so that your changes is reflected: “update-initramfs -u”, alternatively “sudo update-initramfs -u” (the -u stands for update).

After this has been done, your system knowns the proper location to your swap partition and thus the proper location to wake up your system from hibernate properly.

C# Asynchronous Download File with Progress

// Sample call : DownLoadFileInBackground2 ("http://www.contoso.com/logs/January.txt");

public static void DownLoadFileInBackground2(string address)
{
    WebClient client = new WebClient ();
    Uri uri = new Uri(address);

    // Specify that the DownloadFileCallback method gets called
    // when the download completes.
    client.DownloadFileCompleted += new AsyncCompletedEventHandler (DownloadFileCallback2);

    // Specify a progress notification handler.
    client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressCallback);
    client.DownloadFileAsync (uri, "serverdata.txt");

}
private static void UploadProgressCallback(object sender, UploadProgressChangedEventArgs e)
{

    // Displays the operation identifier, and the transfer progress.
    Console.WriteLine("{0}    uploaded {1} of {2} bytes. {3} % complete...", 
        (string)e.UserState, 
        e.BytesSent, 
        e.TotalBytesToSend,
        e.ProgressPercentage);

}
 

private static void DownloadProgressCallback(object sender, DownloadProgressChangedEventArgs e)
{    
     // Displays the operation identifier, and the transfer progress.    
     Console.WriteLine("{0}    downloaded {1} of {2} bytes. {3} % complete...",         (string)e.UserState,         
        e.BytesReceived,         e.TotalBytesToReceive,                    e.ProgressPercentage);

}

Source: https://msdn.microsoft.com/en-us/library/ms144196(v=vs.110).aspx

Add an Application Shortcut to Windows File Explorer’s Context Menu

Context menu for right click on folders in left panel of Windows File Explorer or on background of a directory in right panel

  1. HKEY_CLASSES_ROOT\Directory\Background\shell if you are administrator
  2. HKEY_CURRENT_USER\Software\Classes\directory\Background\shell if you are a normal user

Context menu for right click on folders in right panel of Windows File Explorer

  1. HKEY_CLASSES_ROOT\Directory\shell if you are administrator
  2. HKEY_CURRENT_USER\Software\Classes\directory\shell if you are a normal user

Context menu for any file

  1. HKEY_CLASSES_ROOT\*\shell if you are administrator
  2. HKEY_CURRENT_USER\Software\Classes\*\shell if you are a normal user

In all cases:

  1. add a new key under “shell”, naming it as you want to name the context menu item
  2. add a new key inside this key, named command (mandatory name)
  3. edit the “default” property in “command” to myprogrampath\path\path\executable.exe %1 to pass the file path and name of the selected file to your custom program.

C# Example

Add a String Value to the key called “AppliesTo” and set its value to “under:{path}”

In my example, I want it to only look in the T Drive, so my String value is “AppliesTo”:”under:T:”.

In C#, this is easily accomplished with the following:

RegistryKey _key = Registry.ClassesRoot.OpenSubKey("Folder\\Shell", true);
RegistryKey newkey = _key.CreateSubKey("My Menu Item");
newkey.SetValue("AppliesTo", "under:T:");

RegistryKey subNewkey = newkey.CreateSubKey("Command");
subNewkey.SetValue("", "C:\\yourApplication.exe");
subNewkey.Close();

newkey.Close();
_key.Close();

Full Detailed Example

With a quick registry tweak, you can add any application to any Windows Explorer context menu. You can even add application shortcuts to your desktop’s context menu and launch your favorite applications just by right-clicking on your desktop.

Getting Started

First, launch regedit.exe from the Start menu.

Expand the HKEY_CLASSES_ROOT key.

Specific File Types

As an example, let’s add an option to the context menu for .gif files.

First, scroll down to the .gif key under HKEY_CLASSES_ROOT.

Select it and look at its “(Default)” value. In this case, the default value is “giffile”.

Head to down to the giffile\shell key, also under HKEY_CLASSES_ROOT.

First, right-click the shell key and create a new key. Name the key what you want the option to appear as in the menu. Next, right-click the key you just created and create a new subkey under it. Name the new key “command.”

Double-click the “(Default)” value in the command key and enter the path to the .exe file in the following format:

C:\\Program Files\\Something\\something.exe %1

Be sure to use the double backslashes and end the path with %1. The %1 passes the selected file name to the program.

The option will appear immediately.

Only When Pressing Shift

To have a shortcut appear only when you press Shift while right-clicking, create a string value named “Extended” in the action’s main key.

All File Types

The HKEY_CLASSES_ROOT\*\shell key holds options that appear when you right-click any type of file.

First, navigate to the *\shell key.

Next, create a key with the same structure.

You’ll see the option when you right-click any type of file.

Desktop Menu

Use the HKEY_CLASSES_ROOT\DesktopBackground\shell key to have a shortcut appear when you right-click the desktop.

Omit the %1 part of the command because you only want Windows to launch the app, not try to pass anything to it.

Folder Menus

Use the HKEY_CLASSES_ROOT\Directory\shell key to have the option appear when you right-click a directory.

Use the HKEY_CLASSES_ROOT\Directory\Background\shell key to have an option appear when you right-click the background of a directory in a Windows Explorer window.

Source: http://www.howtogeek.com/107965/how-to-add-any-application-shortcut-to-windows-explorers-context-menu/

 

Create html and chm documentation from C# or C++ Visual Studio source code

Products to be used

Doxygen

Doxygen (doxywizard.exe) is used to generate HTML documentation from source files. Furthermore, it generates the elements needed to create the .chm (compressed HTML) file too. Doxygen can be used under the terms of the GNU General Public License. Doxygen can be downloaded from www.doxygen.org.

Microsoft HTML Help Workshop ®

HTML Help Workshop (hhw.exe) is used to generate compressed HTML files (.chm). This tool is free and can be downloaded from here.

Procedure for generating the technical documentation

Generating HTML files

  • Execute Doxygen GUI frontend (doxywizard.exe).
  • Configure the parameters by using either “Wizard” or “Expert” mode.
  • In order to prepare the .chm file generating, in “Output” tab, it has to check “HTML” and “prepare for compressed HTML” in wizard mode. Whether the expert mode has been chosen, in “HTML” tab, it has to check “GENERATE_HTMLHELP” and to enter the .chm filename (with the extension) in “CHM_FILE” field.
  • Save the configuration file.
  • Run the generating process by clicking on the “Start” button.
  • Check the result by executing “index.html” in the “html” sub folder.
In addition of the html documentation, three more files are supposed to be generated in the “html” sub folder: “index.hhp”, “index.hhc” and “index.hhk”.

Generating compressed HTML file (.chm)

  • Execute HTML Help Workshop (hhw.exe).
  • Open the project file: index.hhp.
  • Eventually change the compiled file location to drop it in the “Doc” folder.
  • Compile the HTML files.
  • Outside HTLM Help Workshop, open the created file in order to  check it.

C# and C++ comments restrictions in Visual Studio ®

Doxygen recognize the C# and C++ comments tags like ///<summary></summary>,///<param></param>, ///<returns></returns> and the other ones. But, for example, under Windows version, it does not recognize the line feed in comments.
So, whether you want to go beyond these basic features and if you want  to format your comments, the best way is to use the Doxygen tags inside the standard comments tags (refer to Doxygen documentation for details).
The Visual Studio compiler does not send any warning about these, but, unfortunetly, these tags appear in the tooltips in the editor.
Below is a sample with “\n” tag for the line feed and, “\code” and “\endcode” to show the encapsulated text like code pattern in the output help file.
/// <summary>
/// Load a config XML file.
/// \n\n XML file format:
/// \code
/// <Parent>
///     <Child Name='ID' Type='Type1' />        
///     ...
/// </Parent>
/// \endcode
/// </summary>

 Visual Studio® and Html Help Workshop® are registered trademarks of Microsoft.

How to Configure the Linux Grub2 Boot Menu the Easy Way

Installing Grub Customizer

The tool in question is called Grub Customizer, created by Daniel Richter. He’s provided a PPA to make installing the tool quick and easy.

Open a terminal window (Ctrl+Alt+T or Applications > Accessories > Terminal) and type in the following commands.

sudo add-apt-repository ppa:danielrichter2007/grub-customizer
sudo apt-get updatesudo apt-get install grub-customizer

GrubCustomizer will now show up in the Applications > System Tools menu.

Or you can open it from the command line.

gksudo grub-customizer

Hide Boot Menu Options

Over time, your boot menu can get cluttered with old versions of the Linux kernel. In a previous article, we showed you how to remove these manually; Grub Customizer makes this process much easier.

When Grub Customizer starts up, you’ll see a list of all the items that show up in the boot menu.

To hide entries that you don’t want to see anymore, simply uncheck the checkbox next to them.

Click the Save button at the top-left to make your changes permanent.

You can uncheck entire sections if you don’t want Grub2 to probe for new operating systems, or give you the option to test your computer’s memory.

Note that, unlike the manual method, this process does not actually remove the kernels from your computer, it just hides them from the boot menu.

Customize Grub Behavior

Grub Customizer can do much more than hide boot menu entries! Opening up the Preferences window lets you customize almost every aspect of Grub.

For example, you can set the default boot menu entry to a certain position, or a specific item.

If you’re bored by the default white-text-on-black-background look of Grub2, you can add a background image and customize text colors.

And, for Grub2 experts, you can set advanced settings much more easily than by editing the configuration files manually.

Grub Customizer is a great addition to any Linux installation that uses Grub2!

Thanks to How-To Geek commenter Hugues for recommending this program!See this Ubuntu Forums post for more detailed information on Grub Customizer.

Source: How to Configure the Linux Grub2 Boot Menu the Easy Way