/etc/security/limits.conf
elasticsearch hard memlock 100000
/etc/default/elasticsearch
# nginx.conf | |
user nginx; | |
worker_processes 1; | |
error_log /var/log/nginx/error.log; | |
pid /var/run/nginx.pid; | |
timer_resolution 500ms; |
# myapp | |
upstream unicorn_myapp { | |
server unix:/var/rails/myapp/current/tmp/sockets/unicorn.sock fail_timeout=0; | |
} | |
server { | |
server_name myapp.com www.myapp.com; | |
root /var/rails/myapp/current/public; |
require 'rspec/core/rake_task' | |
RSpec::Core::RakeTask.new(:spec) do |t| | |
t.rspec_opts = '--format html --out reports/rspec_results.html' | |
end | |
namespace :rspec_report do | |
desc 'Run all specs and generate RSpec report in HTML' | |
task :html => :spec |
Rails 4 uses asset pipeline to concatenate and minify or compress JavaScript and CSS assets. It creates a default app/assets/stylesheets/application.css file which contains these lines:
/*
*= require_self
*= require_tree .
*/
The require_tree directive tells Sprockets to recursively include all CSS files in the specified directory into the output.
There are times that for some layout pages that we would like to exclude a couple of CSS files. Following two ways help us to accomplish this:
It may seem like a trivial decision at first glance, but using UUIDs can have an intricate effect on your applications design structure. If you are building an application and have an id:integer column that auto increments with the creation of every item you add to that table you could end up with some sever issues. As applications grow in size we end up having to seperate parts of the application into different servers: a cluster of database servers, background, jobs, cache server, an httpd server, and throw in a few servers for actual application and you’ve got a whole cluster of services to deal with.
Lets say you’ve got 3 servers running the actual application, each one chugging along running serveral instances of your web application. Now say it’s a basic CRUD application if you’ve got several instances writing to the database at once you will have a conflict. If you’ve got a table named books and a few rows are being added at once by seperate visitors, you’re auto incrimenting the rows
Although it may be obvious for many developers, there are still some that are not aware of great features that PostgreSQL allows to use with ActiveRecord. This tutorial is intended to reveal UUID type, which we can use in our Rails applications, especially as models’ attributes.
Special Postgre’s data types are available in our databases by enabling so called extensions. According to the documentation:
PostgreSQL is extensible because its operation is catalog-driven. The catalogs appear to the user as tables like any other. PostgreSQL stores much more information in its catalogs like data types, functions and access methods. These tables can be extended by the user. Traditional database systems can only be extended by changing source code or by loading modules written by the DBMS vendor. So not only we get a possibility to create our own extensions, but we get a bunch of useful features out of the box as well. Let’s see one of them in action right now.
If you setup a Rails 4 app, you’ll notice the app/models/concerns and app/controllers/concerns directories. Concerns are modules that can be mixed into your models and controllers to share code between them.
Some developers falsely classify mixins as composition when they are actually a form of inheritance. When you include a module in a class, that module’s methods are added to the inheritance chain just like a parent class’ methods are added to a subclass. So, don’t think you’ve solved the problem of inheritance by simply splitting your inherited code into separate files!
That being said, mixins can be a valuable tool to share code between classes that are otherwise unrelated. Here’s an example of how I chose to use it recently.
I am adding admin reporting features to an app I’m hoping to launch soon. I have an admin controller with a simple before filter to redirect if the current user is not an administrator.
class AdminController < ApplicationController
Squid is a web proxy and cache server which primarily provides proxy and cache services for the HTTP protocol. In this tutorial we are going to show you how to install and configure Squid proxy server on a Linux VPS.
Before we start with installing and configuring Squid, let’s update all the system software to the latest version available:
sudo apt-get update && sudo apt-get -y upgrade
The update should take few moments. Once it is done, you are ready to proceed with the other steps of this tutorial. Since Squid is available in the Ubuntu repositories, the installation of Squid proxy server on an Ubuntu VPS is pretty straightforward. To install it on your server you need to run the following command:
sudo apt-get install squid