- Option 1:
set laststatus=2 set statusline+=%F\ row\:%l\ col\:%c
- Option 2:
set ruler
Search This Blog
VIM: show column number
MacVim: set font size
echo "set guifont=Menlo Regular:h14" >> ~/.vimrcor
- CMD+= to zoom in
- CMD+- to zoom out
TCL: array to list or list to array
- List to array:
> array set a [list b 1 c 2 d 3] > puts $a(b) 1 > puts $a(c) 2 > puts $a(d) 3
- Array to list:
> puts [array get a] b 1 d 3 c 2
Eclipse 4.4 Luna on Mac OS 10.9.5: Eclipse.app is not supported on this type of mac
I have recently installed Mac OS 10.9.5 update. After update, I found Eclipse.app failed to start, it pops up a window with message: "It is not supported on this type of Mac."
The solution is:
- Find your java home:
/usr/libexec/java_home -V
, you can see the java home like below:Matching Java Virtual Machines (1): 1.8.0_20, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home
- Edit file: /Applications/eclipse/Eclipse.app/Contents/Info.plist, and insert the follow line:
<string>-vm</string><string>/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/bin/java</string>
to the proper location. - Now you can try to click the Eclipse.app icon, if it pops up another error message: "Eclipse is damaged and can’t be opened. You should move it to Trash.", you will need to run the following command to fix:
xattr -d com.apple.quarantine /Applications/eclipse/Eclipse.app/
Note: you can run the following command to check directory attributes:
xattr /Applications/eclipse/Eclipse.app/
see also
Clonezilla: shutting down caused by "critical temperature"
When running clonezilla on a i3 laptop, it shut down because of high cpu temperature. The solution for this is below:
- While getting into the clonezilla wizard, and before starting the cloning process, Alt+F2 open another terminal:
- Run the command
cpufreq-into
you will see the output like below:analyzing CPU 0: driver: acpi-cpufreq CPUs which run at the same hardware frequency: 0 CPUs which need to have their frequency coordinated by software: 0 maximum transition latency: 10.0 us. hardware limits: 933 MHz - 2.13 GHz available frequency steps: 2.13 GHz, 2.00 GHz, 1.87 GHz, 1.73 GHz, 1.60 GHz, 1.47GHz, 1.33GHz, 1.20 GHz, 1.07 GHz, 933 MHz
- Run the follow command:
sudo cpufreq-set -c 0 -f 1.60GHz
to throttle the cpu speed to 1.6GHz. - Alt+F1 to switch back to clonezilla terminal, and start the clone process
See also
Eclipse for Windows: Could not open/create prefs root node Software\JavaSoft\Prefs
When compiling a project cloned from git repository, got the following warning:
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
Solution:
- Run regedit
- Locate key HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Prefs
- Right click the icon then select Permissions...
- Give full control to users
Change directory ownership recursively on Windows 7
Open Command Prompt as Administrator:
takeown /f "C:\Path\To|Folder" /t /d y icacls "C:\Path\To|Folder" /grant wilson:F /t /q
See also
Create a bootable Window 7 installer usb disk on Debian 7
- You need to the Windows 7 ISO image file ready. e.g. Win7.ISO
- You need to install p7zip-full to extract the ISO image.
sudo apt-get install p7zip-full
- You need to install ms-sys
- Plugin your USB disk and check its device name.
sudo blkid
- Make a NTFS partition on the USB drive by using cfdisk, or gparted and apply boot flag to it.
- Format the USB partition,
sudo mkfs.ntfs -n WIN7 /dev/sdX1
- Mount the partition by pulling off and re-plug in the USB drive or run
mount /dev/sdX1 /media/USB
- Extract the ISO image to the mounted partition:
cd /media/USB; 7z x /path/to/Win7.iso
- Run ms-sys to install the Window 7 boot sector:
ms-sys -7 /dev/sdX
Note: you need to install the boot sector to the USB drive's MBR, so you should use /dev/sdX NOT /dev/sdX1
See also
- To create a bootable USB on Windows, use USB DVD download tool from Microsoft
Remove grub boot sector from a partition
I accidentally installed grub boot sector onto partition /dev/sdc1 instead of /dev/sdc, which is wrong. To remove the boot sector from partition /dev/sdc1:
sudo dd if=/dev/sdc1 of=sdc1.bootsector bs=512 count=1 sduo dd if=/dev/zero of=/dev/sdc1 bs=512 count=1The file sdc1.bootsector is a backup in case anything go wrong.
Install ms-sys on Debian
- Download ms-sys from http://ms-sys.sourceforge.net/#Download.
- Install required packages:
sudo apt-get install build-essential gettext
- Extract the source, and compile, then install:
cd /tmp; tar zxvf ~/Downloads/ms-sys-2.4.0.tar.gz; cd /tmp/ms-sys-2.4.0 make sudo make install
NOTE:
- You need to install build-essential package to install the compilers.
- You need to install gettext package to fix the error
msgfmt: command not found
Javascript: remove an element from an array
var e = { 'name':'John West' }; var array = []; array.push(e); # remove element from the array var idx = array.indexOf(e); array.splice(idx, 1);
javac: include a directory into classpath
On Unix platform:
javac -cp /opt/eclipse/plugins/*:/myproject/lib/* MyClass.javaOn Windows platform:
javac -cp "c:/eclipse/plugins/*:d:/myproject/lib/*" MyClass.java
see also
Java decompilers
Open source
- Procyon [GUI front-ends: Luyten, SourceTeam Java Decompiler[Recommend]
- Krakatau
- CFR
Close source
- Java Decompiler (JD)[Recommend]
- fernflower Doc
- DJ Java decompiler
- Cavaj
See also
PostgreSQL: make a copy of an existing database (includes tables and all records)
If the source database is owned by another user, you must login as super user, then run the command in psql:
You may get errors if the source database is in use:
CREATE new_db WITH TEMPLATE old_db OWNER src_db_owneror run the command in terminal:
createdb -O src_db_owner -T src_db new_db
You may get errors if the source database is in use:
ERROR: source database "src_db" is being accessed by other usersYou can kill all the connections to the source databse:
SELECT pg_terminate_backend(pg_stat_activity.procpid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'src_db' AND procpid <> pg_backend_pid();then run the command
CREATE new_db WITH TEMPLATE src_db OWNER src_db_owner
Python: generates crc32 and adler32 checksum for big files
import zlib
import sys
import urllib2
def __zlib_csum(url, func):
if isinstance(url, basestring if sys.version_info[0] < 3 else str):
url = urllib2.Request(url)
f = urllib2.urlopen(url)
csum = None
try:
chunk = f.read(1024)
if len(chunk)>0:
csum = func(chunk)
while True:
chunk = f.read(1024)
if len(chunk)>0:
csum = func(chunk, csum)
else:
break
finally:
f.close()
if csum is not None:
csum = csum & 0xffffffff
return csum
def crc32(url):
return __zlib_csum(url, zlib.crc32)
def adler32(url):
return __zlib_csum(url, zlib.adler32)
if __name__ == '__main__':
print(hex(crc32('file:/tmp/111.zip')))
print(hex(adler32('file:/tmp/111.zip')))
Subscribe to:
Posts (Atom)