List of cloud services and SaaS with a free tier for developers or that are generally free for open source software.
Fontawesome 4 ships with many useful CSS helper classes.
Add fa-lg
(133%), fa-2x
, fa-3x
, fa-4x
or fa-5x
.
Add fa-fw
. Will give all icons the same width.
Add fa-ul
to a <UL>
and fa fa-<icon name> fa-li
to a <LI>
to give the list items custom "bullets".
Add fa-border
to get a border around the icon.
Add fa-spin
to make any icon rotate. Suggested icons: fa-spinner
, fa-refresh
, fa-cog
. Doesn't work in IE <10.
Fontawesome 4 has introduced new naming conventions that make it easy to retrieve variants of a given icon.
The format is:
fa-[name]-[alt]-[shape]-[o]-[direction]
Note that this is a naming convention which doesn't imply there's an icon for any combination of tags.
The name of the icon, e.g. comment
, print
, bookmark
etc. See the full list.
An alternative icon.
The icon inside a circle
or square
.
An outlined ...
There are some frontends available, but they all suck, are no longer maintained or are hard to install.
As a surprisingly comfortable alternative I have found a command line tool s3cmd
:
sudo apt-get install s3cmd
When you run s3cmd
the first time it will ask you for your access key ID and secret access key. This information is cached somewhere so you only need to write them once. To reconfigure later, call s3cmd --configure
.
Once you're done setting up, s3cmd
gives you shell-like commands like s3cmd ls
or `s3cmd del som...
state_machine
, which has some issues with Rails 4 and isn't actively maintainedAwesome hack by Tim VanFosson:
<img src="some.jpg" onerror="this.src='alternative.jpg'" />
Instead of this:
Image.order('images.created_at DESC')
You can write this:
Image.order(created_at: :desc)
Not only do you not have to write SQL, you also get qualified column names (created_at
becomes images.created_at
) for free.
To add secondary order criteria, use a hash with multiple keys and :asc
/ :desc
values:
Image.order(title: :asc, created_at: :desc)
It's generally not trivial to change a datetime's seconds, minutes, etc in SQL. Here is how it works when speaking PostgreSQL.
Consider you have a timestamp column whose seconds you want to zero:
SELECT born_at FROM users;
born_at
---------------------
2015-05-01 13:37:42
You can the TO_CHAR
function to convert date or time values into a string, and do your changes there:
SELECT TO_CHAR(born_at, 'YYYY-MM-DD HH24:MI:00') FROM users;
to_char
---------------------
2015-05-01 13:37:00
...
Today I learned that Ruby on Rails has shipped with a built-in slug generator since Rails 2.2:
> "What Up Dog".parameterize
=> "what-up-dog"
> "foo/bar".parameterize
=> "foo-bar"
> "äöüß".parameterize
=> "aouss"
Also see: Normalize characters in Ruby.
Clever hack using data-
attributes to assign labels to cells.
It's still a massive duplication of code (labels), but better and more lightweight than most solutions I've seen for this surprisingly tricky problem.
If you need to log to a file you can use Ruby's Logger
class:
require 'logger'
log = Logger.new('log/mylog.log')
log.info 'Some information'
log.debug 'Debugging hints'
log.error StandardError.new('Something went wrong')
Logger
does a number of things well:
If you don't like the output format, you can define a custom formatter.
I ha...
Dusen (our search gem) is now capable of excluding words, phrases and qualified fields from search.
E.g. search for
included -excluded
"search this" -"not that"
topic:"Yes" -topic:"No"
This will soon also work in makandra cards!
If you are using Coffeescript, it is likely to be the culprit. Since Coffeescript always returns the value of the last expression, it may return DOM nodes:
# coffeescript
scope.focus = ->
element.focus()
# javascript
scope.focus = function() {
return element.focus(); // wheee
}
If you e.g. use this function like this, the error will be raised:
<span ng-click="focus()">...</span>
By adding an explicit return value (e.g. return false
), you can Coffees...
If you want to rotate text, you can use CSS transforms in somewhat modern browsers to rotate the container element.
However, if you need to support IE8, transform
is unavailable (if need only IE9 support, ignore the following and use -ms-transform
).
Here is a solution that worked for me:
<div class="my-element">Hi!</div>
^
.my-element {
display: inline-block;
transform: rotate(90deg);
-ms-writing-mode: tb-rl;
-ms-transform: none;
}
This way, browsers will use CSS transforms when available -- w...
What if a complicated component comes along that is naturally modeled by multiple directives? This group of directives, as a whole, form a single self contained component. None of directives in the group can stand alone because they only make sense when used together; they collaborate; they are aware of each other and need to communicate with each other.
This post will discuss best practices for managing communication among collaborating directives and illustrate these practices with an example.
This is useful to kill processes like ruby my-script.rb
:
pkill -f my-script.rb
With great power comes great responsibility.
Check your GPU state on chrome://gpu. If it reads "WebGL: Hardware accelerated" in the first list, you're set. Else:
TL;DR You shouldn't call $scope.$apply()
or $scope.$digest()
inside a function that can be invoked by Angular – e.g. in an ngClick
.
The linked Stackoverflow answer has a quick overview of techniques to apply changes to a scope. It also explains what might be wrong when you're getting the error $digest already in progress
and gives some information that every Angular developer should know.
Opinionated Angular style guide for teams by @john_papa
Not everything in this guide works perfectly for us, but is still a good start.
You can hook into Slack when using Capistrano for deployment. The slackistrano gem does most of the heavy lifting for you. Its default messages are unobtrusive and can be adjusted easily.
When deploying, it posts to a Slack channel like this:
Integrating Slackistrano with Capistrano 3 is fairly simple.
Often times you want to give a bunch of elements the same style, except for the last. For example borders or margins.
You probably commonly used the :last-child
CSS meta selector like so:
.foo {
border-bottom: 1px dashed #000;
}
.foo:last-child {
border-bottom-width: 0;
}
However, this only works when an element is the last child of its parent. Any other siblings which are unrelated to your case will break it.
Instead, prefer using the +
sibling selector. It applies to the element following the other.
.foo + .foo {
...
See this Railscast.
Basically you can simply write views like index.xlsx.erb
:
<?xml version="1.0"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<Worksheet ss:Name="Sheet1">
<Table>
<Row>
<Cell><Data ss:Type="String">ID</Data></Ce...
Write a //
and indent every subsequent line by two spaces.
This is great for documenting BEM blocks!
//
An action button
================
Basic usage
-----------
<a href="/path" class="action">New booking</a>
<button class="action">Save</a>
<input type="submit" class="action">Save</a>
Colors
-------
<a href="/path" class="action is-red">Primary</a>
<a href="/path" class="action is-grey">Secondary</a>
Small inline buttons
--------------------
<p>
Recor...
When you want to look up a class for a given factory, do it like this:
>> FactoryBot.factories.find('admin').build_class
=> User
In older versions, you could do:
>> FactoryBot.factory_by_name('admin').build_class
=> User