The HTTP Request IDs makes it easy to trace requests from end-to-end in the stack and to identify individual requests in mixed logs like Syslog.
Rails 3.2 introduced the ActionDispatch::RequestId middleware that make a unique X-Request-Id header avariable to the response.
curl -I http://sample.dev/
HTTP/1.1 200 OK
Date: Fri, 04 Jul 2014 03:23:43 GMT
To show this request ID in with your application logs, add this line to your config/environments/production.rb
The logs will then be tagged with the Request ID:
I,[2014-07-04T11:23:43.752028#33305] INFO -- : [ddaa28e2-3395-4e66-9ca7-48480882a1df] Started HEAD "/" for 127.0.0.1 at 2014-07-04 11:23:43 +0800I,[2014-07-04T11:23:43.755366#33305] INFO -- : [ddaa28e2-3395-4e66-9ca7-48480882a1df] Processing by StaticPagesController#home as */*I,[2014-07-04T11:23:43.759832#33305] INFO -- : [ddaa28e2-3395-4e66-9ca7-48480882a1df] Rendered static_pages/home.html.erb within layouts/application (0.2ms)I,[2014-07-04T11:23:43.791258#33305] INFO -- : [ddaa28e2-3395-4e66-9ca7-48480882a1df] Rendered layouts/_shim.html.erb (0.0ms)I,[2014-07-04T11:23:43.793947#33305] INFO -- : [ddaa28e2-3395-4e66-9ca7-48480882a1df] Rendered layouts/_header.html.erb (0.3ms)I,[2014-07-04T11:23:43.796489#33305] INFO -- : [ddaa28e2-3395-4e66-9ca7-48480882a1df] Rendered layouts/_footer.html.erb (0.2ms)I,[2014-07-04T11:23:43.797112#33305] INFO -- : [ddaa28e2-3395-4e66-9ca7-48480882a1df] Completed 200 OK in 42ms (Views: 41.2ms | ActiveRecord: 0.0ms)
Last week, We involve a function for users to exports their orders into a spreadsheet document.
We using the spreadsheet gem to modify an existing template spreadsheet.
But when opening the modified spreadsheets by Microsoft Excel, it issues an error:
File error: data may have been lost
After some google search, I was answered to set the encoding explictly:
But it doesn’t works, WTF!
Finally, I decide to create a new spreadsheet and set cell format by hand instead of modify the existing template spreadsheet document.
It’s a painful task. The spreadsheet comes up just fine without error.
Even though it doesn’t elegant, we can get ride of that annoying error.
Yestoday, I upgraded my VirtualBox from version ‘4.2.18’ to ‘4.3.6
along with upgraded the vagrant to '1.4.3’.
After I run vagrant up I got a warning message:
[default] The guest additions on this VM do not match the installed version of
VirtualBox! In most cases this is fine, but in rare cases it can
prevent things such as shared folders from working properly. If you see
shared folder errors, please make sure the guest additions within the
virtual machine match the version of VirtualBox you have installed on
your host and reload your VM.
Guest Additions Version: 4.2.18
VirtualBox Version: 4.3
After a google, I found that there is a plugin which can automatically
installs the host’s VirtualBox Gest Additions on the gest system.
The reason that the URI returns a 301 redirection is the trailing
slashes are misused. Historically, it’s common for URLs with a
trailing slash to indicate a directory, and those without a trailing
slash to denote a file:
The appending $(rvm gemdir)/gems will including Rails build-in
method(or class/module) definitions, it’s very useful to browse Rails
Formerly, I use the Emacs build-in find-tag command which bounding
to M-. to find the tags. It works, but what annoy me is that
everytime I find-tag, it prompt to choose a tag, even the first
one always what I want. So I write a command to take the place of
It seems that things goes well. But I found that If a method defined
in many places. find-tag only jump to one of them, and without any
prompt. This misguide me occasionally.
After some google search, I found a package
Etags-Select provides a
feature to find tag from multiple tag files, and if there are multiple
matching tags, it will open a selection window for you to choose the
one you want.
Sounds great! eh?
After give it a try, I found it’s not that perfect(not perfect for
ruby code at least). It can’t jump to the definition of a method whose
name ending with a question mark! e.g. signed_in?. After a wandering
around the source code of Etags-Select, I decide to ‘fix’ it by
myself. And finally, I made it! Yeah!
It’s showtime ;)
Firstly, git clone my forked
Etags-Select version and add
it to your Emacs load-path, you may also need to install
;;; Installation of Etags-select
(add-to-list 'load-path "/path/to/my-etags-select")(require 'etags-select)
Secondly, add following snippets to your emacs dotfile.
Look at the bottom of the Emacs frame, there is a distinctive line above the minibuffer, it’s mode-line. This displays various information about what is going on in the buffer, such as whether there are unsaved changes, the editing modes that are in use, the current line number, and so forth.
After installed several add-ons, you may find that the mode-line occupied by the minor-mode indicators. As follow:
Not all of the indicators are useful for me, even more, they (but not the minor mode) pollute the mode-line, so I want to save the limited spaces.
First, you should add this function to your .emacs.
(defunhbin-remove-mm-lighter(mm)"Remove minor lighter from the mode line."(setcar(cdr(assqmmminor-mode-alist))nil))