ssh, scp, su -i -u someuser

Today I struggled with downloading a file through ssh.

I can ssh through server with account quynh.nguyen. However, in order to read the file, I must use another account

sudo -i -u someuser

Then when I issue a request to download a file from remote server to local machine. It’ll ask me for the password of someuser, which I do not have. I only have password of user quynh.nguyen.

scp ~/local_directory

The solution seems to be trivial, but I spent around 3 hours with the help of some friends to figure it out.

  1. ssh to server with quynh.nguyen account
  2. Use the shell of someuser
  3. scp to copy file from someuser to quynh.nguyen home folder. Then I’ll input the password for user quynh.nguyen
  4. scp to copy file from home folder of quynh.nguyen to local folder in my machine

Below is the code:

  1. ssh ....
  2. su -i -u someuser
  3. scp /home/someuser/some_file.txt
  4. scp* ~/local_directory 

1st problem –

the first { [ (prls6_36 – prime_36) << 7 ] – 1 } digits after decimal of Pi, in MD5

Useful links:

Other notes:

  • the first digits: notice that “digits” is in plural form. When I first read this problem, I was thinking that I only need to brute force the MD5 for 10 integers from 0 to 9, then I’d get the result.

How I solve that one? I just read the file that contains 1,000,000 digits of number after decimal of Pi, then perform a little bit of arithmetic use a library to know the MD5 of a string.

Set default font for sticky notes

The answer by NudeRaider in this link works.

The simplest way is you type something in Word Pad, change text into the font you want, and then paste that text into Sticky notes. However, I don’t want to carry out copy-paste task all the time. I want to reset the default font for Sticky Notes.

I replace all the “Segoe Print” in StikyNot.exe.mui with Arial font. (StikyNot.exe.mui is placed in folder “C:\Windows\System32\en-US\StikyNot.exe.mui”). By changing the *.mui file, we can make sure that Sticky Notes now use Arial as the default font instead of Segoe Print.

Total COmmander–Shortcut Keys I love

You might want to check the full list of shortcut keys in KeyXL.

Brief view: Ctrl + F1 <== I use brief view most of the time

Deselect all: Ctrl + Num –

Sort by name: Ctrl + F3

Sort by extension: Ctrl + F4

Sort by date/time: Ctrl + F5

Sort by size: Ctrl + F6

Open bookmark: Ctrl + D

Show file properties: Ctrl + F12

Copy current path to cmd line: Ctrl + P

Download pronunciation for english words

1. I use found in anki-english-helper google code site. So you need to go here and download

2. You need to download the AudioBarron.doc file: Audio, and change the extension from *.doc into *.py

You might want to change the fileName in line 6
fileName = 'EnglishWords.txt'

3. The input is the text file, in the code, the text file will be named “EnglishWords.txt”, 1 line for each word. For example, if you want to download pronunciation of “mother”, and “father”. The text file will look like this:


4. You need to install Python to run the source code

5. Put the text file in step 3, the from step 1, and the *.py file from step 3 in the same folder. And just call
python "link to the *.py in step 2"
For example:
python "d:\Code\PronunciationDownloadCode\"

  1. Nếu đã set password trong phpmyadmin cho MySQL thì phải vào C:\wamp\apps\phpmyadmin3.4.9\ để set lại password field trong đó.
  2. Nhớ add thư mục mysql/bin vào Environment Variables để có thể gọi mysql từ bất cứ đâu trong command line
  3. Mở Command Prompt
    cd “C:\wamp\bin\mysql\mysql5.5.20\bin”
    mysql -u USERNAME -p
    (Enter password:…)
  4. show databases;
    use DATABSE
  5. source SQL_FILE_LOCATION;

Đây là link tới Dictionary Lookup để download file sql

Nhớ là check trong source/trunk/wiktionary_setup, và chạy file lookup.sql để tạo table lookup trước khi làm bước 5.

Kết nối Python và MySQL

Trang kitebird có hướng dẫn “Writing MySQL Scripts with Python DB-API”

Trang này để download Windows distributions của MySQLdb, mình sẽ không mất công compile nữa.

Còn siêng siêng thì có thể đọc hướng dẫn của Yun Fu để tự build MySQLdb. Mình giờ không có Visual Studio, mà làm biếng cài quá, nên thôi lấy cái người ta làm sẵn để xài luôn 🙂

Để viết script trong Python, thì mình thấy trang Tutorial Points có nhiều ví dụ minh họa cho các trường hợp insert, select, delete… Nhờ trang này mà mình đã viết xong Python script để select vài columns từ database rồi.