Git – setting up a remote repository and doing an initial push

On remote:

ssh git@example.com
mkdir my_project.git
cd my_project.git
git init --bare
git update-server-info # If planning to serve via HTTP
exit

On local machine:

cd my_project
git init
git add *
git commit -m "My initial commit message"
git remote add origin git@example.com:my_project.git
git push -u origin master

Clone:

git clone git@example.com:my_project.git
cd my_project

Redirect outbound traffic from one host to another

The task is to redirect locally ports.

So for example, when you go in browser to http://a.a.a.a:80, you would like to be always redirected to http://b.b.b.b:80.

-> http://a.a.a.a:80

------------         --------------
|   Host   |  --->   | a.a.a.a:80 |
------------         --------------

-> http://a.a.a.a:80

------------         --------------
|   Host   |  --->   | b.b.b.b:80 |
------------         --------------

What first comes to one’s mind? Right, to just add a line to /etc/hosts:

127.0.0.1    localhost
a.a.a.a      b.b.b.b

That’s absolutely wrong, because with hosts file you can’t map one IP address to another.

The right way is to alter iptables OUTPUT table:

iptables -t nat -A OUTPUT -p tcp -d a.a.a.a --dport 80 -j DNAT --to-destination b.b.b.b:80

The explanation of this command is here.

IMAP/SMTP via HTTPS Proxy

In some places internet access is provided via proxy. Some proxies block imap and smtp and allow only ports 80 and 443. If your email client doesn’t have proxy configuration (like my beloved Mutt), then you need to forward imap and smtp by hand. If the proxy you are behind supports https this means you can bypass it via https connect method.

To demonstrate that I’ll install Proxytunnel on my Ubuntu 14.04. After that I am creating 2 upstart scripts that launch proxy-tunnel daemons from proxy to imap/smtp (in this example to gmail’s servers). The daemons are started on system’s boot and are listening for imap connections on localhost:993 and smtp on localhost:993. For simplicity I’m adding my mail servers to hosts file, without that I would need to reconfigure my mail client to use localhost instead of *.gmail.com.

sudo apt-get install proxytunnel
sudo touch /etc/init/tunnel-imap.conf /etc/init/tunnel-smtp.conf
sudo chmod 644 /etc/init/tunnel-imap.conf /etc/init/tunnel-smtp.conf

/etc/init/tunnel-imap.conf:

# proxy daemon for Gmail

description     "proxy daemon for Gmail imap"

start on runlevel [2345]

expect fork
respawn
respawn limit 10 5

exec    /usr/bin/proxytunnel -p proxy.com:80 -d imap.gmail.com:993 -a 993

/etc/init/tunnel-smtp.conf:

# proxy daemon for Gmail

description     "proxy daemon for Gmail smtp"

start on runlevel [2345]

expect fork
respawn
respawn limit 10 5

exec    /usr/bin/proxytunnel -p proxy.com:80 -d smtp.gmail.com:587 -a 587

add to /etc/hosts:

127.0.1.1   imap.gmail.com
127.0.1.1   smtp.gmail.com

Reboot

Tip 1: if you are an Upstart guru, you can make 1 upstart script instead of 2 🙂
Tip 2: one can use iptables instead of hosts

# iptables -t nat -A OUTPUT -d smtp.gmail.com -j DNAT --to-destination 127.0.1.1

Tip 3: there is a Python script that does the same job (didn’t test it)

Display Time Always in XBMC (Kodi)

20141129_230555_d

Just put these 2 controls to your VideoFullScreen.xml (after opening tag, line 4-5)

        <control type="label" id="1">
            <description>Clock</description>
            <left>460</left>
            <top>15</top>
            <width>800</width>
            <height>5</height>
            <align>right</align>
            <aligny>center</aligny>
            <font>font12</font>
            <textcolor>grey</textcolor>
            <shadowcolor>black</shadowcolor>
            <label>$INFO[System.Time] ($INFO[Player.FinishTime])</label>
        </control>
        <control type="label" id="2">
            <description>OSD</description>
            <left>15</left>
            <top>15</top>
            <width>800</width>
            <height>5</height>
            <align>left</align>
            <aligny>center</aligny>
            <font>font12</font>
            <textcolor>grey</textcolor>
            <shadowcolor>black</shadowcolor>
            <label>$INFO[Player.Time(hh:mm:ss)] - $INFO[Player.Duration(hh:mm:ss)]</label>
        </control>

20141129_230434_d

For skin.maximinimalism I use:

        <control type="label" id="1">
            <description>Clock</description>
            <posx>1730</posx>
            <posy>0</posy>
            <width>24-col</width>
            <font>smallStrong</font>
            <textcolor>grey</textcolor>
            <shadowcolor>-</shadowcolor>
            <label>$INFO[System.Time] ($INFO[Player.FinishTime])</label>
        </control>
        <control type="label" id="2">
            <description>OSD</description>
            <posx>15</posx>
            <posy>5</posy>
            <width>24-col</width>
            <font>smallStrong</font>
            <textcolor>grey</textcolor>
            <shadowcolor>-</shadowcolor>
            <label>$INFO[Player.Time] - $INFO[Player.Duration]</label>
        </control>

Yota не отправляются смс

Для успешной отправки смс требуется проверить правильность смс центра в настройках телефона.

Номер SMSC в сети Yota: +79585370690

Android: изменение SMSC осуществляется в сервисном меню *#*#4636#*#*

image

Ввод SMSC в сервисном меню осуществляется в кавычках. Требуется ввести “+79585370690” и нажать кнопку сохранения.

Forward X11 display to Ubuntu 14.04

I spent a lot of hours before realizing that Ubuntu 14.04 blocks tcp by default.

One can check this by

ps aux | grep X
root      1127  0.1  3.4 364380 71748 tty7     Ss+  12:08   0:00 /usr/bin/X -core :0 
   -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch

Notice the -nolisten option in output.

To enable it, add xserver-allow-tcp=true to lightdm:

sudo vi /usr/share/lightdm/lightdm.conf.d/50-xserver-command.conf
 [SeatDefaults]
 # Dump core
 xserver-command=X -core
 xserver-allow-tcp=true

Restart X (or reboot) and forward X11 desktop by launching:

# server
export DISPLAY=<your-localhost-ip>:0

# client
xhost +

You can test Display forwarding by launching on server

xeyes

credits