Customize and download · Bootstrap
List of variables used in Bootstrap. Overwrite to customize your bootstrap application.
When you are using bootstrap-sass
, simply replace @
by $
.
AngularJS directive to format a text with paragraphs and new lines
If you are using Angular and want something like Rails' simple_format
which HTML-formats a plain-text input into paragraphs and line breaks, this directive is for you.
Any HTML fragments inside that text will still be escaped properly.
Use it like this, where your text
attribute specifies something available in your current scope:
<simple-format text="email.message"></simple-format>
This is the directive, in CoffeeScript syntax:
@app.directive 'simpleFor...
assignable_values 0.9.0 supports virtual attributes
Now you can say:
class Song < ActiveRecord::Base
attr_accessor :virtual_attribute
assignable_values_for :virtual_attribute do
%w[air fluff]
end
end
Linux: How to print PDF files from the command line
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/...
Ruby: How to camelize a string with a lower-case first letter
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"
Listening to bubbling events in Prototype is easy
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...
Test whether Perfect Forward Secrecy (PFS) is enabled on a server (using OpenSSL)
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
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.
No more file type confusion in TextMate2
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!
Solution
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...
What's new in edge Rails: Active Record enums
Declare an enum attribute where the values map to integers in the database, but can be queried by name.
The MariaDB Foundation Announces General Availability of MariaDB 10
MariaDB 10 includes numerous innovations developed with and for web-scale players like Google, Fusion-IO and Taobao such as Replication, NoSQL Capabilities, Sharding.
Why Ruby Class Methods Resist Refactoring
In a nutshell:
- Splitting a long method into sub methods is easier in instances since it is in classes. Since you must not save state in a class, you need to pass around context as a long chain of parameters again and again.
- If your public API has a single entry point, you can still have a class-level method that takes care of constructing the instance etc. So it's all win.
Obfuscating data in Rails applications for screenshots and demonstrations
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!
IE10 / IE11 Metro mode: How to switch tabs or show the address bar
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
Thread Safety With Ruby — Luca Guidi
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.
CSS: Vertically center with margin: auto
Check out the jsFiddle Demo.
CSS
.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%;
}...
Why your previous developer was terrible
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...
BrowserStack has browser plugins for local testing
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
How to remove/disable the automatic XSS protection helper html escaping for Rails 3.
This is probably a horrible idea.