Skip to content

Instantly share code, notes, and snippets.

@afa
afa / rescue-from-git-push-force.md
Created August 4, 2017 13:06 — forked from Envek/rescue-from-git-push-force.md
Откат ошибочной команды git push --force

Откат ошибочной команды git push --force

Иногда при работе с несколькими удалёнными репозиториями в git, может произойти страшное: git push --force в не тот remote и/или не в ту ветку.

Такое может случиться, например, если вы используете [Deis], в котором деплой запускается при git push нужного коммита в сборщик, когда при отладке деплоя после очередного git commit --amend по запарке вместо git push deis master --force делается просто git push --force. Упс.

Как результат, последние коммиты коллег безвозвратно потеряны, и вы чувствуете неотвратимость их ярости…

Но это git, а значит всё можно починить!

@afa
afa / capybara_cheat_sheet.md
Created June 29, 2017 17:20 — forked from WaKeMaTTa/capybara_cheat_sheet.md
Capybara - Cheat Sheet

Navigating

visit("/projects")
visit(post_comments_path(post))

Clicking links and buttons

@afa
afa / game.rb
Created May 19, 2017 12:45
celluloid game
class Game
include Celluloid
include Celluloid::IO
include Celluloid::Internals::Logger
include Celluloid::Notifications
extend Forwardable
finalizer :finalizer
def_delegators :int_state, :stage, :step, :total_steps, :step_status, :statements, :setting
attr_accessor :name, :online
@afa
afa / 00_README.md
Created January 20, 2017 08:03 — forked from mikechau/00_README.md
Logging Rails 4 to Syslog, formatted w/ Logstash

Logging Rails 4 to Syslog, formatted w/ Logstash

Getting Started

Steps to get Rails 4 saving its output to Syslog via Rsyslog. This assumes you are on CentOS, but should be pretty adaptable to any other distribution. Ruby 2.0+ is also required.

  1. Add the gems lograge and logstash-event to your Gemfile. Feel free to remove from production if you'd like to test it in development as well or something.
  2. Update production.rb with the lograge settings and set the logger to Syslog::Logger.
  3. Add the conf files to /etc/rsyslog.d/. /etc/rsyslog.conf should have $IncludeConfig /etc/rsyslog.d/*.conf enabled, so it will load any additional configs from /etc/rsyslog.conf.
@afa
afa / Gemfile
Created December 23, 2015 09:40 — forked from gvarela/Gemfile
web sockets with eventmachine and redis pub/sub
# A sample Gemfile
source "http://rubygems.org"
gem "redis"
gem 'eventmachine', :git => 'git://github.com/eventmachine/eventmachine.git'
gem "em-hiredis"
# gem "em-synchrony"
gem "em-websocket"
@afa
afa / feature_macros.rb
Created November 13, 2015 10:23
Tuning capybara + capybara-webkit + database_cleaner + DeferredGarbageCollection + feature macros
# spec/support/feature_macros.rb
module FeatureMacros
extend ActiveSupport::Concern
# get current domain ("lvh.me:12345")
def domain(port = Capybara.current_session.server.try(:port) || 3000)
port &&= ":#{ port }"
"#{ DEFAULT_HOST }#{ port }"
end
# Build an inverted index for a full-text search engine with Redis.
# Copyright (C) 2009 Salvatore Sanfilippo. Under the BSD License.
# USAGE:
#
# ruby invertedindex.rb add somedir/*.c
# ruby invertedindex.rb add somedir/*.txt
# ruby search your query string
require 'rubygems'
require 'redis'
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/bin/sh
#
# init.d script for single or multiple unicorn installations. Expects at least one .conf
# file in /etc/unicorn
#
# Modified by [email protected] http://github.com/jaygooby
# based on http://gist.github.com/308216 by http://github.com/mguterl
#
## A sample /etc/unicorn/my_app.conf
##
@afa
afa / gist:8434886
Created January 15, 2014 11:51 — forked from anaumov/gist:8432161
class CarConfig
include ActiveSupport::Configurable
config_accessor :brand
end
class Car
attr_accessor :brand
def initialize
self.brand = self.class.config.brand