Usually, there are many opening tabs in my Conkeror (more than 50). However, sometimes Conkeror on MacOS got trouble when quitting which prevents it from auto saving the session file or even worse the session file will appear empty next time Conkeror starts. That makes me lose many opening tabs that I’m reading and I cannot remember which tabs I need to re-open. The solution is using Git for managing, backing up the session file.

Firstly, in order to manage the session file, we need to locate it on our computer. On Mac OS, the Conkeror session file is stored under /Volumes/tmtxt/Library/Application Support/conkeror/Profiles/profile-name/sessions/. Create a git repository there. After that, we need a script that automatically add all the files to staged area and commit with the message containing the current time. The content of the script looks similar to this

now=$(date +"%T")

cd "~/Library/Application Support/conkeror/Profiles/profile-name/sessions/"
git add .
git commit -m "Session at $now"

Finally, hooking the function to run the script into Conkeror.

add_hook("create_buffer_hook", function(buffer){
  shell_command_blind("sh /path/to/conkeror/session/backup/script");
});

Every time a new buffer is created, Conkeror will auto call the script to commit it to git. If you want, you can add hook when a buffer is killed.

Read more

There are several ways of installing Conkeror on Mac OS X but I prefer using the conkeror_mac_bundle script for quickly building the Conkeror application and easily setting it as default browser on Mac OS. For instruction on how to install Conkeror using this method, refer to this page Installation Instructions for OS X.

The only problem with conkeror_mac_bundler script is that you are not able to run shell command directly in Conkeror. The reason is because it cannot find conkeror-spawn-helper in the load path. However, conkeror-spawn-helper is already included when the script build the Conkeror bundle. You can find it under the folder Contents/MacOS inside the Conkeror.app bundle.

Once you find it, add this code to your .conkerorrc file and change the path corresponding to the real location on your computer

PATH.push("~/Applications/conkeror_mac_bundler/Conkeror.app/Contents/MacOS");

That’s everything you need to do. Restart Conkeror and try it by pressing M-x and then shell-command. You can also use TAB completion there.

Alt Text

Alt Text

Read more

minecraft

Set up Minecraft server

First, download the Minecraft Multiplayer Server executable jar file from its download page here https://minecraft.net/downloadLink. When you finish, place the .jar file inside a folder named minecraft in your home directory. Open Terminal, cd to the minecraft directory you’ve just created before and execute this command to start a Minecraft server

$ java -Xmx1024M -Xms1024M -jar minecraft_server.jar

If you want to run it without GUI, add nogui argument at the end of the command. For the first time, it will generate the game contents and place them inside the minecraft folder above. After it have finished generating, stop the server and open the minecraft directory before, you will see a file named server.properties there. All the server properties are described here http://minecraft.gamepedia.com/Server.properties. Take a look at that page and config the server to what you want. If you don’t want the server to authenticate username with Minecraft server, change online-mode to false to prevent this.

Read more

Finding text in Emacs

When working with a project with large number of files, there will be the case that we cannot remember where a piece of text come from or we want to search where one function, variable is used. There are many ways to achieve this and using the grep command in combination with Emacs is a very efficient method.

1. find-grep, grep-find and rgrep

The command find-grep (also aliased as grep-find), which you can activate via M-x, helps you run grep via find and then display all the results in a *grep* buffer. To use it, simply open the directory you need to find in dired mode and call find-grep. The command is already filled for you. All you need is to type the string pattern and press RET for grep to start working. All the result will be display in a new window, just select the item you want and hit RET to visit that file.

rgrep is another impressive command which behave similar to find-grep but it’s more interative and has more configuration to play with. Once activated, rgrep will ask you for the search string regex (default is the word at point), file types to search for (all or just one specific file type) and the base directory (default is the current working directory). Also, you can config rgrep to skip specified files or folders by add them to the two variables grep-find-ignored-files and grep-find-ignored-directories.

Read more

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