Wednesday, October 11, 2017

How to Load GitLab Inside an Iframe

So you are trying to load GitLab inside another page via iframe, and you are not able to. Due to security reasons, this is default behavior for GitLab, and as per the project (see issue 2347, this will not change, and I agree).
However for some internal users this might not be the best approach, so here's how to enable it.
Browse to your install directory and go to your ‘nginx’ folder. If you are not sure where it is, with your GitLab instance running, use the following command (assuming you are using port 8888).
# netstat -anp | grep 8888
tcp        0      0      *                   LISTEN      19761/nginx
Now use the PID to find where ‘nginx’ is running:
# ps -ef | grep 19761
root     19761  1029  0 13:12 ?        00:00:00 nginx: master process /opt/gitlab/embedded/sbin/nginx -p /var/opt/gitlab/nginx
Browse to the config folder and edit the ‘gitlab-http.conf’
# cd /var/opt/gitlab/nginx/conf

# vim gitlab-http.conf
Add the line proxy_hide_header X-Frame-Options;`` in thelocation /` code block
```http.conf location / { ## Serve static files from defined root folder. ## @gitlab is a named location for the upstream fallback, see below. try_files $uri $uri/index.html $uri.html @gitlab; }
proxy_hide_header X-Frame-Options;

Comment the line `proxy_hide_header X-Frame-Options;` if present

location @gitlab {
    ## If you use HTTPS make sure you disable gzip compression
    ## to be safe against BREACH attack.

    ## Some requests take more than 30 seconds.
    proxy_read_timeout      300;
    proxy_connect_timeout   300;
    proxy_redirect          off;

    proxy_set_header   X-Forwarded-Proto $scheme;
    proxy_set_header   Host              $http_host;
    proxy_set_header   X-Real-IP         $remote_addr;
    proxy_set_header   X-Forwarded-For   $proxy_add_x_forwarded_for;
    proxy_set_header   X-Frame-Options   SAMEORIGIN;
    #proxy_hide_header X-Frame-Options;

    proxy_pass http://gitlab;
Restart GitLab
# gitlab-ctl restart
ok: run: logrotate: (pid 31748) 1s
ok: run: nginx: (pid 31752) 0s
ok: run: postgresql: (pid 31757) 1s
ok: run: redis: (pid 31766) 0s
ok: run: sidekiq: (pid 31774) 0s
ok: run: unicorn: (pid 31786) 0s
That should be it!!!

Tuesday, September 26, 2017

Bash Special Parameters

Special parameters are set by the shell to store information about aspects of its current state, such as the number of arguments and the exit code of the last command. Special parameters can only be referenced and cannot have it's value assigned.
Specia parameters are: $*, $@, $#, $$, $!, $?, $0, $-, $_
$*List of arguments (as a string)
$@List of arguments (as an array)
$#Number of positional parameters
$$PID of the current shell
$!PID of the last command executed in the background
$?Exit code of the last-executed command
$0Path to the currently running script
$-Current shell option flags
$_Gives the last argument to the previous command

Sunday, September 24, 2017

Atom as Markdown Editor

I have been looking for a good Markdown editor for quite a while, and after a lot of research, I finally I found one.
Some of the key features that were very important to me on a Markdown editor were:
  • Live preview
  • File browser (sidebar)
  • GitHub flavored
  • Fast and non-laggy preview
And not surprisingly, Atom from GitHub was my solution.
You might also want to:
  • Change the preferences of the already installed package markdown-preview to GitHub flavored
apm install markdown-preview-auto-open

Saturday, September 23, 2017

Gnome Touchpad Settings Missing in Arch (XPS 13 9360)

I had an issue where the Gnome extension 'Touchpad Indicator' stopped working on my XPS 13 (Arch). After looking a bit further, it seems that the Gnome Touchpad settings had also stopped working. All I could see was the mouse settings, and the touchpad section was completely gone.

With Gnome 3.20, xf86-input-synaptics is not longer supported, and you should use xf86-input-libinput instead.
You can check what is installed on your Arch system with pacman -Q | grep input. In my case, I had both packages installed:
$ pacman -Q | grep input
inputproto 2.3.2-1
libinput 1.8.2-1
xf86-input-libinput 0.26.0-1
xf86-input-synaptics 1.9.0-1
xorg-xinput 1.6.2-1
Remove xf86-input-synaptics and any configuration file (like /etc/X11/xorg.conf.d/50-synaptics.conf), install xf86-input-libinput and reboot. That should get your configuration working again.

Wednesday, September 20, 2017

Additional Status for VIM with Powerline

Would you like to have more information displayed while reading files in VIM? Powerline is a great utility for that.
In it's default config, it displays:
  • Current mode (normal, insert, visual)
  • Git branch
  • File name
  • File encoding
  • Script type
  • File view percentage
  • Line number
To install it on Arch:
sudo pacman -Ss python-powerline powerline powerline-vim
Add the line below to your ~/.vimrc
set laststatus=2

Note: If you get the error below
Traceback (most recent call last):
  File "", line 9, in 
ImportError: No module named powerline.vim
An error occurred while importing powerline module.
This could be caused by invalid sys.path setting,
or by an incompatible Python version (powerline requires
Python 2.6, 2.7 or 3.2 and later to work). Please consult
the troubleshooting section in the documentation for
possible solutions.
If powerline on your system is installed for python 3 only you
should set g:powerline_pycmd to "py3" to make it load correctly.
Unable to import powerline, is it installed?
Press ENTER or type command to continue
Modify either ~/.vimrc (or /etc/vimrc if you want the fix available for multiple users) by adding the line below:
let g:powerline_pycmd = 'py3'