Ansible uses YAML to define tasks, playbooks and handlers. If the files follow some conventions, it is easy to index them using Exuberant Ctags.
It is a headache to find an available keyboard shortcuts in Mac OS X. I used Option + Letter and Shift + Option + Letter before, since they are preserved for inputting special characters. It has some problems:
- Emacs and terminal require a modifier for Meta. I choosed Command. It means if I want to use application shortcut with Command in these applications, such as Command+Q to quit the application, I have to use the right one.
- I always forget the shortcuts. Although I have listed them in a sheet, it is a pain to keep it synchronized with the shortcuts defined every where.
I switched to a new solution using keystroke sequence shortcuts recently. All my global shortcuts start with Command+M (⌘M). A menu is displayed when I typed prefix. If I forget the shortcut, I just need to glance through the menu.
I prefer using external keyboard with my MacBook. When no external monitors are used, a typical setup is placing the keyboard above the internal one, so I can still use the internal touchpad.
But sometimes the external keyboard may press some keys of the internal keyboard. There is a solution to disable the internal keyboard, but it is tedious to run the command manually.
# Disable, ignore the warning sudo kextunload /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext/ # Enable sudo kextload /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext/
Fortunately, Keyboard Maestro supports executing scripts when a USB device is attached or detached.
Allows preloading of args, in the same way that includes does.
Indeed the two methods have some differences.
In simple words, prefer
includes to eager load associations. Use
- you want to customize
- you meet error “Can not eagerly load the polymorphic association”.
ActiveRecord has two methods to remove duplicates. Method
uniq and option
distinct: true in method
count. I thought
count(distinct: true) were identical. Indeed,
uniq.count still counts
count(distinct: true) must be used here.
In simple words, use
uniq to get unique result set, use
count(distinct: true) to count unique result.
SVG can use percentage as unit, but it is often more convenient to use px as
unit. Framework such as d3 also uses px internally. However, it is still easy
to scale an SVG using attributes
preserveAspectRatio even px
is used as unit internally.
This is original posted on intridea blog.
I recently worked in a Rails project with Peter (@sporkd). The
project is intended to be used as a sub-site, and should be served under
sub-URI. After google, we ended up by setting
wrapped all routes in
scope. The solution is simple and worked well. But
soon, some weird bugs were found, and Peter was successfully isolated the
problem to session (see demo
After several hours debugging, I finally found out the cause. To make a long
story short, the routes configured in
routes.rb should not start with
config.assets.prefix, otherwise session save is skipped. The demo
sporkd/asset_prefix_test can be fixed by simply setting
/one/assets. You also get a bonus by setting a
unique prefix for assets, since it is easy to add expiration header for assets
in web server.
# ^Xa to insert all matches zle -C all-matches complete-word _generic bindkey '^Xa' all-matches zstyle ':completion:all-matches:*' old-matches only zstyle ':completion:all-matches::::' completer _all_matches
UPDATE: The snippet above brings
insert-completionsto zsh. Thanks, Trevor Joynson, who has provided the solution in comment.
insert-completions (see man bash) is the
feature I most miss in bash.
[insert-completions] Insert all completions of the text before point that would have been generated by possible-completions.
Its default binding is M-*, a.k.a, Alt-Shift-8 or Meta-Shift-8.
It is useful for simple batch operations, such as removing all git branches
After I switched to zsh, I have been looking for a similar command, but for
no results. However, I just discovered the zsh way to select multiple
completions recently, using
[accept-and-hold] Push the contents of the buffer on the buffer stack and execute it.
The default binding is M-a (a.k.a, Alt-a or
Meta-a). If the command line has input content
executes the line
ls without clearing the input.
It seems unrelated. But if completion menu is activated and a menu item is
selected (the simplest way is Tab twice),
the current menu item without closing completing menu. So it is possible to
select multiple items by navigating to wanted items, and type M-a
to select them.
It is very easy to integrate Jasmine into Rails, since the team provides the
jasmine gem. The jasmine gem also supports assets pipeline, just prepend
assets/ to file path. For example,
spec_files does not support assets pipeline, so the files in
src_files in jasmine.yml.
I also created a demo repository, see its commits for integration steps.
assign_multiparameter_attributes trick like
fields_for mocks an association.
The github repository doitian/rails-compound-input-demo contains demos for both methods.