Skip to content

Instantly share code, notes, and snippets.

@afa
afa / deploy.rb
Created July 28, 2011 11:34 — forked from bradly/deploy.rake
Simple Rails Deployments with Net/SSH
require 'net/ssh'
desc "Deploy site to production"
task :deploy => :environment do
host = 'yourhost.com'
user = 'username'
options = {:keys => '~/.ssh/keys/yourserver.pem'}
remote_path = '/path/to/rails_app'
commands = [
@afa
afa / Declaring Branch Bankruptcy.sh
Created August 2, 2011 09:26
git workflow usage from sandofsky@t article
#Maybe my feature branch existed for a very long time, and I had to merge several branches into my feature branch to keep it up to date while I work. History is convoluted. It’s easiest to grab the raw diff create a clean branch.
git checkout master
git checkout -b cleaned_up_branch
git merge --squash private_feature_branch
git reset
#I now have a working directory full of my changes and none of the baggage from the previous branch. Now I manually add and commit my changes.
@afa
afa / cucumber_pauser.rb
Created August 26, 2011 07:32
debug in cucumber's
AfterStep('@pause') do
print "Press Return to continue..."
STDIN.getc
end
@afa
afa / gist:1200070
Created September 7, 2011 08:39
sqlite3 ruby install fix
export CONFIGURE_ARGS="with-sqlite3-include=/usr/local/include" && gem install sqlite3-ruby
@afa
afa / resque_web.rb
Created September 14, 2011 08:22 — forked from grosser/resque_web.rb
Mountable resque-web for rails 3+ apps
# https://gist.github.com/1214052
require 'sinatra/base'
class ResqueWeb < Sinatra::Base
require 'resque/server'
use Rack::ShowExceptions
if CFG[:user].present? and CFG[:password].present?
Resque::Server.use Rack::Auth::Basic do |user, password|
user == CFG[:user] && password == CFG[:password]
@afa
afa / gist:1451070
Created December 9, 2011 10:48
cucmber cheatsheet
#Navigating
visit('/projects')
visit(post_comments_path(post))
#Clicking links and buttons
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@afa
afa / gist:1605422
Created January 13, 2012 10:23
найти и распечатать ремайновских авторо-ватчеров для активных задач
(Issue.all(:conditions=>{:author_id => 45}).map(&:id) + Watcher.all(:conditions=>{:watchable_type => "Issue", :user_id => 45 }).map(&:watchable_id)).uniq.map{|i| Issue.find(i) }.select{|it| ["Новый", "Разработка", "Тестирование", "Проектирование", "Оценка результатов", "На перенос", "Перенесено", "К разработке"].include?(it.status.name) }.sort_by{|it| it.id }.each{|it| puts [it.id, it.tracker.name.inspect, it.status.name.inspect, it.priority, it.subject.inspect, it.author.name.inspect, (it.assigned_to.try(:name) || "").inspect, it.start_date, it.due_date, it.done_ratio, it.custom_field_values.select{|f| f.custom_field_id == 22 }.map(&:value).join(':').inspect].join(', ') }.size
" An example for a vimrc file.
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last change: 2008 Jul 02
"
" To use it, copy it to
" for Unix and OS/2: ~/.vimrc
" for Amiga: s:.vimrc
" for MS-DOS and Win32: $VIM\_vimrc
" for OpenVMS: sys$login:.vimrc
@afa
afa / xmpp.rb
Created February 3, 2012 10:19
xmpp example
require 'rubygems'
require 'xmpp4r/client'
include Jabber
server, login, password = "qip.ru", "my_login", "my_password"
to, subject, body = "someone@qip.ru", "XMPP4R test", "Hi, this is my first try from XMPP4R!!!"
Jabber::debug = true
jid=JID::new "#{login}@#{server}"
@afa
afa / gist:2043722
Created March 15, 2012 11:18
зачистка всех непозволенных ключей из хэша
{1=>2, 3=>4}.select{|a, b| [1].include? a }.inject({}){|r, v| r.merge(v[0] => v[1]) }