Skip to content

Instantly share code, notes, and snippets.

@linko
linko / sidekiq_watcher.rb
Created March 20, 2015 15:26
Sidekiq Watcher
require 'net/http'
require 'json'
def alert_to_slack(env)
uri = URI.parse('https://hooks.slack.com/services/<uri>')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.request_uri, {'Content-Type' => 'application/json'})
request.body = {
"channel" => '#channel',
@import "compass/css3/appearance";
@import "h5bp";
@import "compass/reset";
@import "compass/css3";
@import "compass/css3/pie";
@import "compass/css3/images";
@import "compass/typography";
@import "compass/layout/grid-background";
@import "compass/css3/box-sizing";
@import "compass/utilities/sprites/base";
// Bootstrap components
@import "bootstrap/normalize";
@import "bootstrap/variables";
@import "bootstrap/mixins";
@import "bootstrap/scaffolding";
@import "bootstrap/type";
@import "bootstrap/grid";
@import "bootstrap/tables";
@import "bootstrap/forms";
@import "bootstrap/buttons";
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
unless Rails.application.config.consider_all_requests_local
rescue_from Exception, with: lambda { |exception| Airbrake.notify(exception); render_error(500) }
rescue_from ActionView::MissingTemplate, ActiveRecord::RecordNotFound, ActionController::RoutingError,
ActionController::UnknownController, AbstractController::ActionNotFound, ActiveRecord::RecordNotFound,
ActionController::UnknownFormat, with: lambda { |exception| render_error(404) }
find app/views/ -name '*.html.haml' | while read p; do haml-i18n-extractor $p -n -y config/locales/views/$(echo $p | sed 's/app\/views\///g' | sed 's/.html.haml/.yml/g') && echo $p; done
remember to put this to application.rb:
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]
after that might need to run
grep -Rl "'\"" config/locales/ | while read p; do sed -i "s/'\"/'/g" $p && sed -i "s/\"'/'/g" $p; done
Geocoder.configure(:lookup => :test)
Geocoder::Lookup::Test.set_default_stub(
[
{
'latitude' => 40.7143528,
'longitude' => -74.0059731,
'address' => 'New York, NY, USA',
'state' => 'New York',
'state_code' => 'NY',
require 'spec_helper'
describe 'Sponsorships' do
include Warden::Test::Helpers
describe 'Sponsorships Application form', :js do
let(:proposal) { Faker::Lorem.paragraphs(20).join('.') }
it 'fills out the form and submit' do
class ElementCacheWorker
include Sidekiq::Worker
include Rails.application.routes.url_helpers
sidekiq_options retry: true, failures: true
def perform(element_id)
element = Element.where(id: element_id).first
if element.present?
# spec/support/capybara.rb
require 'capybara/rspec'
require 'capybara/rails'
Capybara.javascript_driver = :webkit
Capybara.app_host = 'lvh.me'
Capybara.always_include_port = true
# spec/support/host_for_subdomains.rb
You should have 2 repositories
origin - your fork
upstream - main repository
<fork repository>
0. git clone [email protected]:you/project.git
1. git remote add upstream [email protected]:our/project.git
2. git checkout master
3. git pull upstream master
4. git checkout -b my-important-feature