proxychains via reverse socks proxy

1. Start local socks proxy:
Connect to localhost via SSH and open SOCKS proxy on port 54321.

ssh -f -N -D 54321 localhost

-f runs SSH in the background.

2. connect to server and setup reverse port forwarding
Bind remote port 6666 to local port 54321. This makes your local socks proxy available to the remote site on port 6666.

ssh root@server -R6666:localhost:54321

3. configure the server software to use the forwarded proxy
I found that installing proxychains makes things a lot easier. Its a tool that uses an LD_PRELOAD trick to wrap TCP and DNS requests from arbitrary commands into a proxy.

This is optional – you may also configure yum or whatever to use the socks proxy, when supported. However, proxychains is really cool because it enables any software to use SOCKS proxy, even those without proxy support. (telnet for example)

Setup /etc/proxychains.conf to use the forwarded socks proxy:

[ProxyList]
# SSH reverse proxy
socks5 127.0.0.1 6666

Tunnel arbitrary tools (that use TCP) with proxychains:

$ proxychains telnet google.com 80
$ proxychains yum update
$ proxychains apt-get update

Nike plus sound volume

Here is what I did in order to restore sound volume in Nike+ app:
1) go to the menu->settings->Auto voice feedback
2)pressed “preview voice over” and quickly, during preview sound, pressed volume+ button of the iPhone.

Read-only user in postgres

  1. Connect as admin
  2. create user:
    CREATE USER 'uuu' PASSWORD 'ppp'
  3. switch to necessary db (if not already):
    \connect ddd
  4. add rights:
    GRANT CONNECT ON DATABASE ddd TO uuu;
    GRANT USAGE ON SCHEMA public TO uuu;
    GRANT SELECT ON ALL TABLES IN SCHEMA public TO uuu;

This only affects tables that have already been created. More powerfully, you can automatically have default roles assigned to new objects in future:

ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO uuu;

Fix Rapid Accelerator and Build

After MacOS upgrade Matlab has outdated links to MacOS SDK and therefore running models in ‘Rapid Accelerator’ mode causes errors. In order to fix ‘Rapid Accelerator’ mode version of MacOS must be updated (for example, from 10.8 to 10.10) in:
/Applications/MATLAB_R2014a.app/rtw/c/tools/unixtools.mk
/Applications/MATLAB_R2014a.app/bin/mexopts.sh
/Applications/MATLAB_R2014a.app/bin/maci64/mexopts/clang_maci64.xml
/Applications/MATLAB_R2014a.app/bin/maci64/mexopts/clang++_maci64.xml

Convert character set of MySQL database

In the command line shell, just fill in “dbname”, “user”, “pass” 😀

DB="dbname"
USER="user"
PASS="pass"
(
echo 'ALTER DATABASE `'"$DB"'` CHARACTER SET utf8 COLLATE utf8_general_ci;'
mysql -u "$USER" -p"$PASS" "$DB" -e "SHOW TABLES" --batch --skip-column-names \
| xargs -I{} echo 'ALTER TABLE `'{}'` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;'
) \
| mysql -u "$USER" -p"$PASS" "$DB"

Add BootCamp on external HDD

1. Add a new virtual hard disk from within the Boot Camp VM settings (it should be Add Device… —> New Hard Disk) of IDE type (the size doesn’t matter, and probably it shouldn’t be of the split type), and save it – with a NameOfVMDK.vmdk name of your choice – inside your Boot Camp VM bundle (it should be the default position in the save dialog); close the VM settings and quit Fusion.
2. In the Terminal, type this command:
$ /Applications/VMware\ Fusion.app/Contents/Library/vmware-rawdiskCreator create /dev/diskX fullDevice ./Desktop/NameOfVMDK ide
… which will create the new .vmdk file on your Desktop.
3. Copy the newly created .vmdk into your Boot Camp VM bundle, thus overwriting the existing one (which was created from within the VM settings).
4. Open Fusion and the VM settings again and verify that the new IDE virtual disk now has the size of your real added hard disk.

Move Gnome window buttons

If you are used to left-side Close, Minimize, Maximize buttons, then can be moved by editing dconf.

  • If you are using Metacity (Gnome3 fallback), settings are located in:
    org.gnome.desktop.wm.preferences.button-layout
  • If you are using Gnome3, settings are located in
    org.gnome.shell.overrides

Contents of the given key must be:
close,minimize,maximize: