browse by category or date

In my company we have GitLab 7.11 running on Ubuntu Ubuntu 14.04.1 LTS. Recently we found out that the email notifications wasn’t sent out. After confirming that the IP address is in the SMTP server’s sender whitelist, I began exploring GitLab’s mail configuration.

In GitLab’s installation folder, open config/environments/production.rb. Find config.action_mailer.delivery_method and change its value to :smtp

nano-gitlab-environment

Next, we need to create the smtp config file. Fortunately, GitLab has the sample config file. Run this command to create the config:

$ cp config/initializers/smtp_settings.rb.sample config/initializers/smtp_settings.rb

Now edit smtp_settings.rb

if Rails.env.production?
  Gitlab::Application.config.action_mailer.delivery_method = :smtp

  ActionMailer::Base.smtp_settings = {
    address: "email.server.com",
    port: 456,
    user_name: "smtp",
    password: "123456",
    domain: "gitlab.company.com",
    authentication: :login,
    enable_starttls_auto: true
  }
end

Since my Exchange is using sender whitelist with no authentication required, my config is very simple:

if Rails.env.production?
  Gitlab::Application.config.action_mailer.delivery_method = :smtp

  ActionMailer::Base.smtp_settings = {
    address: "192.168.1.200", # My SMTP IP Address
    port: 25
  }
end

After saving the config, restart both GitLab and Nginx

$ sudo service gitlab restart
$ sudo service nginx restart

Lastly, test whether the notification out by remove, then add back user to a project. At any case that the email delivery failed, you can view the error message at GitLab’s Admin Area – Background Jobs.

Oh, and if you need for more information on the SMTP configuration, you can refer to this documentation.

I hope it helps, cheers!

About Hardono

Howdy! I'm Hardono. I am working as a Software Developer. I am working mostly in Windows, dealing with .NET, conversing in C#. But I know a bit of Linux, mainly because I need to keep this blog operational. I've been working in Logistics/Transport industry for more than 11 years.

Possibly relevant:

Bad news: You can’t!
Good news: We can work around it, assuming that you are:

  1. a web developer trying to test your website in its eventual domain name
  2. able to ping the IP address, but the browser unable to resolve the host name

The trick is we modify the Http Header’s Host value, then browse the IP address directly.

In Google Chrome, we can do this by using this plugin: ModHeader

Here’s how it looks like:

mod-headers

This way you can have many entries, and activate only one that you need. Don’t forget to deactivate all entries once you finished testing. If not, your browser won’t work.

If you’re using Firefox, you can use this extension: Modify Headers. This plugin offers more functionalities such as Start/Stop the Headers modification, enabling/disabling individual Header entries, etc.

modify-header-firefox

If you’re using Opera, Safari or Internet Explorer, you might want to use Fiddler. It’s all-in-on suite to debug http traffic, which I personally found it an overkill since what we want is just to modify the Http Headers 🙂 Too bad I’m still unable to find plugin/addons similar to what Chrome and Firefox has. Let me know if you find one.

About Hardono

Howdy! I'm Hardono. I am working as a Software Developer. I am working mostly in Windows, dealing with .NET, conversing in C#. But I know a bit of Linux, mainly because I need to keep this blog operational. I've been working in Logistics/Transport industry for more than 11 years.

Possibly relevant:

And so I thought I’ve moved on from Excel Interop to NPOI. But here I am, scouring new tricks to make my Excel export beautiful 🙂 Recently I googled and used these tricks in my project. So I record it here hoping I won’t forget them too soon 🙂

I used to think that using Interop is very very difficult. But that was like 5 years ago. My recent experience shown that using the latest Visual Studio (I’m using 2012, I know, I know) will reduce the pain alot.

Before we start, few prequisites need to be addressed. First, adding the interop in your project reference.
excel-interop

Next, referencing it in the top your source code.

using Excel = Microsoft.Office.Interop.Excel;

OK, now for the first trick.

1. Make the entire row bold

This is the basic trick to make that header row of your report

myWorksheetObject.Cells[1, 1].EntireRow.Font.Bold = true;

2. Filter your data

Instead of just bolding the header, why not use the Filter. The Excel will be much more useful with Filter.

myWorksheetObject.Cells[1, 1].EntireRow.AutoFilter();

3. Auto-fit the columns width

One way to make your Excel file more pleasing to the eyes is by making the columns’ width fit the content.

myWorksheetObject.Cells[1, 1].EntireRow.EntireColumn.AutoFit();

Personally, I would combine trick 2 and 3 to make it dazzling.

myWorksheetObject.Cells[1, 1].EntireRow.AutoFilter();
myWorksheetObject.Cells[1, 1].EntireRow.EntireColumn.AutoFit();

4. Sorting the Filter

Sometimes, your user is too lazy to sort the data (use the damn filter please), so they want you to default the sorting in the filter.

myWorksheetObject.Cells[1, 1].EntireRow.AutoFilter();
myWorksheetObject.Cells[1, 1].EntireRow.EntireColumn.AutoFit();

myWorksheetObject.AutoFilter.Sort.SortFields.Clear();

//the first sort criteria, column E
//assume we have 10 rows of data, E2 to E11
myWorksheetObject.AutoFilter.Sort.SortFields.Add(
	myWorksheetObject.get_Range("E2","E11"), 
        Excel.XlSortOn.xlSortOnValues, 
        Excel.XlSortOrder.xlAscending);

//the second sort criteria, column B
//it should also consists of 10 rows of data, B2 to B11
myWorksheetObject.AutoFilter.Sort.SortFields.Add(
	myWorksheetObject.get_Range("B2","B11"), 
        Excel.XlSortOn.xlSortOnValues, 
        Excel.XlSortOrder.xlAscending);

myWorksheetObject.AutoFilter.Sort.Apply();

5. Print Preview it

Again, your user is too lazy to set the page-break, page orientation, paper size, etc. So they want you to do it.

//use A4 paper
//be cautious with below line, might not work in Excel 2007 or below
myWorksheetObject.PageSetup.PaperSize = Excel.XlPaperSize.xlPaperA4;

//set to paper orientation to landscape
myWorksheetObject.PageSetup.Orientation = Excel.XlPageOrientation.xlLandscape;

//don't forget to print the boxes
myWorksheetObject.PageSetup.PrintGridlines = true;

//make sure everything fit into one paper-wide
myWorksheetObject.PageSetup.Zoom = false;
myWorksheetObject.PageSetup.FitToPagesWide = 1;

That’s all folks. I hope it helps.

Cheers!

About Hardono

Howdy! I'm Hardono. I am working as a Software Developer. I am working mostly in Windows, dealing with .NET, conversing in C#. But I know a bit of Linux, mainly because I need to keep this blog operational. I've been working in Logistics/Transport industry for more than 11 years.

Possibly relevant: