Force absolute URLs for parts of a view or controller
You know that you can force absolute URLs throughout a response. Now you want to modify URLs similarly, but only in parts of a view (or controller) logic. Here is how.
Note: this has only been tested on a Rails 2 application. It should work similarly for Rails 3.
Put this into your ApplicationController
:
def rewrite_options(*args)
options = super
options.merge!(:only_path => false) if @with_full_urls
options
end...
FooLimitExceeded Quota problem with OpenStack
If you get a Quota error with OpenStack, it doesn't have to be what it tell.
For example, I've got this message because the RAM Quota was exceed:
2013-11-11 17:13:25 WARNING nova.compute.api [req-bdasdfas-f5d7-4fcd-bf1b-asdfasdf229e ba2c21dadasdfasdf1d6asdfasdfa0f bfe2db2aasdfasdfb8ea686asdfasdfb] Quota exceeded for bfe2db2aasdfasdfb8ea686asdfasdfb, tried to run 1 instances. Cannot run any more instances of this type.
2013-11-11 17:13:25 INFO nova.api.openstack.wsgi [req-bd003113-f5d7-4fcd-bf1b-asdfasdf229e ba2c21dadasdfasdf1d6asdf...
Syn - a Standalone Synthetic Event Library
Syn is a synthetic event library that pretty much handles typing, clicking, moving, and dragging exactly how a real user would perform those actions.
Float Label Pattern
A clever way to have inline labels ("placeholders") that don't disappear when the user enters text.
Monitoring a network connection from a remote host
Sometimes you need to monitor a connection from your machine to a specific, single host or network in order to identify which network hop between your machine and the target causes trouble. You can use the following shell script to easily achieve this kind of monitoring.
If the target host is unable to respond to the specified number of ICMP packets, you will get an eMail together with a mtr
to see on which hop the problem occurs.
#!/bin/bash
TARGET=8.8.8.8 # Target host or IP address to be monitored.
MAIL_RECIPIENT=you@exam...
GlyphSearch: search for icons from Font Awesome, Glyphicons, and Ionicons
A better way to search Font Awesome & Glyphicons.
Don't use PDFKit v0.5.4 – it breaks on dead urls
When I upgraded from 0.5.4 PDFKit deadlocked or crashed when an ApplicationController::RouteError occured. If this error happens only because of a broken image link you probably still wan't the page to render and get a PDF with a "missing image placeholder" instead.
I don't know yet in which version (0.5.2, 0.5.3 or 0.5.4) the bug was built in. At the moment I'm doing fine with 0.5.1 and I didn't evaluate any other versions yet.
I will update this card as soon as I know further information (State 4th Nov. 2013).
Fix „command failed: /usr/bin/wkhtmltopdf ...“ using PDFKit middleware
Ubuntu 12.04 LTS x64, Ruby 1.8.7, Rails 2.13, PDFKit 0.5.4, Phusion Passenger Apache 2
I ran into this, when I started using passenger to deal with the Single Thread Issue which caused my webrick to deadlock when an ActionController::RoutingError (No route matches "...")
occurred.
These steps brought me a little further
(1) assert dependencies are installed
sudo aptitude install openssl build-essential xorg libssl-dev
(2) only for 64bits OS Run one by one the follo...
How to set git user and email per directory
I am using git at several places: at work, at university, and at home. I want an own git user/email for each of those places, but I don't want to care setting the values each time I create or clone a new repository.
Git allows for setting user/email per repository, globally and system-wide, but I need a fourth dimension: per directory. By setting git environment variables using ondir
, I managed to get exactly what I need.
- Install
ondir
(on a Mac:brew install ondir
, other OSs need to install it from the linked page). - Put these ...
Mysql collate, searching case sensitive
Usually our mysql queries are not case sensitive. In order to query case sensitive, you can use the mysql COLLATE clause.
The collate clause lets you specify a collation, which basically is a set of rules for comparing characters in a given character set.
The suffixes ci, cs, bin of a collation stand for case insensitive, case sensitive and binary, respectively. A binary collation such as utf8_bin is case sensitive as well since it compares the characters based on their numeric values.
SELECT * FROM use...
Ruby: The & operator
After reading, you will know why and how runners.each(&:run)
works. Here some tidbits:
& can be quite confusing because it has a different meaning depending on the context in which it's used.
&object is evaluated in the following way:
- if object is a block, it converts the block into a simple proc.
- if object is a Proc, it converts the object into a block while preserving the lambda? status of the object.
- if object is not a Proc, it first calls #to_proc on the object and then converts it into a block.
Legacy docs for Font Awesome 3.2.1
Font Awesome 4 has renamed all icons. What the fuck.
Check the attached link for an icon list for the old Font Awesome 3.2.1.
Note
The following icons are listed on the linked page but may not exist in your vendored font:
icon-adn
icon-align
icon-ambulance
icon-anchor
icon-android
icon-angle
icon-apple
icon-archive
icon-arrow
icon-ban
icon-bar
icon-beer
icon-bitbucket
icon-btc
icon-bug
icon-building
icon-bullseye
icon-caret
icon-chevron
icon-circle
icon-cny
icon-code
icon-coffee
icon-col...
Texture Mixin for Sass
Awesome Sass plugin to experiment with Subtle Patterns based textures. It automatically removes the base color from the pattern, leaving a semi-transparent texture that you can tint in any color you want. It also has switches to invert the pattern.
@include texture(green, 34, 0); // color, texture-number, 0=inverted or 1=normal
If you have ever done this manually you know how much pain this can safe you. Check it out!
weighttp - a lightweight and simple webserver benchmarking tool
Weighttp is threaded and might exhaust resources of an application better than ApacheBench or httperf.
You need libev installed.
sudo apt-get install libev-dev
./waf configure
sudo ./waf install
The top responsive web design problems ... and how to avoid them
I recently created a survey asking fellow designers about the problems they faced when creating fully responsive sites. This article will list the most common problems they reported and offer possible solutions, along with suggestions to consider on your next projects.
HubSpot/mixen · GitHub
It's mixins (modules) for Coffeescript classes. Other than most homegrown approaches, this one allows you to keep using super
.
Carrierwave – Recreate versions
A snippet of the carrierwave documentation
You might come to a situation where you want to retroactively change a version or add a new one. You can use the recreate_versions! method to recreate the versions from the base file. This uses a naive approach which will re-upload and process the specified version or all versions, if none is passed as an argument.
Call recreate_versions!
on a mounted uploader.
A common usecase
User.all.each { |user| user.avatar.r...
Allow setting the #id attribute when creating an ActiveRecord
When creating an ActiveRecord with .new
, .create
or create!
, you cannot set the ID attribute (note: When using Machinist's .make
you can).
This is because even when you are not using attr_protected
or attr_accessible
, some attributes are always protected. These attributes are #id
and #type
.
If you want to allow setting #id
on .new
, .create
or create!
you can include the attached module in order to whitelist #id
on a model of your choice like this:
class MyModel <...
Installation of therubyracer fails with "undefined method `include_path'"
Today I ran into trouble installing therubyracer on Ruby 1.8. The installation failed with
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
...
What you need to know about Angular SEO
Search engines, such as Google and Bing are engineered to crawl static web pages, not javascript-heavy, client-side apps. This is typical of a search engine which does not render javascript when the search bot is crawling over web pages.
This is because our javascript-heavy apps need a javascript engine to run, like PhantomJS or v8, for instance. Web crawlers typically load a web page without using a javascript interpreter.
Are we out of luck for providing good SEO for our Angular apps? This article will show you exactly what you nee...
safe_cookies is now in public beta
We proudly release our safe_cookies middleware into public beta and just published it on Github.
Features are:
- make all application cookies
secure
andHttpOnly
(keeping them from being sent over HTTP and protecting them from Javascript) - rewrite all client cookies once, making them
secure
andHttpOnly
- notification if a request has unregistered cookies (no unsecure cookie will slip by)
- ability to ignore external cookies, like
__utma
and other tracking cookies - easy configurat...