ActiveRecord has two methods to remove duplicates. Method uniq and option distinct: true in method count. I thought uniq.count and count(distinct: true) were identical. Indeed, uniq.count still counts duplicates, and 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.
A collection of 45 articles
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 viewBox and 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 config.assets.prefix and 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 sporkd/asset_prefix_test) 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 config.assets.prefix to /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.
I like the feature to Insert all completions in bash, and I can get this feature in zsh now
There are two TAB’s in Emacs, (kbd "TAB") (\t, ) and (kbd "<tab>") ([tab]). If modes like yasnippet and auto-complete want to bind on TAB, their trigger key must be the same with the original Tab command.
Yasnippet tries functions in yas/prompt-functions when it needs user to select one choice, such as selecting snippets with the same trigger key, such as helper method yas/choose-value. popup is a visual popup interface library extracted from auto-complete by its author. It has better look and feel than all the built-in yas/prompt-functions. Also it is easy to customize, and its isearch mode is very efficient, the items are filtered on-the-fly when typing.
Many editor can wrap a line that reaches the window width and show an indicator in the margin, for example, Emacs. Emacs line wrap with bent arrow in fringe I want to add such line wrap indicators to the code block in HTML. It is easy to add indicators as background image in CSS. But the indicators should only be shown when the line is wrapped. And from the figure, the wrap indicator is not displayed on the last line in the right margin, and not on the first line in the left margin. There’s a :first-line pseudo element selector, there’s no :last-line. However, it can be achieved by using :before and :after with position trick. You can check the result in this jsfiddle. Resize the result panel to see the line wrap indicators. Following is a detailed explanation.
Not fully tested, let me know if it mess up your buffer. ※ my-ruby-mode.el (font-lock-add-keywords 'ruby-mode '(("\\(\\b\\sw[_a-zA-Z0-9]*:\\)\\(?:\\s-\\|$\\)" (1 font-lock-constant-face))))