Installing RubyGems for Ruby 1.8.6
Since version 1.5 RubyGems requires at least Ruby 1.8.7. The last one working with Ruby 1.8.6 was RubyGems 1.4.2.
You get still download it from their servers and install RubyGems.
How to fix Passenger "Unexpected end-of-file detected" error
This is for you if Passenger gives you the following useless error message.
Passenger encountered the following error:\
The application spawner server exited unexpectedly: Unexpected end-of-file detected.
- Exception class:
- PhusionPassenger::Rack::ApplicationSpawner::Error
Most often this happens because you are missing a gem. Usually Passenger would tell you about that but in some cases it can't.
To resolve this issue, run:
bundle install
If this does not do the trick for you, take a look at the Apache log files for de...
Let the browser choose the protocol
Use protocol independent URLs whenever possible so that the browser will choose the protocol related to the protocol which the page is delivered with.
Example issues
- When your page is delivered via
https
and you provide a youtube video only viahttp
the most browsers (e.g. Firefox, Chrome) won't display the video. - When you deliver your youtube video via
https://youtu.be/jyElDp98HdI
your test which checks that the embeded video is rendered in the view will fail because your test server doesn't use https
Solution
Let your lin...
MySQL: "LOAD DATA INFILE" says "file not found"
This might be due to AppArmor denying the MySQL server access to most of the filesystem. You can instead use
LOAD DATA LOCAL INFILE ...
to pipe data through the MySQL client, which can read everything the executing user can.
xip.io: wildcard DNS for everyone
xip.io is a magic domain name that provides wildcard DNS for any IP address. Say your LAN IP address is 10.0.0.1. Using xip.io,
10.0.0.1.xip.io resolves to 10.0.0.1
www.10.0.0.1.xip.io resolves to 10.0.0.1
mysite.10.0.0.1.xip.io resolves to 10.0.0.1
foo.bar.10.0.0.1.xip.io resolves to 10.0.0.1
...and so on. You can use these domains to access virtual hosts on your development web server from devices on your local network, like iPads, iPhones, and other computers.
JSONP - Wikipedia
Under the same origin policy, a web page served from server1.example.com cannot normally connect to or communicate with a server other than server1.example.com. An exception is the HTML <script> element. Taking advantage of the open policy for <script> elements, some pages use them to retrieve Javascript code that operates on dynamically-generated JSON-formatted data from other origins. This usage pattern is known as JSONP. Requests for JSONP retrieve not JSON, but arbitrary JavaScript code.
Rails: How to get PostgreSQL version being used
To check the currently running PG version from your Rails application (e.g. Rails console on your production server), simply do this:
ActiveRecord::Base.connection.select_value('SELECT version()')
HTTPie nice command line HTTP client
HTTPie consists of a single http command designed for painless debugging and interaction with HTTP servers, RESTful APIs, and web services
It easy to use and has very nice defaults and coloured output which makes it good for local testing.
Usage examples with curl equivalent:
# curl post
curl --data "foo=23&bar=42" https://example.org/blub
# httpie post
http https://example.org/blub foo=23 bar=42
# curl localhost
curl localhost:3000/users
# httpie localhost
http :3000/users
travisliu/traim: Resource-oriented microframework for RESTful APIs
Use Traim to build a RESTful API for your ActiveRecord models with very little code.
Traim assumes your API resources will map 1:1 to your ActiveRecord models and database tables. This assumption usually falls apart after a few months into a project, so be ready to replace your Traim API with something more expressive afterwards.
Traim outputs a Rack application which you can either serve standalone or mount into your Rails app.
nginx: How to drop connections for a location
If you want to configure your nginx to drop connections to a specific location
, you can do so by responding with HTTP response code 444.
Status 444 is a non-standard response code that nginx will interpret as "drop connection".
Example:
server {
listen 127.0.0.1;
location /api/ {
return 444;
}
}
An example use case is reverse-proxying with nginx and simulating a route that drops connections.
Don't use Ruby 1.9.2
Ruby 1.9.2 is very slow when loading files, especially starting Rails servers or running specs takes forever.
Do yourself a favor and upgrade to 1.9.3.
mysql-master-master - Google Code
MMM (MySQL Master-Master Replication Manager) is a set of flexible scripts to perform monitoring/failover and management of MySQL Master-Master replication configurations (with only one node writable at any time). The toolset also has the ability to read balance standard master/slave configurations with any number of slaves, so you can use it to move virtual IP addresses around a group of servers depending on whether they are behind in replication.
Git: See all unpushed commits or commits that are not in another branch
If you need to find out which of your local commits are not on the remote server do this:
git cherry -v
The -v
option prints out the commit messages. Without it you will see only the SHA1 codes.
You may also compare against another (upstream) branch like that:
git cherry -v origin/somebranch
This tool is especially useful when you have a ton of commits after a merge and want to know the commit differences between branches.
Exclude your staging site from Google with robots.txt and not shoot yourself in the foot
If you want to exclude your staging site from Google using robots.txt
without running the risk to forget deleting the file once you go live, name the file robots.exclude.txt
instead.
In your Apache Vhost config, rewrite requests for the staging server only:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^staging\.project\.com$
RewriteRule ^robots\.txt$ /robots.exclude.txt
Your robots.exclude.txt
looks like this:
# This file is returned for /robots.txt on staging servers
User-agent: *
Disallow: /
**Important ...
Keep Pidgin up to date
If your pidgin IM fails to connect to ICQ, you may need to update it. The ubuntu default sources are usually outdated.
Just follow the instructions 1-4 and 1-3 on the page linked below.
Making SSL connection work
If you can not connect using SSL, open up the account settings and enable "clientLogin". Also, your Server should be set to slogin.icq.com
.
Tearing Down Capybara Tests of AJAX Pages
An all-in-approach to fix the problem of pending AJAX requests dying in the browser when the server ends a test or switches scenarios.
We were able to work around this issue in most projects by doing this instead:
After '@javascript' do
step 'I wait for the page to load'
end
Force net/http to verify SSL certificates
Ruby's net/http is setup to never verify SSL certificates by default. Most ruby libraries do the same. That means that you're not verifying the identity of the server you're communicating with and are therefore exposed to man in the middle attacks. This gem monkey-patches net/http to force certificate verification and make turning it off impossible.
Researching a new form of HTTP caching optimization - Phusion BlogPhusion Blog
Interesting approach to caching responses directly in the HTTP server, based on the value of an individual cookie.
No word yet how to force cache-invalidation.
Your First AngularJS App: A Comprehensive Tutorial
This is a great tutorials for beginners and intermediate AngularJS developers. It covers a lot of ground, including routing and data transfer between client and server.
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.
Removing Dot-Underscore Files ~ Kadin2048's Weblog
This is just a quick note, mostly for my own reference, of a few ways to easily delete the dot-underscore (._foo, ._bar, etc.) files created by (badly-behaved) Mac OS X systems on non-AFP server volumes.
Evening on Backbone.js/Views w/ Q&A with David Heinemeier Hansson - YouTube
Interesting interview with DHH, where he talks about how they made the new Basecamp feel very fast without using a lot of Javascript (most of Basecamp still lives on the server). The two tricks they used are PJAX and Russian Doll Caching.
defunkt/jquery-pjax
pjax loads HTML from your server into the current page without a full reload. It's ajax with real permalinks, page titles, and a working back button that fully degrades.
pjax enhances the browsing experience - nothing more.