Skip to content

Instantly share code, notes, and snippets.

View ybogdanov's full-sized avatar

Yuriy Bogdanov ybogdanov

View GitHub Profile

Привет. Меня зовут Дима Унковский, я – ведущий разработчик в команде Platform в Grammarly, и я ищу хороших DevOps ребят в нашу команду.

Что делает ваша команда?

Наша область ответственности – облачная инфраструктура, сопутствующие инструменты и инфраструктурные сервисы. Улучшая их, мы делаем все, чтобы продуктовым командам было удобнее разрабатывать и поддерживать продукт Grammarly.

Что делает компания? Как вы работаете?

@ybogdanov
ybogdanov / app.yml
Last active November 28, 2016 00:26
An example of a high-level application (service) manifest. See http://tech.grammarly.com/blog/posts/How-We-Deploy-Containers-at-Grammarly.html
# This is an example of a high-level application (service) that can run along with
# platform agents, write metrics and logs to them.
namespace: example
containers:
app:
image: alpine:3.2
# We wrote a simple program that on every tick prints the iterator,
# increments a metric in StatsD and writes a line to the log file
cmd: |-
@ybogdanov
ybogdanov / platform.yml
Last active November 28, 2016 00:26
A manifest that describes "platform" agents that we run on every instance. See http://tech.grammarly.com/blog/posts/How-We-Deploy-Containers-at-Grammarly.html
# This is a manifest that describes "platform" agents that we run on every instance.
# It includes auxilary services that work alongside with the application containers
# to provide logging and monitoring.
#
# This file looks a bit tough, but that's what happens when you meet the reality.
# We have also pruned it a bit to remove our company specifics.
#
# You may notice "env", "role" and "track" variables. We specify them as EC2 instance
# tags and pass them to rocker-compose on every run. This allows us to distinguish
# instances and do basic service discovery and A/B testing.
@ybogdanov
ybogdanov / erlang_brute.erl
Created October 12, 2011 01:19
brute force example on erlang
-module(brute).
-export([brute/1]).
brute_(N, M, _, O) when N == M ->
O;
brute_(N, M, L, O) ->
[string:right(integer_to_list(N), L, $0) | brute_(N + 1, M, L, O)].
brute(N) ->
brute_(0, math:pow(10, N), N, []).
@ybogdanov
ybogdanov / node-sync-express-mysql-transactions.js
Created August 30, 2011 15:23
how to use node-sync in express-middleware style with mysql transactions
// Заюзай node-sync v0.1.9beta2, в ней есть .asyncMiddleware()
// это маленькая магия, которая позволяет писать "синхронные" функции типа function(req, res, next)
// еще не знаю, как ее лучше назвать...
app.post('/q/register', function(req, res) {
var mysql = database.spawnConnection();
// А можно реализацию beginSync?
mysql.beginSync();
@ybogdanov
ybogdanov / createEdge-async-example.js
Created August 21, 2011 22:51
examples of code which uses node-async vs node-sync with more complex logic
createEdge : function(e, callback)
{
var self = this, tryNum = 0,
isolateRetryAttempts = 20,
isolateRetryInterval = 1000;
callback = callback || function(){};
if (!(e instanceof Edge) || !e.isValid()) {
return callback(new Error("Invalid edge passed"));
@ybogdanov
ybogdanov / getUserSummary_nodejs_async.js
Created August 20, 2011 13:19
nodejs callbackDriven vs node-async vs node-sync
function getUserSummary(userId, callback)
{
async.parallel({
user : function(callback) {
db.users.findUserById(userId, callback)
},
tweets : function(callback) {
db.users.getTweets(userId, callback)
@ybogdanov
ybogdanov / rimraf-sync.js
Created August 9, 2011 21:51
Rimraf implementation using node-sync (node-fibers abstraction lib)
var path = require('path')
, fs = require('fs')
, Sync = require('sync')
// Return a future which just pauses for a certain amount of time
function realish (p) {
return path.resolve(path.dirname(fs.readlink.sync(fs, p)))
}
@ybogdanov
ybogdanov / gist:1010061
Created June 6, 2011 10:44
Using ES6 coroutines for synchronous yielding of asynchronous stuff
function someAsyncFunction(param, callback) {
setTimeout(function(){
callback(null, param); // result
}, 100)
}
Function.prototype.sync = function(param) {
this(param, function(e, result) {
Fiber.run(result); // substitute result instead of yield, resume current Fiber
@ybogdanov
ybogdanov / sync_integration.js
Created March 25, 2011 10:21
Example that shows how you can easily integrate node-sync to your app without refactoring
someObject = {
myNewMethod : function(a, b) // <-- no callback
{
console.log(Fiber.current); // Inside of fiber
if (a == 1)
throw "'a' cannot be 1"; // we can use throw here