Skip to content

Instantly share code, notes, and snippets.

@kirs
kirs / user.rb
Last active December 19, 2015 12:39 — forked from Olefine/user.rb
class User < ActiveRecord::Base
#default_scope where(:banned => false)
scope :unbanned, where(:banned => false)
include ChooseCity
rolify
acts_as_voter
has_karma(:questions, :as => :submitter, :weight => 0.5)
mount_uploader :avatar, AvatarUploader
namespace :app do
namespace :error_pages do
desc "Generates static pages 500, 403, 404, 422"
task :generate => :environment do
av = ActionView::Base.new
av.class_eval do
include ApplicationHelper
include Rails.application.routes.url_helpers
end
@kirs
kirs / sshc.sh
Created November 4, 2012 22:29 — forked from syabruk/sshc.sh
Manage ssh connection information
#!/bin/bash
SSHC_PATH=$HOME'/.sshc'
if [ ! -d $SSHC_PATH ] ; then
mkdir "$SSHC_PATH"
fi
case "$1" in
-a | --add)
touching_name="$2"
@kirs
kirs / deploy.rb
Created July 5, 2012 12:38 — forked from mikhailov/0. nginx_setup.sh
Nginx+Unicorn (production-ready setup)
# Capistrano configuration
#
# require 'new_relic/recipes' - Newrelic notification about deployment
# require 'capistrano/ext/multistage' - We use 2 deployment environment: staging and production.
# set :deploy_via, :remote_cache - fetch only latest changes during deployment
# set :normalize_asset_timestamps - no need to touch (date modification) every assets
# "deploy:web:disable" - traditional maintenance page (during DB migrations deployment)
# task :restart - Unicorn with preload_app should be reloaded by USR2+QUIT signals, not HUP
require 'spec_helper'
describe "HistoryItems" do
before(:each) {login_as :user}
describe "GET /history_items" do
it "works!" do
visit history_items_path
response.should be_success
end
end
@kirs
kirs / chef_solo_bootstrap.sh
Created April 12, 2012 10:14 — forked from ryanb/chef_solo_bootstrap.sh
Bootstrap Chef Solo
#!/usr/bin/env bash
apt-get -y update
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline5-dev libyaml-dev
cd /tmp
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz
tar -xvzf ruby-1.9.3-p125.tar.gz
cd ruby-1.9.3-p125/
./configure --prefix=/usr/local
make
make install
@kirs
kirs / action.php
Created September 10, 2011 06:47 — forked from anonymous/gist:1208029
public function actionRegistr()
{
$form = new RegistrForm;
if (!Yii::app()->user->isGuest) {
throw new CException('Вы уже зарегистрированны!');
} else {
if (isset($_POST['RegistrForm'])) {
$form->attributes = $_POST['RegistrForm'];