Hex color codes for the CGA palette
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: ...
Virtual attributes for date fields
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 ...
How to remap your caps lock to a second Escape key
When have you last used your caps lock key? On purpose? Right...
In Gnome
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 ...
url_for with added params
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')
Rails 3 issue: update_all ignores conditions, when :orders and :limit options are supplied
Leads to awesomeness and unicorns when used in production.
How to use different encodings for text in HTTP headers
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
Shell script to generate a Git commit with Pivotal Tracker story ID and title
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...
Fix "private method `select' called for Capybara::Node::Element
API breakage ahoy. You need to either upgrade your Capybara or downgrade your selenium-webdriver
gem.
Alternatively, this could solve your trouble.
Edit your previous Skype messages
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.
Linux: Create file of a given size
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...
Dotfiles: Keep your linux configuration on github
Running the Awesome window manager within Gnome
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 win...
Hoptoad is now Airbrake
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.
How to enlarge a VirtualBox VDI disk file
VirtualBox does not offer anything for this task -- you need to do it yourself. It's not that hard:
Get more disk space
- Add an extra virtual hard disk to the machine with the disk size you want to achieve.
- Get a Linux live CD (like the Ubuntu live image) that offers
fdisk
,dd
andgParted
. - Boot the guest from the CD, open a terminal (on the guest, not the host!) and become root:
sudo su
-
fdisk -l
to see the disk information. \
There should be one drive with some partitions and one without any....
Show the status of a running dd copy
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
You may also pass the status=progress
option to dd
like so:
dd if=... o...
Disable Thumbs.db on Windows 7
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:
- Start → Run (or press Meta+R)
- gpedit.msc
- User Configuration → Administrative Templates → Windows Components → Windows Explorer
- Locate "Turn off the caching of thumbnails in hidden thumbs.db files" (should be one of the top list entries)
- Set it to "Enabled". Yes, seriously -- you enable the disabling of thumbs.d...
Check gem dependencies before installation
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)
Use look-behind assertions in regular expressions with Ruby 1.8
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://...
Disable text selection on iOS and Android devices
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;
...
Get syntax highlighting for puppet files (.pp) in vi
First option is to install it with your package manager:
apt-get install vim-puppet
vim-addons install puppet
If you don't want to install the dependencies download this puppet_syntax.zip and move the content into ~/.vim/
.
Installing Rails on a fresh system
- Install Ruby from the Ubuntu repository:
sudo apt-get install ruby ruby-dev
\
ruby
is the meta package. If you want to explicitly install 1.8 or 1.9, installruby1.8
orruby1.9
instead (the same applies forruby-dev
). - Do not install RubyGems from the repository but install the version from the webpage instead.
- Get Bundler:
sudo gem install bundler
Rails and other gems for a project should now be installed via bundle install
from the...
CPU limit
cpulimit is a simple program which attempts to limit the cpu usage of a process (expressed in percentage, not in cpu time). This is useful to control batch jobs, when you don't want them to eat too much cpu. It does not act on the nice value or other scheduling priority stuff, but on the real cpu usage. Also, it is able to adapt itself to the overall system load, dynamically and quickly.
Disable Dell U2410 beeping sound
The first thing to do with any new U2410 should be to disable the incredibly annoying beep when pressing any monitor button. Here is the fastest way to achieve that:
- OSD button (above the power button)
- Menu
- 2 × Up (You should be at “Other Settings” now)
- Right
- 4 × Up (“Button Sound”; the “Power Save Audio” entry is usually grayed out, so this is 1 beep less than from above.)
- Right
- Down
- Tick
Do it this way or your colleagues will stand at your desk after the 12th beep, ready to smack you.
Fix slow specs using SOLR
I've recently encountered a weird problem with specs making lots of SOLR queries using the acts_as_solr
plugin: After a certain number of specs, exactly one spec suddenly took over 30 seconds to finish.
It turns out that for some reason, the SOLR server seemed not to close its HTTP connections properly. After the maximum number of connections was reached, the next spec needed to wait for an old connection to time out.
I'm not exactly sure why this happened, why it only seems to be happening in specs and which part of the code is actually...