Skip to content

Instantly share code, notes, and snippets.

@stas
stas / vsftpd.conf
Created February 26, 2010 14:46
VSFTPD.CONF for virtual users with write/read/delete permissions
###
# VSFTPD.CONF for virtual users with write/read/delete permissions
###
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
xferlog_enable=YES
connect_from_port_20=YES
chown_uploads=YES
require 'active_model/validator'
# Runs [Array] type validations
class ArrayValidator < ActiveModel::EachValidator
# Checks if the value is an [Array] type
#
# Will sort, remove duplicates and blanks as well.
#
# Will validate the subset if passed options are present under `subset_of`.
#
@stas
stas / deploy.rb
Created January 15, 2013 15:34
Mina Deploy Task (Rails + Puma + Delay Job + rbenv)
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rbenv' # for rbenv support. (http://rbenv.org)
# require 'mina/rvm' # for rvm support. (http://rvm.io)
# Basic settings:
# domain - The hostname to SSH to.
# deploy_to - Path to deploy into.
# repository - Git repo to clone from. (needed by mina/git)
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "activerecord", "~> 4"
gem "pg", "0.19"
end
require "active_record"
@stas
stas / post-receive.sh
Created February 4, 2012 21:18
Heroku like deployment git hooks
#!/bin/bash
# (Re)spawn the application
function spawn () {
local ps_name=$1
local spawn_cmd=$2
local pids=`ps -C $ps_name -o pid=`
if [ ${#pids} -ne 0 ]
then
echo "Sending TERM to $pids..."
@stas
stas / vbSEO_cowboys_should_read_php_specs.diff
Created October 1, 2012 21:24
NGINX vbSEO https/http fix.
diff --git vbseo/includes/functions_vbseo_pre.php vbseo/includes/functions_vbseo_pre.php
index db03f74..27a251f 100755
--- vbseo/includes/functions_vbseo_pre.php
+++ vbseo/includes/functions_vbseo_pre.php
@@ -26,7 +26,7 @@ if (!defined('VBSEO_VB_EXT'))
define('VBSEO_VB_EXT', 'php');
function vbseo_is_https()
{
-return isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] != 'off') || isset($_SERVER['HTTP_FRONT_END_HTTPS']);
+return isset($_SERVER['HTTPS']) && ( !empty( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] != 'off') || isset($_SERVER['HTTP_FRONT_END_HTTPS']);
@stas
stas / jquery.cleditor.pastecode.js
Created February 21, 2011 16:16
CLEditor pastecode (pre/code) plugin
// Just append `pastecode` to your controls
(function($) {
$.cleditor.buttons.pastecode = {
name: "pastecode",
image: "",
title: "Code",
command: "inserthtml",
popupName: "pastecode",
popupClass: "cleditorPrompt",
popupContent: "Paste the code:<br /><textarea cols='40' rows='3'></textarea><br /><input type='button' value='Ok' />",
@stas
stas / config.ru
Created August 13, 2012 21:03
Rack app for serving static files (ex. on Heroku), handles haml if any, just drop it in compass project dir.
require 'haml'
# Do not buffer output
$stdout.sync = true
# Get working dir, fixes issues when rackup is called outside app's dir
root_path = Dir.pwd
use Rack::Static,
:urls => ['/stylesheets', '/images', '/javascripts', '/fonts'],
:root => root_path
@stas
stas / console.cap
Created December 13, 2013 16:01
Capistrano 3 console (Rails/SSH) tasks
namespace :rails do
desc 'Opens the Rails console'
task :console => ['deploy:set_rails_env'] do
on primary fetch(:migration_role) do
within release_path do
with rails_env: fetch(:rails_env) do
cmd_string = command(:rails, 'console').to_command
exec 'ssh %s -l %s -p %s -t "%s"' % [
host.hostname, host.username, host.port, cmd_string]
end