Add my own window.onload safely without overwriting old ones

Posted on

My webpage has one existing window.onload javascript function defined by a javascript plugin in the <head> section. Now, I defined a new one and add it to the end of the HTML page: <script type=”text/javascript”> window.onload = function () { // great work here } </script> I find the new one overwrites the old one
Read more

Emacs highlighting part of lines that go over 80 chars

Posted on

How to make Emacs highlighting part of lines that go over 80 chars? I use the whitespace mode: ;; `lines-tail`, highlight the part that goes beyond the ;; limit of `whitespace-line-column` (require ‘whitespace) (setq whitespace-style ‘(face empty tabs lines-tail trailing)) (global-whitespace-mode t) More: https://github.com/zma/emacs-config/blob/master/.emacs Alternatively, you can run highlight-lines-matching-regexp with the expression .{81}. http://stackoverflow.com/questions/6344474/how-can-i-make-emacs-highlight-lines-that-go-over-80-chars

How to convert between dos and unix file coding in Emacs?

Posted on

How to convert between dos and unix file coding for files in Emacs? From Dos to Unix coding: M-x set-buffer-file-coding-system RET undecided-unix or C-x RET f undecided-unix Then save the file (C-x C-s). From Unix to Dos M-x set-buffer-file-coding-system RET undecided-dos or C-x RET f undecided-dos Then save the file (C-x C-s).

How to get the git commit tree?

Posted on

How to get a tree-like view of the git commit history? My favorite command line: git log –graph –oneline It will prints a text based graph like (with colors): * b5dc8b9 Merge branch ‘master’ of https://github.com/layerzero/libi0 | | * 7514ef1 revised the README.md a little bit | * 6692428 align size to page for both
Read more

Bash comparison operators

Posted on

What are all the bash supported comparison operators? The man 1 test contains all the operators supported in bash. An omitted EXPRESSION defaults to false. Otherwise, EXPRESSION is true or false and sets exit status. It is one of: ( EXPRESSION ) EXPRESSION is true ! EXPRESSION EXPRESSION is false EXPRESSION1 -a EXPRESSION2 both EXPRESSION1
Read more

How to rearrange Alt, Ctrl and Win keys on Linux: Win as Alt and Ctrl/Alt as Ctrl

Posted on

How to rearrange Alt, Ctrl and Win keys on Linux: Win as Alt and Ctrl/Alt as Ctrl? On Linux, the Win key is seldom used. Mapping the Alt keys which are close to my thumb is damn convenient for Emacs users. Hence, the keyboard at the bottom line would look like: ———————————————————— |Ctrl|Alt|Ctrl| Space Bar
Read more

How to detect memory leaks of C programs in Linux?

Posted on

How to detect memory leaks of C programs in Linux? I also have access to the source code of the program. There are many posts related to this: Easy and quick tools on Linux (while not very accurate): http://blog.thewebsitepeople.org/2011/03/linux-memory-leak-detection/ Valgrind: manual and a tutorial. gperftools has the Google Heap Profiler which can checks for memory
Read more

How to change default OS for windows dual boot manager in Windows 7?

Posted on

How to change default OS for windows dual boot manager in Windows 7? The c:/boot/ in older Windows does not exist anymore. Open the Control Panel and click on the System icon. In the left pane, click on the Advanced system settings link. Under the Advanced tab, click on the Settings button under Startup and
Read more

How to make Emacs run in command line by default?

Posted on

How to make Emacs run in command line by default? I do not want to open the X window. You have at least 2 choices. First choice: use emacs-nox and make it the default: # yum install emacs-nox # alternatives –config emacs and choose emacs-nox. Second choice: use emacs but with -nw to disable the
Read more

How to debug/check network-related driver information on Linux?

Posted on

How to debug/check network-related driver information on Linux? Several commands/tools that you may find usefull: Messages: dmesg grep NetworkManager /var/log/messages lshw: list hardware lshw -c network lsusb: list USB devices lsusb rfkill: enabling and disabling wireless devices rfkill unblock all rfkill event iwconfig: configure a wireless network interface iwconfig ifconfig: configure a network interface ifconfig

How to get the directory path and file name from a absolute path in C on Linux

Posted on

How to get the directory path and file name from a absolute path in C on Linux? For example, with “/foo/bar/baz.txt”, it will produce: “/foo/bar/” and “baz.txt”. You can use the APIs basename and dirname to parse the file name and directory name. A piece of C code: #include <libgen.h> #include <string.h> char* local_file =
Read more