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

Auto switch to A2DP bluetooth device when connected in Ubuntu

Add to /etc/pulse/default.pa to automatically switch pulseaudio sink to Bluez:

 .ifexists module-bluetooth-discover.so
 load-module module-bluetooth-discover
 load-module module-switch-on-connect  # Add this
 .endif

Modify /etc/bluetooth/audio.conf to auto select A2DP profile (instead of HSP/HFP):

 [General]
 Disable=Headset # Add this

Apply changes:

sudo pulseaudio -k # Restarts pulseaudio
sudo restart --system bluetooth # Restarts BT

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>

Новости первого канала XBMC (Kodi)

Написал за вечерок плагин, который берёт новости с сайта первого канала (http://1tv.ru) и добавляет в плейлист XBMC. Комментарии, баг репорты приветствуются.

Сорцы: https://github.com/DmitrySandalov/xbmc-repo
Репозиторий: repository.sandalov.zip
Форум: http://xbmc.ru/forum/showthread.php?t=4715

Название репо: Dmitry Sandalov’s XBMC Repo

20141128_233123_d

20141128_233206_d

Актуальная версия плагина: 1.0.9

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

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

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

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

image

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