Skip to content

Instantly share code, notes, and snippets.

View davydovanton's full-sized avatar
:shipit:
Working from home

Anton Davydov davydovanton

:shipit:
Working from home
View GitHub Profile
http://www.facebook.com/sharer.php?u={url}&t={title}
http://www.liveinternet.ru/journal_post.php?action=n_add&cnurl={url}&cntitle={title}
http://www.livejournal.com/update.bml?event={url}&subject={title}
http://connect.mail.ru/share?url={url}&title={title}
http://www.odnoklassniki.ru/dk?st.cmd=addShare&st._surl={url}&title={title}
http://twitter.com/share?text={title}&url={url}
http://vkontakte.ru/share.php?url={url}
http://www.google.com/buzz/post?message={title}&url={url}
http://del.icio.us/post?url={url}&title={title}
http://digg.com/submit?url={url}&title={title}&media=news&topic=people&thumbnails=0
" Tools for searching and replacing text in Vim
" Search for the current visual selection
fun! StarSearch(direction)
let old_reg = getreg('"')
let old_regtype = getregtype('"')
exe 'normal! gvy\<esc>gV'
let @/ = EscapeMagic(@")
call histadd("/", @/)
call setreg('"', old_reg, old_regtype)

Zero downtime deploys with unicorn + nginx + runit + rvm + chef

Below are the actual files we use in one of our latest production applications at Agora Games to achieve zero downtime deploys with unicorn. You've probably already read the GitHub blog post on Unicorn and would like to try zero downtime deploys for your application. I hope these files and notes help. I am happy to update these files or these notes if there are comments/questions. YMMV (of course).

Other application notes:

  • Our application uses MongoDB, so we don't have database migrations to worry about as with MySQL or postgresql. That does not mean that we won't have to worry about issues with the database with indexes being built in MongoDB or what have you.
  • We use capistrano for deployment.

Salient points for each file:

Transactions

As your business logic gets complex you may need to implement transactions. The classic example is a bank funds transfer from account A to account B. If the withdrawal from account A fails then the deposit to account B should either never take place or be rolled back.

Basics

All the complexity is handled by ActiveRecord::Transactions. Any model class or instance has a method named .transaction. When called and passed a block, that block will be executed inside a database transaction. If there's an exception raised, the transaction will automatically be rolled back.

Example

@davydovanton
davydovanton / osx-10.11-setup.md
Created December 20, 2015 18:54 — forked from kevinelliott/osx-10.11-setup.md
Mac OS X 10.11 El Capitan Setup

Mac OS X 10.11 El Capitan

Custom recipe to get OS X 10.11 El Capitan running from scratch, setup applications and developer environment. This is very similar (and currently mostly the same) as my 10.10 Yosemite setup recipe (as found on this gist https://gist.github.com/kevinelliott/0726211d17020a6abc1f). Note that I expect this to change significantly as I install El Capitan several times.

I use this gist to keep track of the important software and steps required to have a functioning system after a semi-annual fresh install. On average, I reinstall each computer from scratch every 6 months, and I do not perform upgrades between distros.

This keeps the system performing at top speeds, clean of trojans, spyware, and ensures that I maintain good organizational practices for my content and backups. I highly recommend this.

You are encouraged to fork this and modify it to your heart's content to match your own needs.

@davydovanton
davydovanton / rdrc2016.md
Created July 9, 2016 09:37 — forked from cheeaun/rdrc2016.md
RedDotRubyConf 2016 links & resources 😘
@davydovanton
davydovanton / GIF-Screencast-OSX.md
Created August 21, 2016 15:06 — forked from dergachev/GIF-Screencast-OSX.md
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@davydovanton
davydovanton / config.ru
Created September 24, 2016 21:30 — forked from homakov/config.ru
config.ru
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
#prevents DNS rebinding attacks
class DNSBinding
VALID_HOSTS = %w{localhost:9292 myshop.dev:3000 myshopprod.com}
def initialize(app)
@app = app
end
@davydovanton
davydovanton / talks.md
Created December 13, 2016 20:36 — forked from melekes/talks.md
The list of my favorite talks.
@davydovanton
davydovanton / Grafana Alert Template.md
Created November 21, 2023 15:36 — forked from gelldur/Grafana Alert Template.md
How to use Grafana Alerts with the Telegram
  • Template name: telegram.message
  • Content:
    {{- /* Telegram message to use: {{ template "telegram.message2" . }} */ -}}
    {{ define "__alerts_list" -}}
    {{ range . }}
    {{if ne (index .Labels "alertname") "" -}}
    {{ if eq .Status "firing" }}🔴{{ else }}🟢{{ end }}
        {{- if ne (index .Labels "severity") "" -}}
            <u><b>P{{ index .Labels "severity" }}</b></u> {{ end -}}