Wednesday, December 5, 2007

To disable Intellisense in Visual Studio

rename
C:\p\msnet\VC\vcpackages\feacp.dll
or
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\vcpackages\feacp.dll

Saturday, November 24, 2007

Emacs survival kit

  • ESC x  set font-lock-mode
  • Enable PHP highlighting on ubuntu (I used emacs21)
  • aptitude install emacs-snapshot emacs-goodies-el php-elisp ruby-elisp python-elisp

  • Useful commands:
    C-something = CTRL+something
    M-something = ESC then something

    C-x b : swith buffers
    C-x o : other splitted window
    C-SPACE : yank current line
    C-w : delete selected block
    M-x : grep
    M-% : replace
    C-g : quit all macro
    C-x C-c : exit emacs
    C-x C-f ~ : to know where is your .emacs
  • C-q C-j: Inserting a CR in an emacs file
    M-x whitespace-mode:  show whitespaces and tabs:

  • Macros:

  • C-x ( start recording key strokes to build a keyboard macro.
  • C-x ) stop recording key strokes to for a keyboard macro.
  • C-x e execute the keyboard macro. Only one keyboard macro can be defined at a time. This is very powerful when used in conjunction with C-u 
  • do for example: C-u 200 C-x e 

  • .emacs file

  • ;; show column numbers
    (setq column-number-mode t)
    (set-frame-font "DejaVu Sans Mono-09")

    (set-frame-font "DejaVu Sans Mono-8")
    ;; 1ASC-Liberation Mono-bold-normal-normal-*-*-*-*-*-m-0-iso10646-1

    ;; 2 spaces for tabs
    (setq-default indent-tabs-mode nil);
    (setq default-tab-width 2);

    ;; don't back up tilde files
    (setq make-backup-files nil)

    ;; show column numbers
    (setq column-number-mode t)

    ;; show matching parentesis when pressing % on a parenthesis
    (global-set-key "%" 'match-paren)
    (defun match-paren (arg)
      "Go to the matching paren if on a paren; otherwise insert %."
      (interactive "p")
      (cond ((looking-at "\\s(") (forward-list 1) (backward-char 1))
    ((looking-at "\\s)") (forward-char 1) (backward-list 1))
    (t (self-insert-command (or arg 1)))))
  • json
  • (Just run M-x beautify-json on a buffer and it will reformat it)
  • (defun beautify-json ()
      (interactive)
      (let ((b (if mark-active (min (point) (mark)) (point-min)))
            (e (if mark-active (max (point) (mark)) (point-max))))
        (shell-command-on-region b e
         "python -mjson.tool" (current-buffer) t)))
  • to compile C++ using the F7 key
  • (global-set-key [f7] 'compile)
  • Vista
  • You cannot create a .emacs file simply on Vista (problem creating a file with a name starting with a dot). What I did is download one from the net.

    • Replace in multiple files
    1. Call dired to list files in dir, or call find-name-dired if you need all subdirectories. (just select all files at this step "*")
    2. Mark the files you want. You can mark all by doing CTRL G m m .You can mark by regex by typing 【% m】. (pom.xml for example)
    3. Type Q to call dired-do-query-replace-regexp.
    4. Type your find regex and replace string. 〔➤ common elisp regex pattern
    5. For each occurrence, type y to replace, n to skip. Type 【Ctrl+g】 to abort the whole operation.
    6. Type ! to replace all occurrences in current file without asking, N to skip all possible replacement for rest of the current file. (N is emacs 23 only)
    7. To do the replacement on all files without further asking, type Y. (Emacs 23 only)
    8. Call ibuffer to list all opened files.
    9. Type 【* u】 to mark all unsaved files, type S to save all marked files, type D to close them all.
  • Debugging C++ under emacs22 
  • - M-x gdb
  • Left click on the light gray column on the C++ source to set breakpoints (gdb needs to be running)
  • Use icons at the top as debugger commands.
  • - I tried "ddd". It is on top of gdb. It is OK, but it is an external editor, independent of emacs. The ddd window is an XWindow but it is very close to what you get with gdb+emacs.
  •  .

    Wednesday, November 7, 2007

    Cell phones OS

    To summarize:

    Symbian: pretty much all Nokias, some SonyEricsson
    Windows mobile: Taiwanese HTC, HP
    Android: Linux embedded based, Google's cell phones OS
    Proprietary: IPhone, SonyEricsson

    Tuesday, October 30, 2007

    new dynamic STL list

    I always have to look back on how to do this, so here we go:

    list<string> * myList = new list<string>();

    Monday, October 15, 2007

    VIVO and Video input a VGA card ?

    I wanted to watch the video that is going out of my FreeBox HD on my PC. I thought of using the sVideo output of the FreeBox HD, and use the Peritel of the FreeBox HD for the sound.

    I know I can use streaming directly from Free, but on the direct streaming there is no TF1 or M6.

    On some PC VGA cards, you have a sVideo or DVI plug. However these are almost always video OUT only. To be able to use your VGA card for acquisition, it has to be VIVO labelled (Video In, Video Out). Just FYI.

    Wednesday, October 3, 2007

    Tuesday, August 7, 2007

    Running a simple Java program on Windows

    let's say you have:

    // Toto.java
    package com.mydomain.MyTest;
    public class Toto
    {
    public static void main (String[] args)
    {
    System.out.println("hello");
    }
    }


    then, you can create a BuildRun.bat like this:

    REM BuildRun.bat
    javac Toto.java
    copy Toto.class com\mydomain\MyTest\
    java.exe com.ltu.MyJNITest.Toto

    To get directly the execution shell file that you need to run, you can get it from Eclipse:
    http://stackoverflow.com/questions/2502518/eclipse-export-running-configuration
    .

    Saturday, August 4, 2007

    %ProgramFiles% environment variable

    %ProgramFiles% is not like the other environment variables. It is initialized by the system with the value of ProgramFilesDir at boot time, and cannot be changed after that.

    Since ProgramFilesPath value is %ProgramFiles%, it has the same value also

    "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion"

    Usually, I just restart the console and all environment variables are set to their correct value. You can see the value of all environment variables by doing "set" in the Windows console. But %ProgramFiles" is initialized only at boot time.

    Creating an environment variable %ProgramFiles% from the control panel will not modify this behaviour, even after reboot.

    Tuesday, July 31, 2007

    Add a new SATA hard disk

    I ran into the issue that you need Windows XP SP2 to be able to install a new SATA hard disk. Well, I didn't have a Windows XP SP2 install CD, I just had a SP1. It turns out that it is pretty easy to create a SP2 from a SP1 though, here we go:

    Do an XP SP2 CD from a SP1

    Friday, May 25, 2007

    charmap.exe

    Having trouble with foreign characters on a remote machine ?: charmap.exe

    Saturday, April 21, 2007

    Vista UAC (User Account Control)

  • On Vista, I tried to copy a zip files from a shared folder of XP, in a regular Vista folder. A dialog box showed up and say "You need permission to perform this action".

    I tried to play around with UAC. I disabled it by doing:

    Control Panel/User Accounts

    and then "Turn User Account Control on or off". I change all the permissions of the folder. I tried to rename the file. It still didn't work. It was working with an mpeg file though.

    The only way I could eventually copy this zip file was to go on XP, and copy the zip file in a shared folder of Vista, and after that, copy it in the target Vista folder.

  • Also, sometimes, I cannot install things on Program Files because of Vista privileges nightmare, so I created a C:\MyProgramFiles where I put stuff I cannot install to other places
  • Monday, March 19, 2007

    Change keyboard from English to French

    Paneau de configuration / Options Regionales / onglets "Langues" / Details

    Thursday, March 1, 2007

    Upload files to free.fr

    The nice thing is they give 1GB disk space for free. They will send you back your confirmation/log-in/pw by regular mail, believe it or not. You need to use an ftp client though, as opposed to geocities which has a web ftp interface. One last thing: file transfer through ssh will not work. So here we go:

    * hostname: ftpperso.free.fr
    * login sans le suffixe "@free.fr"
    * port: 21

    To survive, you need this too:

    assistancefree.fr
    aduf.org


    To upload/download from your FreeBoxHD:
    * hostname: hd1.freebox.fr
    * un: freebox

    Thursday, February 15, 2007

    Where to look in the registry for exe started after boot

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

    HKCU\Software\Microsoft\Windows\CurrentVersion\Run
    HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce
    HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce
    HKLM\Software\Microsoft\Windows\CurrentVersion\Reinstall

    Wednesday, February 7, 2007

    _asm int 3 and __debugbreak() and DebugBreak();

    C++ hardcoded debug breakpoints on Windows:

  • _asm int 3
    Not supported on Windows 64 bits architecture


  • __debugbreak(); or DebugBreak();
    Use this on Windows 64 bits


  • .

    Saturday, January 27, 2007

    Moving Text in vi editor

    Command ------- Explaination
    1. ------ Move the cursor to the top of the paragraph you want to move.
    2. ma --- Place a mark named "a" at this location. (Vim will give you no indication that this command has been executed. In other words, the screen will not change.)
    3. ------ Move the cursor to the bottom of the paragraph to be moved.
    4. d'a -- Delete to mark "a". This puts the deleted text in a cut buffer.
    5. ------ Move the cursor to line where the text is to go. The paragraph will be placed after this one.
    6. p ---- Paste the text in below the cursor.

    Solaris survival kit

    /usr/platform/`uname -i`/sbin/prtdiag -v

  • Processors

    The psrinfo utility displays processor information. When run in verbose mode, it lists the speed of each processor and when the processor was last placed on-line (generally the time the system was started unless it was manually taken off-line).

    /usr/sbin/psrinfo -v
    Status of processor 1 as of: 12/12/02 09:25:50
    Processor has been on-line since 11/17/02 21:10:09.
    The sparcv9 processor operates at 400 MHz,
    and has a sparcv9 floating point processor.
    Status of processor 3 as of: 12/12/02 09:25:50
    Processor has been on-line since 11/17/02 21:10:11.
    The sparcv9 processor operates at 400 MHz,
    and has a sparcv9 floating point processor.

    The psradm utility can enable or disable a specific processor.

    To disable a processor:
    /usr/sbin/psradm -f processor_id

    To enable a processor:
    /usr/sbin/psradm -n processor_id

    The psrinfo utility will display the processor_id when run in either standard or verbose mode.

  • RAM

    The prtconf utility will display the system configuration, including the amount of physical memory.

    To display the amount of RAM:

    /usr/sbin/prtconf | grep Memory
    Memory size: 3072 Megabytes

  • Disk space

    Although there are several ways you could gather this information, the following command lists the amount of kilobytes in use versus total kilobytes available in local file systems stored on physical disks. The command does not include disk space usage from the /proc virtual file system, the floppy disk, or swap space.

    df -lk | egrep -v "Filesystem|/proc|/dev/fd|swap" | awk '{ total_kbytes += $2 } { used_kbytes += $3 } END { printf "%d of %d kilobytes in use.\n", used_kbytes, total_kbytes }'
    19221758 of 135949755 kilobytes in use.

    You may want to convert the output to megabytes or gigabytes and display the statistics as a percentage of utilization.

    The above command will list file system usage. If you are interested in listing physical disks (some of which may not be allocated to a file system), use the format command as the root user, or the iostat -En command as a non-privileged user.

  • Processor and kernel bits

    If you are running Solaris 2.6 or earlier, you are running a 32-bit kernel.

    Determine bits of processor:
    isainfo -bv

    Determine bits of Solaris kernel:
    isainfo -kv
  • vlc and ffmpeg on fedora core 5

    1) What I tried first was http://www.videolan.org/vlc/download-fedora.html
    --> didn't work on fedora core 5

    2) Then I did:
    rpm -ivh http://rpm.livna.org/livna-release-5.rpm
    instead

    3) If you are not interested in the vlc player, go to (7)
    yum install xvidcore
    yum install xvidcore-devel
    yum install x264
    yum install vlc

    when you run vlc, if there is a permission problem, you have to have
    System -> Administration -> Security Level and Firewall -> SELinux Tab
    set to "Permissive" and not "Enforced"

    4) When I played something like schaufel.mpeg, I got:
    VLC media player 0.8.4a Janus
    vlc: pcm_plug.c:384: snd_pcm_plug_change_channels: Assertion `snd_pcm_format_linear(slv->format)'
    failed

    5) goto VLC settings -> preferences -> audio -> o/p modules -> advanced
    and change the Audio Output Module to Linux OSS Output
    Another thing you can do is: vlc schaufel.mpeg --no-audio

    6) related topics: Alsa, oss linux audio devices. So now, I am OK to use vlc

    7) About ffmpeg, first I need svn version control to get the sources
    yum install subversion

    8) Compile ffmpeg
    svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk
    ./configure
    ./make

    Then, you can do something like:
    ffmpeg -i videos/schaufel.mpeg -f mp3 toto.mp3