How to find out Your Ubuntu / Debian Linux is 32 bit or 64 bit
uname -m
i686
means 32-bit.
Fix error: can’t find executable rails
If you get an error like this ...
can’t find executable rails for rails-3.2.3 (Gem::Exception)
... one of several things might be wrong.
- You're using RVM
It's possible that you have a system-wide gem executable (like rails
) that requires a gem that is not available in the current RVM Ruby or gemset. Check what Ruby you are using (rvm current
) and look out for .rvmrc
files in your current directory (which change your Ruby upon entering the directory).
- You killed a gem install process
----------...
Three quick Rails console tips
How to call routes, make requests and try out helpers from the Rails console.
OCRA
OCRA (One-Click Ruby Application) builds Windows executables from Ruby source code. The executable is a self-extracting, self-running executable that contains the Ruby interpreter, your source code and any additionally needed ruby libraries or DLL.
ocra [option] script.rb
Will package “script.rb“, the Ruby interpreter and all dependencies (gems and DLLs) into an executable named “script.exe“.
How to fix: RubyMine does not remember last used monitor (on Ubuntu)
Every time I started RubyMine, it opened the main window on the left monitor -- when moving it to the center monitor and closing it, the next time it still opened up on the left one.
Here is how I forced RubyMine to start up on a different screen:
- Un-maximize the main window
- Move it to your preferred monitor
- Close RubyMine (keep it unmaximized)
- Start RubyMine again.
- You may now maximize your main window; the next time you start up RubyMine, it will open on the correct screen, maximized.
That's crazy!
salesking/king_dtaus
DTAUS & DTAZV are formats for German bank transfers and is short for "Datenträgeraustausch". The format itself totally sucks because it was established in the last century, to be used on floppy disks. Still almost all German banks use it (they only seem innovative at robbing), and it is therefore supported in common banking programs too.
This gem saves you all the trouble when generating DTAUS- or DTAZV-text.
rspec_candy is now a gem
Our awesome collection of rspec helpers (formerly known as "spec_candy.rb") is now available as a gem. It works, it is tested and there will be updates.
Usage
Add rspec_candy
to your Gemfile.
Add require 'rspec_candy/helpers'
to your spec_helper.rb, after the rspec requires.
List of features
IE9: Linear gradients remove border-radius and inset box-shadows
When you add a linear gradient to an element, IE9 removes all border-radius
and inset box-shadows
. This is because you probably are doing linear gradients with this weirdo Microsoft filter:
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0A284B', endColorstr='#135887');
filter
hijacks the rendering of the entire element box, so you're out of luck. IE9 doesn't support CSS gradients.
A forward-looking workaround is to not use gradients and [emulate your gradients with box-shadows](https://makandracards.com/m...
You cannot use :before or :after on img in CSS
Though the W3C even gives it as an example, no browser actually supports this CSS:
img:before {
content: "something";
}
Browsers will simply not render anything when doing that on images (Fun fact: It worked in an older version of Opera but got dropped).\
The same applies to the :after
pseudo-element.
This makes me sad.
You can try using jQuery instead.
Use a special version of Chrome for selenium (and another for your everyday work)
Sometimes you need a special version of chrome because it has some features you need for testing, like in this card. You do not need to use that Version apart from tests, because you can tweek selenium to use a special version that you set in your environment:
# features/support/chrome.rb
require "selenium/webdriver"
Capybara.register_driver :chrome320x480 do |app|
if driver_path = ENV["CHROME_SELENIUM_BIN...
Set the accept-language of Chrome in selenium tests
You can set the resolution and user agent used in selenium tests with chrome with the method described in this card, but you can also set the accept-language and other profile settings if you do this:
# features/support/chrome.rb
require "selenium/webdriver"
Capybara.register_driver :chrome320x480 do |app|
args = []
args << "--window-...
jQuery File Upload
File upload with nice UI, progress bar and preview, allowing multiple files and supports drag & drop.
Its default is built on Bootstrap, but there's a version for jQuery-UI.
When I give a button and a link the same styles, why is the link one pixel higher?
It's not logical, so don't be too hard on yourself. You need to give it a height and change the box-sizing
and display
:
button
input[type="reset"],
input[type="button"],
input[type="submit"],
input[type="file"] > input[type="button"]
display: inline-block
box-sizing: border-box
height: 20px
line-height: 20px
Run Chrome in a specific resolution or user agent with Selenium
When you want to test how an web-application reacts in a specific resolution, you can set up a specific Selenium driver for some tests:
Before('@chrome320x480') do
Capybara.current_driver = :chrome320x480
end
After('@chrome320x480') do
Capybara.use_default_driver
end
You can use either chromium or chrome beta (as of 2012.05 the Version "19.0.1084.41 beta" works), or any other member of the family. It only needs to supports the "--window-size" command-line switch. [See this list](http://peter.sh...
Manipulating the browser history - MDN
The DOM window object provides access to the browser's history through the history object. It exposes useful methods and properties that let you move back and forth through the user's history, as well as -- starting with HTML5 -- manipulate the contents of the history stack.
Fix error when embedding Bing maps
If you get this:
p_elSource.attachEvent is not a function
... you need to disable Firebug or switch to another browser.
Open Helvetica alternatives
The closest is probably Nimbus Sans L, which is released under the GPL, AFPL, LPPL licenses. However, I couldn't find a way to convert Nimbus Sans L into a web font.
I finally settled with Liberation Sans, which is awesome for some reasons:
- Although it's available for free, it's a high quality font because its creation was thankfully sponsored ...
Convert a TrueType (.ttf) font to web font formats
- Note that you are not allowed to embed any font in a website. You need to check the license first. Fonts from Font Squirrel are all okay to embed and use for commercial purposes, but as with many free fonts, quality differs widely, especially at medium and small font sizes.
- You will need to embed your font in several formats since browser support is a mess.
- You can use the [Font Squirrel @font-face generator](http://www.fontsquirrel.c...
Navigating through the browser history in a cucumber feature using selenium
In order to navigate through the browser history. you can manipulate the window.history object via javascript like follows:
When /^I go back in the browser history$/ do
page.evaluate_script('window.history.back()')
end
For further functions of the window and history objects check out this link.
An improved version of this step is now part of our gem spreewald on Github.
Creating a multi-resolution favicon including transparency with the GIMP
The result is a .ico file with multiple versions of your logo at different resolutions. Now, depending on the context, visitors to your site will see your nice favicon in their browser tabs, superimposed on whatever browser chrome they're using in all of its transparent glory.
How to access a dmcrypt-encrypted partition from outside your system
This is for you when you want to mount a dmcrypt
encrypted partition manually, e.g. from a live CD.
First, open the dmcrypted partition (You need to provide some name. It may, but does not need to, be your LVM group name):
cryptsetup luksOpen /dev/sda5 some_name
Since your encryption container most likely contains an LVM group (root + swap for example), enable the logical volume manager (replace LVM_NAME
with your volume group's name):
vgchange -ay LVM_NAME
After that, you can your access (mount, [fsck](https://makandrac...
How to check your file system's integrity with fsck
To force a check on your next reboot (here for your root partition), simply:
touch /forcefsck
To manually do this, here is how to do it for the first partition on sda
, when you are using ext4:
fsck.ext4 -fn /dev/sda1
-
-f
forces the check, even if everything seems okay. -
-n
is a "read only" check, where nothing is changed and every question is answered with "no". - When using dmcrypt, you probably want to check s...
Type text into Javascript prompt dialogs in Capybara/Selenium
Spreewald gives you steps like these:
When I enter "text" into the browser dialog
Also see Accept or deny JavaScript confirmation dialogs in Capybara/Selenium.
Browser support for box-shadow
Basic box shadow support is available in all browsers today, but you need to check to which extend they are supported. Implementations differ:
- Are multiple box shadows (separated by comma) possible?
- Are inset shadows possible?
- Can the spread radius be defined?
- Can you use it without vendor prefix?
A good compatibility chart can be found here. The gist is that, except for IE and some Safaris, you can use all features ...