Google
 

6/2/14

(gnome-ssh-askpass:13543): Gtk-WARNING **: cannot open display:

(gnome-ssh-askpass:13543): Gtk-WARNING **: cannot open display:

While  git clone https://dokokanogitrepos/passtuki.git if get the above error.

run

#$ unset SSH_ASKPASS

3/3/14

To show Justin how it works

Here you can write whatever you think interesting.

12/10/13

Load Microsoft Word Macro

To add the template to the list of global templates



  • On the Tools menu, click Templates and Add-ins.
  • In the Templates and Add-ins dialog box, click Add.
  • Navigate to global_macros.dot, and then click OK.
  • The template appears in the Checked items are currently loaded list, and Word automatically selects the check box next to the template name, as shown in this illustration.

7/20/13

count number of lines under linux

Use the following to see how many jobs are submitted.

>> qstat -u username | wc -l

10/18/12

Fiji: install deconvLab

When first download the plugin, it does not work. It is a zip file. Put the zip file into the plugin folder of Fiji. Then unzip it. If you don't unzip it, Fiji cannot load it.

6/5/12

Ubuntu Live CD root password and live session password for default user Ubuntu

Posted on December 11, 2009 by GoogleThem.
Categories: Linux tips and tricks.
sudo passwd ubuntu
Then create your password, you will need to already be in Terminal ;-)
To create a usable root user’s account on a live cd, you can set the root password then su. This has not been possible in previous versions of Ubuntu as their user model made you remember to sudo before each command requiring root access.
sudo passwd root
It’s easier just to sudo command for one time use, instead of creating a root user to su to.
As of Ubuntu 9.10, I haven’t been able to login with “demo” or “Ubuntu” as the password for live session username “Ubuntu”.
If you are running most other types of linux like Debian, Red Hat, Mepis, Suse and others, they have an actual root user with an account.
It is easier to gain root access permanently, for these other flavors of Linux click here to learn how.

5/15/12

Dropbox cannot sync problem.

This problem was solved for me by following this article on Dropbox support:

https://www.dropbox.com/help/72

Of which the key details were:

Permissions errors occur more frequently when using shortcuts (Windows), aliases (Mac) or symlinks (Mac/Linux) to sync folders outside of your Dropbox folder.

Often you can resolve the problem by reverting the file's sharing settings using an administrative account. Here's how:

On Mac OS X
The easiest way to fix all Dropbox settings folder permissions in Mac OS X is through the Terminal application. You can run Terminal using Spotlight or find it in the Applications > Utilities folder
Once there, copy and paste the following lines into Terminal one at a time and exactly as it is written and press the return key after each line:
sudo chown -R $USER ~/Dropbox
sudo chmod -R u+rw ~/Dropbox
sudo chown -R $USER ~/.dropbox
sudo chmod -R u+rw ~/.dropbox

You may be prompted to enter your password. Enter the password you use to log in to the computer to permit the permissions change
If you've moved your Dropbox at some point, replace ~/Dropbox in the first two lines with the path to your Dropbox folder.

This command will grant your user account read and write access to all of the files in the Dropbox settings folder. After running these commands, restart your Dropbox and it should be able to sync happily again.

9/19/11

Comment in .vimrc

It is unusual. It is ".

7/31/11

matlab mex

1. be careful with the data type. It messes up instead of telling you that there is some implicit conversion.

7/26/11

use vi to open two files at the same time.

from here

Sometimes you need to edit a new or existing file while looking at a separate file using VI. This can be very useful and a powerful time saver. Fortunately you can do this using some simple commands.


First go ahead and edit a file with VI
shellprompt$ vi test-1.txt
while in VI enter the following
:new
This will open a new split screen session, in order to navigate between the two windows in VI do the following
ctr-w
j
Or
ctr-w
k
Using the first will move you to the lower window and using the latter will move you to the upper window.
To make one of the windows full screen and out of the dual screen mode use the following
:only
*Important Side Notes
If you used :new and opened up a new window session it will not have a name so you cannot save it without entering the following
:wq whatevername.txt
Also if you want to open a file in split screen mode that is not new and exists you can enter the following
:new /path/to/whateverfile

7/16/11

list only direcoties

>> ls -d */

to list hidden direcotories:

>> ls -d .*/

7/5/11

mac: move applications to different spaces.

You do not have to view all Spaces to move windows between them (That is, by pressing F8, then using your mouse to drag and drop the desired window to the desire Space location). Nor do you have to drag to a screen edge, wait, then drop. If you like to use your keyboard, here's a fast way to do it.

  1. Using your mouse, click and hold the window you want to move to another Space.
  2. While still holding your mouse button down, use your Spaces keyboard shortcut to move to the desired Space. This is usually done by pressing Control and one of the arrow keys.
The window you are holding will be moving with you as you change your Spaces. Once you reach your destination, release the mouse button.

[robg adds: You can also use this method to move the window directly to a numbered space -- just select the window, then press Control-1, -2, -3, etc. This is my preferred method of moving a window to a space, as it seems by far the quickest.]


source from here

5/20/11

rsync exclude files.

To exclude some directory, check the following:

http://www.thegeekstuff.com/2011/01/rsync-exclude-files-and-folders/

5/6/11

uninstall Qt


sudo /Developer/Tools/uninstall-qt.py

3/22/11

ITK directory

To configure cmake
ITK_DIR
It should be "/Users/xxxx/software/InsightToolKitCompiled", where you put your compiled ITK.

3/21/11

Problem with ITK: library not loaded.

Problem: 
dyld: Library not loaded: libITKCommon.3.16.dylib


Solution:
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/usr/local/lib/InsightToolkit


/usr/local/lib/InsightToolkit is where the "libITKCommon.3.16.dylib" lives in.

12/28/10

use grep

Recently I am using Mercurial to manage my Matlab codes. I need combine commands "hg" with "grep" to see which files are updated. Here is how it is working:

>> hg status | grep '\.m$'

The above command will give all the .m files without any other junks, such as "*.m~" and other image files.

12/23/10

Install python packages.

Python provides a easy solution to install packages and resolve package dependencies.


>> sudo easy_install simplejson 

This works very well!!!

11/17/10

Debian Lenny.

Have not used Linux (Debian) for a while. Today, my old computer for my son showed some problem with X windows. I could not start the X server. Tried to reconfigure the Xorg. The Wiki from Debian is very helpful. Followings are the steps I followed.



Switch to a console as root (not a terminal emulator in X), then run:

/etc/init.d/kdm stop
/etc/init.d/gdm stop
/etc/init.d/xdm stop
cd /etc/X11/
Xorg -configure

Alternatively, reboot the machine in single user mode, then run:

cd /etc/X11/
Xorg -configure

Follow the on-screen instructions. This should give you something to work with.

Run X


After installation run:

startx

10/11/10

apple page customize dictionary

copied from: http://discussions.apple.com/thread.jspa?threadID=531999

I've converted the all.dic from Medic.zip in the format you need with Pages. A quick test showed that it works.

If you send me your e-mail address, I'll send you the new dictionary file. Click on my name above the atavar and use the e-mail address in the Biography field.

You then only need to join your ~/Library/Spelling/en with the new medic.en:

* Either open both en and medic.en in TextEdit and copy medic.en to the en window, then save the file
Or, if you're familiar with Terminal.all, you could cd to ~/Library/Spelling and use this command:

cat ~/Desktop/medic.en >> en

(I assume that you unzipped the file to your desktop)
---

If you want to change all.dic by yourself, then you have to replace the line endings with a special character from the en file. The character looks like "^@" but is in fact one character. In the resulting file, the words are all in one line separated by the special character. TextEdit doesn't show this character, so to change all.dic you should use something like emacs that comes with Mac OS X. You can launch emacs in Terminal.app.

9/22/10

vi editor: multiline comment

1. :x,y s/^/# /

The colon is command mode, obviously
x and y is a range of line numbers you want to affect
s is a sed substitution, the caret (^) means the beginning of the line
The sharp (#) is the comment character, again obviously
I put a space after the comment, but it isn't necessary, substitute any string that suits you.



2. Another way to do do this is to visually select the lines you want to comment with shift-v and up and down arrows, then type

:s/^/# /

Easier for blocks of fewer lines.

NB: When you press : vim will add '<,'> to the command line so the final command is:

:'<,'>s/^/# /

9/20/10

Vim: comment multiple lines


Vim Tip: Comment out multiple lines

Commenting out a bunch of lines without a vim plugin:
Select your lines with VISUAL BLOCK (CTRL-V), then press I to insert before all highlighted lines. Next type your comment character, # (for python, shell, etc). Last press ESC.
I forget not frequently used, but helpful VIM commands from time to time. Why not blog it?
You can alternatively select your lines with VISUAL LINE (SHIFT-V), then type : s/^/#
This tells the selected lines that you wish to substitute the start of the line with the # char.

vim cut past; copy and past

Ever try to cut (or copy) some lines and paste to another place? If you need to count the lines first, then try these to eliminate counting task.


Cut and Paste:
1. Place the cursor at the beginning of the block you want to CUT.
2. Mark it with md
3. Go to the end of the block.
4. Cut it with d'd
5. Go to the new location that you want to PASTE those text.
Press P.

Copy and Paste:
1. Place the cursor at the beginning of the block you want to COPY.
2. Mark it with my
3. Go to the end of the block.
4. Copy it with y'y
5. Go to the new location that you want to PASTE those text.
Press P.

The name of the mark used is related to the operation (d:delete or y:yank).
I found that those mark names requires minimal movement of my finger.


Visual line mode (by shift+v):
delete by: d
Visual block mode (by ctrl + v):
delete by: c

8/12/10

Cool vi

Start to vi as my editor on Mac. It is very cool. Here I just record some of the very useful notes for myself.

1. show line numbers
:set number
one can hide the numbers by :set nonumber

5/12/10

Sharing Data Among a GUI's Callbacks

http://www.mathworks.com/access/helpdesk/help/techdoc/creating_guis/f13-998449.html

The first method, nested functions, seems to work only when you write the GUI programmatically. If you use GUIDE, this may not be easy to implement. In such case, use application data is better.

5/2/10

compile Qt from source code.

Decided to compile from source because I want to have -arch x86_64 -cocoa and -qt-tiff


This target is using the GNU C++ compiler (macx-g++).

        Recent versions of this compiler automatically include code for
        exceptions, which increase both the size of the Qt libraries and
        the amount of memory taken by your applications.

        You may choose to re-run configure with the -no-exceptions
        option to compile Qt without exceptions. This is completely binary
        compatible, and existing applications will continue to work.


Build type:    macx-g++
Architecture:  macosx ( x86_64 )
Using framework: Cocoa

Build ............... libs tools examples demos docs translations
Configuration .......  build_all debug shared dll largefile stl precompile_header mmx 3dnow sse sse2  x86_64 absolute_library_soname  minimal-config small-config medium-config large-config full-config dwarf2 qt3support phonon phonon-backend accessibility opengl reduce_exports ipv6 getaddrinfo ipv6ifname getifaddrs png gif no-freetype system-zlib nis cups openssl xmlpatterns multimedia audio-backend svg webkit script scripttools release debug qt_framework  x86_64
Debug ............... yes (combined)
Default Link ........ debug
Qt 3 compatibility .. yes
QtDBus module ....... no
QtConcurrent code.... yes
QtScript module ..... yes
QtScriptTools module  yes
QtXmlPatterns module  yes
Phonon module ....... yes
Multimedia module ... yes
SVG module .......... yes
WebKit module ....... yes
JavaScriptCore JIT .. To be decided by JavaScriptCore
Declarative module .. no
STL support ......... yes
PCH support ......... yes
MMX/3DNOW/SSE/SSE2..  yes/yes/yes/yes
Graphics System ..... default
IPv6 support ........ yes
IPv6 ifname support . yes
getaddrinfo support . yes
getifaddrs support .. yes
Accessibility ....... yes
NIS support ......... yes
CUPS support ........ yes
Iconv support ....... no
Glib support ........ auto
GStreamer support ... auto
Large File support .. yes
GIF support ......... yes
TIFF support ........ plugin (qt)
JPEG support ........ plugin (qt)
PNG support ......... yes (qt)
MNG support ......... plugin (qt)
zlib support ........ system
Session management .. auto
OpenGL support ...... yes (Desktop OpenGL)
OpenVG support ...... no
ODBC support ........ plugin
SQLite support ...... plugin (qt)
OpenSSL support ..... yes (run-time)
alsa support ........ no


lipo in Mac

lipo is very helpful. Look at the following examples.



$ lipo -info /usr/local/lib/libgd.a
input file /usr/local/lib/libgd.a is not a fat file
Non-fat file: /usr/local/lib/libgd.a is architecture: ppc7400

$ lipo -info /usr/lib/libcrypto.dylib
Architectures in the fat file: /usr/lib/libcrypto.dylib are: ppc7400 ppc64 i386 x86_64


How to uninstall Qt on Mac.

If you installed the binary file, do the following:

sudo /Developer/Tools/uninstall-qt.py

4/22/10

Use dar to backup large directories to multiple DVDs.

I have a large directory of research data. Cannot use tar to do the work because the file size limit of tar is 4G. Finally get dar, which works very well. Use the following to backup


>> sudo dar -s 10M -c test -R / -g /Volumes/DATABACKUP/Research/ -v


The above means: backup all the stuffs in directory /Volumes/DATABACKUP/Research/. Since there are so many files in this directory, dar will make sure that the files it generate is small enough for later use. Here with -s 10M, dar generates files of 10 M.  -v is used to display message. -R is used to set the ROOT directory, which is / here. -g restricts the directory to /Volumes/DATABACKUP/Research/.


4/15/10

Doxygen graph interpretation.


call graph: 

A ------> B: A is called by B. 

Classes: 

A ----> B: Actually B is the parent class! One way to understand/remember this that A is called as B (for example: A is a dog class; B is an animal class. Dog is called as animal. 

4/7/10

Qt and gsl library problem.

ld: warning: in /usr/local/lib/libgsl.dylib, file is not of required architecture


Solution: 
open the Makefile and: 
1. CFLAGS: get rid of "arch i386'. 
2. CXXFLAGS: get rid of "arch i386"
3. comment LFLAGS. 
4. QMAKE_COMP_QMAKE_OBJECTIVE_CFLAGS: get rid of "arch i386". 

then save the Makefile and do: 
> make clean
> make
you will get warning but it should pass!

4/6/10

dyld: Library not loaded

After I installed qwt, everything seems to work. However, whenever I execute the program (examples), I got into trouble. When I used Qt creator to open one particular example and build it, I encountered the following error: 
dyld: Library not loaded: libqwt.5.dylib
I searched the internet and did not find any easy solution. Proudly I used the following command to fix the problem. It may not be elegant but it works for me.


sudo ln -s /usr/local/qwt-5.2.0/lib/libqwt.5.dylib /usr/lib/libqwt.5.dylib



3/29/10

logout kde desktop from command line.

1. 'killall kdeinit' to logout KDE.
2. 'dcop kdesktop default logout'. This one will popout the logout dialog and ask the user what to do (logout, cancel or reboot). 

3. 'dcop ksmserver ksmserver logout 0 0 0 '. 
If you want to reboot the machine after logout you have 'dcop ksmserver ksmserver logout 0 1 1'

kde slow keyboard response

Check the following solution.

Fortunately you can turn it off with just the mouse by going to the K menu; Control Centre -> Regional and Accessibility -> Accessibility -> Activation Gestures, and untick the first box ('Use gestures for activating slow keys and sticky keys'). Also go to the Keyboard Filters tab and untick the 'Use slow keys' box if it is ticked. Press apply and you should be OK.

switch to root user from kde GUI "run command".

Use:

kdesu command

lock kde screen from command line.

Lock your KDE screen from the command line

January 29th, 2009 by T4L

Did you know you can lock your current KDE screen by using the command line? For the 3.x series use

dcop kdesktop KScreensaverIface lock

and for KDE 4.x try

qdbus org.freedesktop.ScreenSaver /ScreenSaver Lock

With the help of these you should be able to craft a simple shell script that will lock your screen at given actions. For example, you can leave your screen unlocked and make the PC activate the commands above when it detects mouse movement or when a certain application is launched.

3/22/10

Top 10 things that annoy programmer

Copied from http://www.kevinwilliampang.com/2008/08/28/top-10-things-that-annoy-programmers/

Very nice post!




Top 10 Things That Annoy Programmers

Programmers all have their pet peeves. Whether it’s scope creepHungarian notation, or smelly coworkers, we’ve come to accept that there are certain nuisances that come with our line of work. The following is a list of the top 10 things that annoy programmers, compiled from the results ofmy recent question on StackOverflow along with some of my own experiences:

10. Comments that explain the “how” but not the “why”

Introductory-level programming courses teach students to comment early and comment often. The idea is that it’s better to have too many comments than to have too few. Unfortunately, many programmers seem to take this as a personal challenge to comment every single line of code. This is why you will often see something like this code snippit taken from Jeff Atwood’s post on Coding Without Comments:
1r = n / 2; // Set r to n divided by 2
2
3// Loop while r - (n/r) is greater than t
4while ( abs( r - (n/r) ) > t ) {
5    r = 0.5 * ( r + (n/r) ); // Set r to half of r + (n/r)
6}
Do you have any idea what this code does? Me neither. The problem is that while there are plenty of comments describing what the code is doing, there are none describing why it’s doing it.
Now, consider the same code with a different commenting methodology:
1// square root of n with Newton-Raphson approximation
2r = n / 2;
3
4while ( abs( r - (n/r) ) > t ) {
5    r = 0.5 * ( r + (n/r) );
6}
Much better! We still might not understand exactly what’s going on here, but at least we have a starting point.
Comments are supposed to help the reader understand the code, not the syntax. It’s a fair assumption that the reader has a basic understanding of how a for loop works; there’s no need to add comments such as “// iterate over a list of customers”. What the reader is not going to be familiar with is why your code works and why you chose to write it the way you did.

9. Interruptions

Very few programmers can go from 0 to code at the drop of a hat. In general, we tend to be more akin to locomotives than ferraris; it may take us awhile to get started, but once we hit our stride we can get an impressive amount of work done. Unfortunately, it’s very hard to get into a programming zone when your train of thought is constantly being derailed by clients, managers, and fellow programmers.
There is simply too much information we need to keep in mind while we’re working on a task to be able to drop the task, handle another issue, then pick up the task without missing a beat. Interruptions kill our train of thought and getting it back is often a time-consuming, frustrating, and worst of all, error-prone process.

8. Scope creep

From Wikipedia:
Scope creep (also called focus creep, requirement creep, feature creep, and sometimes kitchen sink syndrome) in project management refers to uncontrolled changes in a project’s scope. This phenomenon can occur when the scope of a project is not properly defined, documented, or controlled. It is generally considered a negative occurrence that is to be avoided.
Scope creep turns relatively simple requests into horribly complex and time consuming monsters. It only takes a few innocent keystrokes by the requirements guy for scope creep to happen:
  • Version 1: Show a map of the location
  • Version 2: Show a 3D map of the location
  • Version 3: Show a 3D map of the location that the user can fly through
Argh! What used to be a 30 minute task just turned into a massively complex system that could take hundreds of man hours. Even worse, most of the time scope creep happens during development, which requires rewriting, refactoring, and sometimes throwing out code that was developed just days prior.

7. Management that doesn’t understand programming

Compiling
Ok, so maybe there are some perks.
Management is not an easy job. People suck; we’re fickle and fragile and we’re all out for #1. Keeping a large group of us content and cohesive is a mountain of a task. However, that doesn’t mean that managers should be able to get away without having some basic understanding of what their subordinates are doing. When management cannot grasp the basic concepts of our jobs, we end up with scope creep, unrealistic deadlines, and general frustration on both sides of the table. This is a pretty common complaint amongst programmers and the source of a lot of angst (as well as one hilarious cartoon).







6. Documenting our applications

Let me preface this by saying that yes, I know that there are a lot of documentation-generating applications out there, but in my experience those are usually only good for generating API documentation for other programmers to read. If you are working with an application that normal everyday people are using, you’re going to have to write some documentation that the average layman can understand (e.g. how your application works, troubleshooting guides, etc.).
It’s not hard to see that this is something programmers dread doing. Take a quick look at all the open-source projects out there. What’s the one thing that all of them are constantly asking for help with? Documentation.
I think I can safely speak on behalf of all programmers everywhere when I say, “can’t someone else do it?“.

5. Applications without documentation

I never said that we weren’t hypocrites. :-) Programmers are constantly asked to incorporate 3rd party libraries and applications into their work. In order to do that, we need documentation. Unfortunately, as mentioned in item 6, programmers hate writing documentation. No, the irony is not lost on us.
There is nothing more frustrating than trying to utilize a 3rd party library while having absolutely no fricken idea what half the functions in the API do. What’s the difference between poorlyNamedFunctionA() and poorlyButSimilarlyNamedFunctionB()? Do I need to perform a null check before accessing PropertyX? I guess I’ll just have to find out through trial and error! Ugh.

4. Hardware

Any programmer who has ever been called upon to debug a strange crash on the database server or why the RAID drives aren’t working properly knows that hardware problems are a pain. There seems to be a common misconception that since programmers work with computers, we must know how to fix them. Granted, this may be true for some programmers, but I reckon the vast majority of us don’t know or really care about what’s going on after the code gets translated into assembly. We just want the stuff to work like it’s supposed to so we can focus on higher level tasks.

3. Vagueness

“The website is broken”. “Feature X isn’t working properly”. Vague requests are a pain to deal with. It’s always surprising to me how exasperated non-programmers tend to get when they are asked to reproduce a problem for a programmer. They don’t seem to understand that “it’s broken, fix it!” is not enough information for us to work off of.
Software is (for the most part) deterministic. We like it that way. Humor us by letting us figure out which step of the process is broken instead of asking us to simply “fix it”.

2. Other programmers

Programmers don’t always get along with other programmers. Shocking, but true. This could easily be its own top 10 list, so I’m just going to list some of the common traits programmers have that annoy their fellow programmers and save going into detail for a separate post:
  • Being grumpy to the point of being hostile.
  • Failing to understand that there is a time to debate system architecture and a time to get things done.
  • Inability to communicate effectively and confusing terminology.
  • Failure to pull ones own weight.
  • Being apathetic towards the code base and project
And last, but not least, the number 1 thing that annoys programmers…

1. Their own code, 6 months later


Don’t sneeze, I think I see a bug.
Ever look back at some of your old code and grimace in pain? How stupid you were! How could you, who know so much now, have written that? Burn it! Burn it with fire!
Well, good news. You’re not alone.
The truth is, the programming world is one that is constantly changing. What we regard as a best practice today can be obsolete tomorrow. It’s simply not possible to write perfect code because the standards upon which our code is judged is evolving every day. It’s tough to cope with the fact that your work, as beautiful as it may be now, is probably going to be ridiculed later. It’s frustrating because no matter how much research we do into the latest and greatest tools, designs, frameworks, and best practices, there’s always the sense that what we’re truly after is slightly out of reach. For me, this is the most annoying thing about being a programmer. The fragility of what we do is necessary to facilitate improvement, but I can’t help feeling like I’m one of those sand-painting monks.
Well, there you have it. The top 10 things that annoy programmers. Again, if you feel that I missed anything please be sure to let me know in the comments!