Friday, February 27, 2009

Ubuntu / Debian Survival Kit



  • Install / Packages 
    • instal .deb
      • sudo dpkg -i nomachine_5.1.26_1_amd64.deb
    • install LAMP on a fresh Ubuntu
    sudo tasksel install lamp-server
    • If you want to use the "Gnome classic" desktop instead of Unity from Ubuntu 14:
    sudo apt-get install gnome-session-fallback then reboot, and you will get the gnome icon in the user login part
    • Font: FreeSans 16 is not bad for firefox
    • dpkg -l |grep emacs (list installed packages)
    • alien (package conversions: rpm, tgz, etc). Usually not working for me when trying to convert Debian packages
    • To install a Debian package (read dpkg before, since it can mess up your config)
      sudo dpkg -i mysql-workbench-gpl-5.2.33b-1ubu1010-amd64.deb
    • aptitude install mysql-workbench
    • search:
      • apt-cache search libtool
      • or aptitude search libtool
  • Network
    • ip adress   (ifconfig is obsolete, see "ip" command)
    • restart network interface:
      • ifdown eth0
      • ifup eth0
    • Network, command line (dhcp/static)
      sudo vi /etc/network/interfaces
    • If your network is disabled, first right click on the network icon and enable connections (sometimes these get disabled at reboot)
    • NetworkManager
    • look at your /etc/resolv.conf, the first line will tell you if the network management of your machine is done through the NetworkManager server. You need to start it in case of failure: sudo /etc/init.d/network-manager restart The other network management way is sudo /etc/init.d/networking
    • If your IP is static, you need to specify your DNS servers manually
      /etc/resolv.conf, should look like this:
      search mydomain.example
      nameserver 212.27.40.254
    • # dns google nameserver 8.8.8.8 Note that resolv.conf is overwritten with another dns nameserver when going through DHCP
      To know what is the dns of a specific network interface
      nmcli device show eth0
    • Network config:
      sudo apt-get install gnome-network-admin
      network-admin (do not use sudo, otherwise, everything is grayed out)
      sudo /etc/init.d/networking restart
      (you need to use this command when you go on standby and come back on, the networking get a new IP address throuch DHCP in this case)
    • WIFI
      • To use WIFI, you need to stop firestarter. So better stop apache and samba also while you use WIFI. RPCbind port 111 remains open. If you really want to close this port too (you don't have to):
        /etc/init.d/portmap stop
      • Also, at some point NetworkManager was not working anymore, not sure why. I could not use WIFI anymore. I installed wicd and it worked fine. Useful commands to trouble shoot WIFI on Ubuntu are:
        lshw, sudo iwlist scan
        Note that when login identification is required on a web site, the WIFI connection will show alternate "connected"/"disconnected" on wicd until you login.
        wicd 1.7.0 shows "wrong password" for WPA2 (Ubuntu 10.04 LTS). Seems working with wicd 1.6. Just use the regular wifi icon on the tray.
      • wifi not working after Ubuntu suspend
        • sudo nmcli nm sleep false
      • list wifi connections
        • sudo nmcli dev wifi list
    • firewall: "sudo firestarter"
    • When using wireshark, do not forget to use sudo, otherwise, it does not see any network interface. There is no snoop on ubuntu
    • tcpdump -n -A -p -i lo host 127.0.0.1 and port 8086
    • tcpdump -n -A -p -i eth0  host 192.168.0.202 and port 8080 |grep GET
    • tcpdump -n -A -p -i lo host 127.0.0.1 and dst port  8080
    • tcpdump -n -A -p -i eth0 host 192.168.0.195 and port 12501 |grep kWords --color=auto
    • tcpdump -n -A -p -i eth0 host 192.168.4.101 and port 12560 |grep kWords --color=auto
    • sudo tcpdump -n -A -p -i bond1  host   10.64.113.173 and port 8080 |grep GET
    • tcpdump -n -A -p -i em2  host 192.168.4.188 and port 8384 |grep solr
    • tcpdump -n -A -p -i em1 |grep 10\.1\.65\.208
    • (proxy / threesint2) tcpdump -n -A -p -i bond1  host 10.64.114.35 and port 8080 |grep GET              (can be run from threesint2, not from docker)
    • [proxy vv157]# tcpdump -n -A -p -i eth1  host  10.64.115.157 and port 8080 |grep "siteId=" --color
    • some packets are filtered by tcpdump (local machine)

  • Flush RAM / Clear memory cache
    x14:/data/data_ref/DE# echo "1" > /proc/sys/vm/drop_caches
    x14:/data/data_ref/DE# echo "0" > /proc/sys/vm/drop_caches
    x14:/data/data_ref/DE# free -m

  • Config / Settings / Display
    • Need a .profile file to specify to exec .bashrc See dot files
    • compiz settings:  sudo ccsm &
    • BUG Ubuntu: "Display settings" not taken into account when using nvidia driver:
      • pkill -9 -f gnome-settings-daemon
  • Services
    • sudo service "equivalent to" sudo /etc/init.d/serviceName (start|stop|rerstart)
    • see /etc/inetd.conf : services made available by this machine over the net - see System/Administration/Services to disable samba for example
    • dpkg -S /sbin/init   - is either "upstart" or  "systemd"
      • systemd => /etc/init.d
      • upstart => /etc/init
    • service --status-all
    • initctl list
    • remove a service started at boot time
      • update-rc.d -f  hbase-master  remove
      • see also    "ls -al /etc/rc*.d/"
    • some services (updatedb / mlocate) are started from
      • /etc/cron.daily     (/etc/cron.*)
      • the way to disable this services seems to be:
        • /etc/cron.daily#   chmod -x mlocate
  • version
    cat /etc/lsb-release
    cat /etc/issue

  • CPU temperature
    • "sensors" to get processor temperature
    • The following gets the BIOS info but the system freezes shortly after that:
      - "sudo modprobe i8k force=1" to be able to use i8kctl on vostro. A folder /proc/i8ctl is created (and disappear after reboot). Seems disabled after reboot.
      - "i8kctl" to display infos
  • boot
    • /etc/rc.local
    • /etc/fstab for boot time mounts
  • To mount a remote directory on my machine:
    vi /etc/fstab (add the my_folder line)
    mkdir /mnt/my_folder
    ln -s /mnt/my_folder /my_folder
    mount -a
    df
    exportfs
  • alias
    alias h='history 50'
    alias l.='ls -ald .*'
    alias ll='ls -l'
    alias ls='ls --color=auto'
  • To get colors when using vi
    • apt-get install vim
  • To acces an NT machine file system
    from the "Places" Ubuntu file explorer:
    smb://192.168.0.22/
  • unmount Sony-Ericsson:
    sudo eject /media/PHONE
  • If mouse and keyboard are frozen at login
    sudo apt-get update
    sudo reboot
    or plug a USB mouse
  • alsa force-reload       (restart audio device)
.

Sunday, January 18, 2009

Linguistics

Anaphora / ellipsis resolution

  - anaphora resolution
  The music stopped, and that upset everyone

  - ellipsis resolution

Toponymy
Studies place names

.

Friday, January 16, 2009

About BTree

Hash clusters were introduced in Oracle 7 as an alternative way of indexing
a table. Instead of randomly storing rows in arbitrary table blocks and
using indexes to locate them (using a B-tree search), hash cluster rows are
stored according to the key values. Each row's location is derived by its
key value.
.

Wednesday, January 14, 2009

OO survival kit

If one has:
class MyImplement : public MyInterface

If the destructor of MyInterface is not virtual, then the destructor of MyImplement is not called in this case:

MyInterface * myInterface = new MyImplement();
delete myInterface;
.

Tuesday, January 13, 2009

GAC / .NET SDK

gacutil to manipulate the Global Assembly Cache can be found in
C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin

At first I tried to install the .NET SDK, but it was telling me that it was installed already. It is actually installed with Visual Studio. When you start the VisualStudio Command Prompt, the path to it is set already.

Sunday, November 30, 2008

Java logger

import java.util.logging.Logger;
import java.util.logging.FileHandler;
import java.util.logging.SimpleFormatter;
import java.util.logging.Level;

logger = Logger.getLogger("com.mycompany.conversion"); // logger internal name
FileHandler fileHandler = new FileHandler("basic.conversion.txt", 1000, 1);
fileHandler.setFormatter(new SimpleFormatter());
logger.addHandler(fileHandler);
logger.log(Level.INFO, " Initializing GgWebService");

See also:
C:\Program Files\Java\jdk1.6.0_10\jre\lib\logging.properties
.

Friday, November 21, 2008

Strings

  • C#
    string is an alias for String
    String: UTF16
  • Java
    UTF16
  • C++
    wchar_t: UTF16 on Windows, UTF32 on Unix
    wchar_t is not portable, better to use ICU instead.
  • stl::string
    typedef basic_string < char > string;
    typedef basic_string < wchar_t > wstring;
    wstring string1 = L"obecnÄ›";
  • CString
  • ICU
    UnicodeString: UTF16 internally. Note that the endianess of UTF-16 is platform dependent.
    ICU does not use UCS-2. UCS-2 is a subset of UTF-16. UCS-2 does not support surrogates, and UTF-16 does support surrogates.
  • Note: most commonly, "Unicode" means UCS-2, but the difference between UCS-2 and UTF16 is not visible from the Java and C# standpoint
  • Windows TCHAR
    #ifdef UNICODE
    typedef wchar_t TCHAR;
    #else
    typedef char TCHAR;
    #endif
    TCHAR * toto = _T("obecnÄ›");
  • Note: in Java and C#, strings are immutable. String content cannot be changed after the object is created. See StringBuffer (Java) and StringBuilder (C#)
  •