When working with multiple files, especially for a set of files that contain the same header, we occasionally want to edit the header. This leads to the need to update all other files as well. Fortunately, Emacs has the built in command for interactively find and replace a String pattern in multiple files. Here are the steps on how to quickly find and replace text in multiple files.

  • Open the directory that contains all the files web need to find and replace in dired mode.
  • Mark the files you want to find the text. Hit t (dired-toggle-marks) to select all files in the current folder
  • Type Q (dired-do-query-replace-regexp), type in the pattern that you want Emacs to find and the replace string. Hit RET.
  • For each occurrence, type y to replace, n to skip. Type Ctrl+g to abort the whole operation.
  • Type ! to replace all occurrences in current file without asking, N to skip all possible replacement for rest of the current file.
  • To do the replacement on all files without further asking, type Y.
  • Call ibuffer to list all opened files.
  • Type * u to mark all unsaved files, type S to save all marked files, type D to close them all.
Read more

SQLite Manager is a powerful extension for Firefox, which provides the ability to manage SQLite database from within Firefox. Also, Conkeror/Firefox store their data (history pages, bookmarks, downloads,…) using SQLite database. However, Conkeror doesn’t have any feature to have you manage its data (bookmarks, history, downloads..). You need to query that data manually from the SQLite database file. This blog post will demonstrate how to install and use SQLite Manager to manage those kinds of data from within Conkeror.

First, you need to install the SQLite Manager add-on from Mozilla extensions page. Open Conkeror and follow this url https://addons.mozilla.org/en-US/firefox/addon/sqlite-manager/. In my case, everything I need to do is to click on the Download button and the extension installer will do the rest. However, if you encounter any problem, take a look at how to forced install the extension on Conkeror’s page http://conkeror.org/Extensions.

Read more

Recently, I was working on one assignment about OSGI framework in Java. At first sight, I was excited about its idea of dynamically changing the .jar module while the application is running. However, I soon gave up with OSGI since it’s too complex and there are little documents about OSGI on the internet. OSGI with Spring Dynamic Modules requires too many config to run just a simple application. Also, there were many bugs and exceptions happened while I was working with it but I cannot not find the solution due to the lack of help/document about OSGI on the internet.

Finally, I ended up with a simple application using OSGI with Spring Dynamic Module and JDBC for working with databse. I was not successful in making a web, CLI or GUI application because of some bugs that I don’t where they came from so that the application is just like a main function automatically calls all the functions inside the provider bundle. Hopefully, in the future I will have the chance to research more about this technology to enhance this application. Here are steps of how to make that simple application. I also included the source code so you can download it to test.

Setting up the database

First you need to setup the database. In my example, I used MySQL and MySqlJDBC for connecting to the database. Create a new database named test_osgi in your MySql. After that, create 2 tables with the structure like this

Read more

tmtxt-async-tasks

This is a new emacs package that I’ve just finished. This is not a very complicated extension or something very new. This is just the code I extracted from my previous emacs’ extension tmtxt-dired-async. The purpose of tmtxt-async-tasks is to provide emacs users a tool for executing shell command asynchronously in a separate window and not be affected by the process. When you executing a command using this package, a new window will be created at the bottom of the current frame (this window is not affected by the other-window command). The shell command keep running and print out the result for you to keep track of the process and the window contains that command can be automatically closed after a specified time period when it finish executing. For more information, demo as well as how to use the package, please visit it’s homepage at http://truongtx.me/tmtxt-async-tasks.html.

Update of tmtxt-dired-async

With the release of tmtxt-async-tasks, tmtxt-dired-async should be updated, too. There is no need to keep all the code to executing command asynchronously inside tmtxt-dired-async because the new package has all that feature. tmtxt-dired-async now relies on tmtxt-async-tasks so if you are going to update to the new version, please include tmtxt-async-tasks as well. Also, in the new release, I have changed many function name to make it shorter and changed many option variables for easier usage so if you want to upgrade, please change the function name accordingly. You can see all the new name at the project’s homepage http://truongtx.me/tmtxt-dired-async.html.

Read more

A few days ago, Facebook made some minor changes to its News feed that make my CEFM mode sometimes cannot find the selected story link to open. Today, I have released a new version of CEFM to fix that error. Also, in this update, I have improved some existing functions and add some more features so that it can interact more with the Facebook page.

If you are installing CEFM for first, just ignore this post and head to the project’s home page at CEFM Homepage. If you upgrade from a version before 21 Nov 2013, please consider reading these post because I have changed some functions’ names.

Remove pre-keybindings for some Quick access commands

Before that, CEFM bound 3, 4, 5 to the 3 commands cefm-open-friend-request, cefm-open-messages and cefm-open-notification respectively. However, in this new release, I have remove those key bindings to give you freedom of binding to whatever you want.

define_key(facebook_keymap, "3", "cefm-open-friend-request");
define_key(facebook_keymap, "4", "cefm-open-messages");
define_key(facebook_keymap, "5", "cefm-open-notification");

Change Commands Prefix

Since this release, I have changed the prefix of all commans from facebook- to cefm-. That is to prevent duplicate commands if Conkeror includes some commands for Facebook with the same name. You need to change your key bindings in order to use the new version. Here is the list of changes

Read more

aria2 is a lightweight multi-protocol & multi-source command-line download utility. It supports HTTP/HTTPS, FTP, BitTorrent and Metalink. aria2 can be manipulated via built-in JSON-RPC and XML-RPC interfaces.

I’m currently using a Mac. There are many good download manager for MacOS out there, for example Folx, Speed Download, JDownloader, iGetter, DownThemAll, uTorrent, Transmission,… However, most of them have drawbacks. Speed Downloader and iGetter are not free, you have to pay in order to use it and you cannot download torrent with them. Folx offers a free version but the functionality is limited. Also, Folx 3 has removed the ability to download torrent file. DownThemAll requires Firefox to be opened. uTorrent and Transmission are just torrent specialized. But the most annoying problem for me is that they are not light-weight applications. I want some simple, free but light-weight app that can support multiple protocols from http, ftp to torrent.

Finally, I found aria2, a CLI download manager that can satisfy all my demands. When disk cache is off, the physical memory usage is typically 4MiB (normal HTTP/FTP downloads) to 9MiB (BitTorrent downloads). CPU usage in BitTorrent with download speed of 2.8MiB/sec is around 6%.

However, sometimes the command line brings more power than necessary. I also need a simple GUI for working with the app more easily. Webui-aria2 is the solution. One of the great feature of webui-aria2 is that it’s a web-based UI. I can use the browser (Conkeror or Chrome with Vimium) to interact with it (add, pause, remove downloads) using the keyboard very quickly.

Here are the steps on how to setup aria2 client on a Unix/Linux system.

Note: If you’are using Linux, there are an application that is the GUI wrapper for aria2 called uGet.

Read more

Macports is one of the most popular package manager system for MacOS. Usually, when you want to install Macports, you will download the automatic installer from Macports website. This is convenient for those people who first come to Macports’s world. Usually, the best way to backup with Mac is to backup your home directory. However, Macports by default will install all its packages into /opt/local, which make it difficult when you want to re-install your whole system or migrate to a new Mac because it’s outside your home directory.

The solution is to install Macports into your home directory and config it to put all its stuff into your home directory, too. By using this method, you can easily backup your home directory and start your work immediately with all your favorite applications/packages when you re-install the whole system.

There is one thing to notice. Not all packages from Macports can be installed and launched from your home directory. The ones that cannot are those that need to create another user, interact with folders outside your home dir,… (tasks that need sudo permission). One example that I have encountered is Mysql server. It needs to create another user to run the instance of Mysql but I think we can config it (I have not tried yet). To fix this, simply install 2 instances of Macports, one using the default installer and one in your home directory.

Read more

I’ve just implemented new feature for CEFM - Scrolling chat conversation.

Usually, while you are chatting with your friend, you want to scroll up the conversation for viewing the conversation history. The command facebook-scroll-up-current-coversation and facebook-scroll-down-current-coversation will help you easily scroll through the current chat conversation that you are in. Simply bind it to any key stroke that you want to use, for example

define_key(facebook_keymap, "C-I", "facebook-scroll-up-current-coversation");
define_key(facebook_keymap, "C-K", "facebook-scroll-down-current-coversation");

You can also config the scroll gap (the distance for each scroll) by setting the following variable

facebook_mode_scroll_gap = 50;

For more information about the mode, visit its homepage at http://truongtx.me/conkeror-extended-facebook-mode.html

Read more

Conkeror and Emacs are my two most used applications, one for web browsing and one for text editing, developing. It would be very great if I could use Emacs to interact directly with Conkeror for developing purpose. Fortunately, I found Mozrepl, an extension that “lets us program Firefox and other Mozilla-based applications from the inside” (quoted from Mozrepl homepage). This article is to summarize the steps on to set up Mozrepl in Conkeror and Emacs.

Install Mozrepl extension for Conkeror

You cannot directly install Mozrepl for Conkeror from Mozilla Add-ons page. Instead, you need to download it from the Mozilla Add-ons page, edit the install.rdf file and do a forced-installation following the instruction here Conkeror Extensions.

Config Mozrepl

Create a file named mozrepl-conkeror.js inside your home directory. Place this code as the file’s content

var conkeror = Cc["@conkeror.mozdev.org/application;1"]
	.getService().wrappedJSObject;

this.enter(conkeror);

Next, open your .conkerorrc and add this piece of code inside it to start the Mozrepl immediately when Conkeror start and then load the config file above.

Read more

Today, I have added my extension for Conkeror some new features. They are small but really useful for interacting with Facebook effectively through the keyboard.

You can find the information as well as the instruction on how to install and use at the package’s homepage http://truongtx.me/conkeror-extended-facebook-mode.html

Cycle through chat conversions with keyboard

Everything will be great if there is a handy keystroke for cycling through chat conversations. CEFM provides a useful command named facebook-cycle-conversations to help you solve this problem. Simply bind it to a keystroke that you want, for example

define_key(facebook_keymap, "C-C", "facebook-cycle-conversations");

Now in every facebook page, type q to search for a friend to chat, press C-C to jump to the next chat conversation. Usually if you press Esc, the current chat conversation will be closed. If you want to continue browsing Facebook without closing it, you can see the steps how to achieve it in this post Using Esc key in Conkeror.

Functions to fix fallthrough keys that Facebook cannot recognize

For keys from 0-9, there is a little problem so that I have to implement some custom functions for performing their functionalities but have not finished all, they will appear in the next version.

  • 3 - Open Friend Requests panel
  • 4 - Open Messages panel
  • 5 - Open Notifications panel
Read more