Skip to content

Instantly share code, notes, and snippets.

View nlevchuk's full-sized avatar
🪐

Nikita Levchuk nlevchuk

🪐
View GitHub Profile
@nlevchuk
nlevchuk / shared_folder_centos_virtualbox.txt
Created January 2, 2017 20:37 — forked from larsar/shared_folder_centos_virtualbox.txt
Mount shared folder on CentOS in VirtualBox
# The VirtualBox documentation[1] for how to install guest additions
# for Linux on a virtual host is somewhat messy. So here is what
# I did to make it work.
# Install the packages required
yum update
yum install gcc kernel-devel make bzip2
reboot
if Rails.env.production?
PAYPAL_ACCOUNT = 'production@gmail.com'
else
PAYPAL_ACCOUNT = 'development@gmail.com'
ActiveMerchant::Billing::Base.mode = :test
end
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
class Avatar < ActiveRecord::Base
attr_accessor :content_type, :original_filename, :image_data
before_save :decode_base64_image
has_attached_file :image,
PAPERCLIP_CONFIG.merge(
:styles => {
:thumb => '32x32#',
:medium => '64x64#',
require 'rubygems'
require 'rubygems/package'
require 'zlib'
require 'fileutils'
module Util
module Tar
# Creates a tar file in memory recursively
# from the given path.
#
# download and make Redis
$ wget http://redis.googlecode.com/files/redis-2.6.7.tar.gz
$ sudo tar xzf redis-2.6.7.tar.gz -C /usr/lib/
$ cd /usr/lib/redis-2.6.7
$ sudo make
# create symlinks to the /usr/local/bin
$ sudo ln -s /usr/lib/redis-2.6.7/src/redis-server /usr/local/bin/redis-server
$ sudo ln -s /usr/lib/redis-2.6.7/src/redis-cli /usr/local/bin/redis-cli
class ApplicationController < ActionController::Base
# ...
unless Rails.application.config.consider_all_requests_local
rescue_from Exception, with: lambda { |exception| render_error 500, exception }
rescue_from ActionController::RoutingError, ActionController::UnknownController, ::AbstractController::ActionNotFound, ActiveRecord::RecordNotFound, with: lambda { |exception| render_error 404, exception }
end
private
def render_error(status, exception)
#!/usr/bin/env bash
export TMUX_INSTALL_VERSION=1.6
wget -q -O - "https://gist.github.com/raw/4561674/install_tmux_${TMUX_INSTALL_VERSION}_on_ubuntu_10.04.sh" | sudo bash

Out of the box, Homebrew does a default installation on Sphinx:

$ brew install sphinx

However, if you're using MySQL, the thinking-sphinx gem won't work because it needs to use MySQL libraries.

If you managed to screw up the first time, uninstall sphinx first:

$ brew remove sphinx

@nlevchuk
nlevchuk / unicorn
Created March 27, 2012 09:54 — forked from vdv/unicorn
unicorn init.d script with rvm on ubuntu 11.04
#!/bin/bash
### BEGIN INIT INFO
# Provides: APPLICATION
# Required-Start: $all
# Required-Stop: $network $local_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start the APPLICATION unicorns at boot
# Description: Enable APPLICATION at boot time.
### END INIT INFO