Spreewald 0.8.0 brings a file attachment step
# Attach a file
#
# Example:
#
# Company.new.logo = File.new…
#
# Given the file "…" was attached as logo to the company above
#
#
# Example:
#
# class Gallery
# has_many :images, :as => :owner
# end
#
# class Image
# belongs_to :owner, polymorphic: true
# end
#
# # so container = Image.new; container.file = File.new… , container.owner = object
#
# Given the file "…" was attached as Image/file to the company above
#
#
# Example:
#
# Set updated_at with
#
# Given … above at "2011-11-11 11:11"
#
Virtual attributes for integer fields
Note that this card is very old. You might want to use ActiveType for your auto-coerced virtual attributes instead.
We sometimes give our models virtual attributes for values that don't need to be stored permanently.
When such a virtual attribute should contain integer values you might get unexpected behavior with forms, because every param is a string and you don't get the magic type casting that...
howto fix spreewald issue „database configuration does not specify adapter (ActiveRecord::AdapterNotSpecified)“
This error occurs when you already have a database.yml
which defines the database for the cucumber
environment instead of test
. (Spreewald database.sample.yml
has changed)
Fix
Change cucumber
to test
in your databse.yml
test: # <---
adapter: mysql2
database: spreewald_test
encoding: utf8
host: localhost
username: root
password: password
Rubymine >= 5.4.3.2.1 supports keybinding for "Goto next/previous splitter"
Rubymine supports keybinding to switch panes by hotkey like awesome window manager users are used to.
Type "splitter" in the top right keymap section search field (not the global settings search).
Note: A splitter
is what you get after using split vertically
or split horizontally
.
How to find out the type of a model's attribute
When you want to find out the data type of an attribute, you can just use ActiveRecord's columns_hash
method.
It returns a hash of column objects that include a type
attribute (and more database-related information).
Example:
Contract.columns_hash['id'].type
=> :integer
Contract.columns_hash['active'].type
=> :boolean
Contract.columns_hash['updated_at'].type
=> :datetime
Alan Klement: Replacing The User Story With The Job Story
I've written about the problem with user stories before. At the time, I found it better to just have the team talk over proposed changes to the product. This worked great when the team had gelled and the product is very mature; however, now I'm working with a new team and building a product from scratch. In this case, because our canvas is blank, we are having trouble getting on the same page when it comes to customer motivations, events and expectations. But today, things have turned around. I've come across a great way to use the jobs to...
pickadate.js
The mobile-friendly, responsive, and lightweight jQuery date & time input picker.
Does not depend on jQuery UI, but currently does not allow typing in the associated input field.
An Illustrated Guide to SSH Agent Forwarding
Note - This is not a tutorial on setup or configuration of Secure Shell, but is an overview of technology which underlies this system.
How to subscribe to Ruby security updates
Ruby publishes security issues and MRI updates on ruby-lang.org. Unfortunately there is no straight-forward way to subscribe to these updates via e-mail.
I fixed this for me by taking their RSS feed and submitting it to Blogtrottr. Blogtrottr is an RSS-to-email service that sends you an e-mail whenever the feed updates.
kickstarter/rack-attack
Rack::Attack is a rack middleware to protect your web app from bad clients. It allows whitelisting, blacklisting, throttling, and tracking based on arbitrary properties of the request.
MySQL: How to clone a database
Here is a way to create a duplicate of one database, with all its tables and their data, under a new name.
-
Make a dump of your source database:
mysqldump -uroot -p my_project -r my_project.sql
Or, if you only want to dump the database's table structure (schema) without any contents:
mysqldump -uroot -p my_project -r my_project.sql --no-data
-
Open up a MySQL shell:
mysql -uroot -p
-
From the MySQL shell, create a new database and populate it with the dumped data:
CREATE DATABASE my_project_copy;
...
Slice a nested hash
The attached initializer gives your hashes a #deep_slice
method that lets you recursively slice their contents by a given whitelist of allowed keys and sub-keys:
{ :a => { :b => 'b', :c => 'c' } }.deep_slice(:a => :c) # => { :a => { :c => 'c' } }
ftlabs/fastclick
FastClick is a simple, easy-to-use library for eliminating the 300ms delay between a physical tap and the firing of a click event on mobile browsers. The aim is to make your application feel less laggy and more responsive while avoiding any interference with your current logic.
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 ...