Skip to content

Instantly share code, notes, and snippets.

View poly_through_issue.rb
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "activerecord", "~> 4"
gem "pg", "0.19"
end
require "active_record"
@stas
stas / console.cap
Created Dec 13, 2013
Capistrano 3 console (Rails/SSH) tasks
View console.cap
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
@stas
stas / deploy.rb
Created Jan 15, 2013
Mina Deploy Task (Rails + Puma + Delay Job + rbenv)
View deploy.rb
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)
@stas
stas / pry.rb
Created Jan 9, 2013
3.2.11 routing spec debugged
View pry.rb
pry(#<RSpec::Core::ExampleGroup::Nested_14::Nested_1>)> @routes.router
=> #<Journey::Router:0xa4e6150
@options=
{:parameters_key=>"action_dispatch.request.path_parameters",
:request_class=>ActionDispatch::Request},
@params_key="action_dispatch.request.path_parameters",
@request_class=ActionDispatch::Request,
@routes=
#<Journey::Routes:0xa4e61b4
@ast=
@stas
stas / Rakefile
Created Nov 22, 2012
Rails Engine: rake task and generator to DRY `spec/dummy`
View Rakefile
#!/usr/bin/env rake
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec => :dummy_app) do |t|
t.pattern = File.expand_path('../spec/**/*_spec.rb', __FILE__)
end
task :default => :spec
desc 'Generates a dummy app for testing'
task :dummy_app => [:setup, :migrate]
@stas
stas / .gitconfig
Created Oct 10, 2012
WordPress Git SVN config example
View .gitconfig
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
autocrlf = false
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = git@github.com:Courseware/buddypress-courseware.git
[branch "master"]
@stas
stas / git-version.php
Created Oct 5, 2012
Hook git repo version into WordPress <head>.
View git-version.php
<?php
/*
Plugin Name: Git Version
Plugin URI: http://wordpress.org/extend/plugins/git-version/
Description: Add a git version meta to HEAD
Version: 0.1
Author: sushkov
Author URI: http://wordpress.org/extend/plugins/git-version/
*/
?>
View vbSEO_cowboys_should_read_php_specs.diff
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 / config.ru
Created Aug 13, 2012
Rack app for serving static files (ex. on Heroku), handles haml if any, just drop it in compass project dir.
View config.ru
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 / crontab
Created Aug 1, 2012
WordPress tests svn git mirror scripts
View crontab
*/1 * * * * stas ( cd /home/stas/wordpress-tests && ./update.sh ) >/dev/null 2>&1
You can’t perform that action at this time.