Sometimes you may want to print files from the command line, especially when you have lots of them.
You can use lp
for that.
To print a single example.pdf
file on your default printer, simply say:
lp example.pdf
lp
accepts multiple filenames, so to print all PDF files in the current directory:
lp *.pdf
You can specify a printer via the -d
switch:
lp -d YOUR_PRINTER_NAME *.pdf
Your printer's name is then one you defined on your system. You can check with your CUPS configuration by visiting <http://localhost:631/...
If you want to do JavaScript-style camelization, ActiveSupport's String#camelize
method can actually help you out. Simply pass a :lower
argument to it.
>> 'foo_bar_baz'.camelize
=> "FooBarBaz"
>> 'foo_bar_baz'.camelize(:lower)
=> "fooBarBaz"
If you come across an (older) application that is using Prototype instead of jQuery, you may often see events bound to single elements only, like this:
$('foo').observe('change', updateThings);
$('bar').observe('change', updateThings);
$('baz').observe('change', updateThings);
If you are calling only one method in each case, this is unnecessarily ugly. Also, when your page contents have been replaced via AJAX (like sections of a form after choosing something), those event hooks will no longer wo...
Use the following command to test if a server (in this example: makandra.com on port 443) uses Perfect Forward Secrecy (PFS):
openssl s_client -connect makandra.com:443 -cipher ECDHE-RSA-RC4-SHA
You should see something like the following:
~ > openssl s_client -connect projecthero.com:443 -cipher ECDHE-RSA-RC4-SHA
CONNECTED(00000003)
depth=1 O = AlphaSSL, CN = AlphaSSL CA - G2
verify error:num=20:unable to get local issuer certificate
verify return:0
---
Certificate chain
0 s:/C=DE/OU=Domain Control Va...
The Heartbleed Bug is a serious vulnerability in the popular OpenSSL cryptographic software library. This weakness allows stealing the information protected, under normal conditions, by the SSL/TLS encryption used to secure the Internet.
When using TextMate2 with the cucumber bundle, it does not recognize step definitions (e.g. custom_steps.rb
) as such but believes they are plain Ruby files. But there is help!
Add these lines to the bottom of your .tm_properties
file (in ~/
for global settings, in any directory for per-project settings):
[ "*_steps.rb" ]
fileType = "source.ruby.rspec.cucumber.steps"
Apparently, this works for any files. Define a regex and specify custom settings. The attached article lists all available configuration options (whic...
Declare an enum attribute where the values map to integers in the database, but can be queried by name.
MariaDB 10 includes numerous innovations developed with and for web-scale players like Google, Fusion-IO and Taobao such as Replication, NoSQL Capabilities, Sharding.
In a nutshell:
I recently had a need to demonstrate a data-heavy application to potential customers. Demonstrating the application with bogus numbers is one thing, but everything looks much more realistic when I’m using real data. I can’t reveal any real information, though, so I needed a quick way to obfuscate real names. Faker to the rescue!
Internet Explorer on Windows 8 and 8.1 is available in a "Desktop version" and the metro version which is designed for touch devices. \
When using IE Metro with a mouse (e.g. via BrowserStack), controls such as the tab bar or address bar will disappear after a little while.
To show them again, right-click anywhere in the page (except on links, etc).
O_o
Ruby’s model for concurrency is based on threads. It was typical approach for object oriented languages, designed in the 90s. A thread is sequence of instructions that can be scheduled and executed in the context of a process. Several threads can be running at the same time.
Ruby’s VM process allocates a memory heap, which is shared and writable by threads. If incorrectly coordinated, those threads can lead to unexpected behaviors.
Check out the jsFiddle Demo.
.absoluteCenterWrapper {
position: relative; /* Declare this element as the anchor point for centering */
}
/* Positioning */
.absoluteCenter {
margin: auto; /* Required */
position: absolute; /* Required */
top: 0; bottom: 0; /* Aligns Vertically */
left: 0; right: 0; /* Aligns Horizontally */
}
/* Make sure the centered element fits into its container. If you know that's the case, you can omit this part. */
.absoluteCenter {
max-height: 100%;
max-width: 100%;
}...
When you, as a developer, look at the choices used to build a particular application, you’re blown away at the poor decisions made at every turn. “Why, oh why, is this built with Rails when Node.js would be so much better?” or “how could the previous developer not have forseen that the database would need referential integrity when they chose MongoDB?” But what you may not realize is that you are seeing the application as it exists today. When the previous developer (or team) had to develop it, they had to deal with a LOT of unknowns. They...
Local testing allows you to test your private and internal servers using the BrowserStack cloud, which has support for firewalls, proxies and Active Directory.
How to remove/disable the automatic XSS protection helper html escaping for Rails 3.
This is probably a horrible idea.
On Ubuntu, you can scroll horizontally with your mouse wheel when holding the Shift key while scrolling.
It does not work in all applications, but many support it.
Alternatives to drop-down menus to consider in form design.
If you need to quickly find out the number of weekdays (Monday to Friday) between to given dates, try this:
require 'date'
a = Date.parse "11.04.2014"
b = Date.parse "31.12.2014"
(a..b).count {|date| (1..5).include?(date.wday) }