Ubuntu comes with keyboard layouts like "Germany Eliminate Dead Keys", which are practical for programming.
If you need to type accented characters with such a layout, make sure to configure a Compose key. You can then look up which compose combo will produce the character you need.
E.g. you can type "á" by pressing Compose, ´, a
.
In Rails 2, you could use link_to_remote ... :update => 'id'
to automatically replace the content of $('#id')
.
To do the same in Rails 3, include usual rails-ujs JavaScript, and put this into your application.js
:
$(function() {
$('[data-remote][data-replace]')
.data('type', 'html')
.live('ajax:success', function(event, data) {
var $this = $(this);
$($this.data('replace')).html(data);
$this.trigger('ajax:replaced');...
If you use Selenium and Launchy to open web pages, you might run into an error saying "Your Firefox profile cannot be loaded. It may be missing or inaccessible.".
This happens because Launchy tries to use your Firefox running the web driver to open the page.
For Launchy < 0.4.x, as a workaround you can set an environment variable
export LAUNCHY_BROWSER=`which google-chrome`
For newer Launchys you also need to set:
export BROWSER=`which google-chrome`
If you want to do this in a ruby script, you can say
chrome_path ...
This finally works:
User.any_instance.should_receive(...)
as does
User.any_instance.stub(...)
Note: You won't have RSpec 2.6 if you're still working on Rails 2.
Free Hoptoad/Airbrake alternative which can capture exceptions from any platform. It comes with a Rails notifier and a RESTful API to write your own notifiers for Javascript, etc.
Should we some day wish to do away with the current way we deal with exceptions, this might be a good place to start.
Below you can find the hex color codes for the Color Graphics Adapter palette which used to be popular in the 1980s.
$cga_black: #000000
$cga_white: #ffffff
$cga_light_gray: #aaaaaa
$cga_dark_gray: #555555
$cga_yellow: #ffff55
$cga_brown: #aa5500
$cga_light_red: #ff5555
$cga_dark_red: #aa0000
$cga_light_green: #55ff55
$cga_dark_green: #00aa00
$cga_light_cyan: #55ffff
$cga_dark_cyan: #00aaaa
$cga_light_blue: #5555ff
$cga_dark_blue: ...
Note that this card is very old. You might want to use ActiveType for your auto-coerced virtual attributes instead.
We sometimes give our models virtual attributes for values that don't need to be stored permanently.
When such a virtual attribute should contain Date
values you might get unexpected behavior with forms, because every param is a string and you don't get the magic type casting that ...
When have you last used your caps lock key? On purpose? Right...
Make it an additional ESC key by going to System -> Preference -> Keyboard -> Layouts -> Options -> CapsLock key behavior and select "Make CapsLock an additional ESC".
On recent Ubuntus this option was removed so you have to resort to using dconf.
dconf write /org/gnome/desktop/input-sources/xkb-options "['caps:escape']"
Or, open Tweak advanced GNOME 3 settings
and ...
You cannot say this because url_for
only takes one parameter:
url_for(@deal, :tab => 'general') # won't work
Just use polymorphic_url
instead:
polymorphic_url(@deal, :tab => 'general')
Leads to awesomeness and unicorns when used in production.
In order to use different encodings than ASCII for HTTP headers use the following syntax:
Header-Key: Header-Value; Parameter-Name*=utf-8''parameter_value_in_utf8_and_encoded_chars
Concrete example how to use an utf8 encoded filename for file downloads (with fallback):
Content-Disposition: attachment; filename="aepfel"; filename*=utf-8''%c3%a4pfel
We usually generate our commit messages from Pivotal Tracker IDs and titles, like
[#15775609] Index view for conflicts
The geordi command commit
automates this. (See: Pretty Commit messages via geordi).
Just run geordi commit
and it will connect to PT and let you select from a list of all started and finishes stories. Then it runs git commit
with the generated message (i.e. all staged changes will be commited).
When running for the first time, Geordi will request your PT...
API breakage ahoy. You need to either upgrade your Capybara or downgrade your selenium-webdriver
gem.
Alternatively, this could solve your trouble.
Just in case you did not know it: If you sent a Skype message containing a typo, you don't need to send a second one to correct yourself.
Instead, simply press the up key (↑
). The message area will become yellow and contain your previously sent message. Make any changes and submit again.\
You can also right-click any other message (of the current session) to edit it.
Sometimes you need a file of some size (possibly for testing purposes). On Linux, you can use dd
to create one.
Let's say you want a 23 MB file called test.file
. You would then run this:
dd if=/dev/zero of=test.file bs=1048576 count=23
The block size (bs
) is set to 1 MB (1024^2 bytes) here, writing 23 such chunks makes the file 23 MB big.\
Adjust to your needs.
This linux command might also come in handy in a Ruby program. It could be used like:
mb = 23
mb_string, _error_str, _status = Open3.capture3('dd if=/dev/zero...
Note: Consider using MATE instead of Gnome 3 on newer system
Awesome is a very good tiling window manager that provides neat features like automatic layouting of windows, good multi-display support with per display workspaces and more. Unfortunately, it is only a window manager, and lacks a lot of Gnome's conveniences like the network manager, application menus, automatic updates etc.
Fortunately, Gnome allows you to selectively replace only the window manager, so you get all of Gnome'...
We are changing our name from Hoptoad to Airbrake. You see, some folks much larger than us reached out and claimed trademark over all things related to frogs and toads and little animals of that ilk. After speaking to our lawyers we reluctanctly decided it’s best to change the name.
VirtualBox does not offer anything for this task -- you need to do it yourself. It's not that hard:
fdisk
, dd
and gParted
.sudo su
fdisk -l
to see the disk information. \When you do a bitwise copy using the dd
tool you will not see any output until it completes or an error occurs.
However, you can send a command signal to the process to have it show its progress so far.
From another terminal, simply call (be root or use sudo
):
pkill -USR1 dd
This makes dd
write something like this into the terminal it is running in:
388+0 records in
387+0 records out
396288000 bytes (396 MB) copied, 24.9862s, 15.9 MB/s
Every time you open a directory containing images, Windows creates those pesky Thumbs.db
files for a minor speed-up and lots of cluttering your zip files etc.
You do want to disable them. Here is how on Windows 7:
With gem dependency
it is possible to check the dependencies for your gem before you install it.
Here is an example output for Nokogiri:
Gem nokogiri-1.4.4
hoe (>= 2.6.2, development)
minitest (>= 1.6.0, development)
racc (>= 0, development)
rake-compiler (>= 0, development)
rexical (>= 0, development)
rubyforge (>= 2.0.4, development)
Regular expressions can have something called "zero-width look-behind assertions". This means that you want a pattern to be preceded by another pattern, but not include the preceding pattern in your match or search cursor. E.g. (?<=x)y
matches y
in xyz
but not in syz
. There are also negative look-behind assertions, e.g. (?<!x)y
matches y
in syz
but not in xyz
.
Unfortunately look-behind assertions are only available in Ruby 1.9. With Ruby 1.8 you need to use an alternative regular expression library called [Oniguruma](http://...
When you double-tap a string of text on an iPhone or iPad a complicated context menu for copying and pasting will appear. This can confuse unexperienced users.
Use the Javascript hack below to disable text selection on mobile devices:
// Deactivating distracting Text Selection:
// from: http://stackoverflow.com/questions/1794220/how-to-disable-mobilesafari-auto-selection
$.fn.extend({
disableSelection : function() {
this.each(function() {
this.onselectstart = function() {
return false;
...