Skip to main content

Posts

Showing posts from May, 2013

A simple script for get birth time of Linux process

This is a simple script to get the Linux birth time of the system or a process using /proc/stat and /proc/pid/stat. For example, you may get local datetime when process 12345 started: import datetime import btime datetime.datetime.fromtimestamp(btime.process_time(12456)[1]) View the source code in github gists:

winpath.py -- A simple command line tool for managing windows PATH

I have write a simple command line tool for managing windows PATH env variable with in Python. The program mainly uses _winreg lib to access the Windows Registry. Several Example: # List all the current PATH entries python winpath.py list # Find if C:\Temp in PATH python winpath.py find C:\Temp # Add C:\Temp to System PATH python winpath.py add system C:\Temp # Remove C:\Temp from PATH(both system and user) python winpath.py remove C:\Temp The code the tool is available at this github gists .

The Awesome BitTorrent Sync

The BitTorrent Sync is really an awesome tool for syncing files between your different devices. Currently, it supports Windows/Mac/Linux. The software is not like dropbox(cloud services stored you files on their servers),  it syncs folders among your own devices(the security is protected by a secret key and encrypted file transfer). And actually BitTorrent Sync is not Dropbox killer, the two services are both just awesome in their own way. Dropbox is still consider to be my own online safe storage, but BitTorrent Sync can be used as much faster sharing and syncing. For example, you may setup it on Linux via follwing steps #Downloading and unpacking wget http://btsync.s3-website-us-east-1.amazonaws.com/btsync_x64.tar.gz tar vzxf btsync_x64.tar.gz #Copy to /usr/bin/ sudo cp btsync /usr/bin/btsync #Generate the config from sample config btsync --dump-sample-config > ~/btsync.conf # Edit the ~/btsync.conf based on the embedded comments # Detail config in linux, please refer http://

Change emacs code page when shell starts in Windows

Use "chcp 65001" can change the current code page of windows console to UTF-8. To change this in emacs when "M-x shell" starts, you need to add a ~/.emacs_shellname(in the same directory of your .emacs file) containing the "chcp 65001" command.  But note that, the shellname in Windows is cmdproxy.exe, so your ~/.emacs-shellname should be ~/.emacs-cmdproxy.exe (if this is not working, try "echo %SHELL%" in emacs shell).