Skip to content

Instantly share code, notes, and snippets.

View chester89's full-sized avatar

Gleb Chermennov chester89

View GitHub Profile
@chester89
chester89 / swagger.json
Created May 5, 2021 15:18
Openapi input
{
"openapi": "2.0.1",
"info": {
"title": "MMS.TradingAccounts.Api",
"version": "1.0"
},
"servers": [
{
"url": "http://trading-accounts.uat.zfx.loc/trading-accounts/"
}
@chester89
chester89 / mapping.json
Created August 2, 2018 10:04
time_mapping.json
{
"index-name-2018.07.31": {
"aliases": {},
"mappings": {
"doc": {
"properties": {
"@timestamp": {
"type": "date"
},
"time": {
RestClient client = new RestClient();
RestRequest request = new RestRequest();
request.AddParameter("domain", domain, ParameterType.UrlSegment);
request.Resource = "{domain}/messages";
request.AddParameter("from", sender);
request.AddParameter("to", sendTo);
request.AddParameter("subject", "...");
request.AddParameter("text", "...");
request.Method = Method.POST;
public interface IBackoffStrategy
{
void RetryOnException(Action<Int32> intent, Int32 maxAttempts);
void RetryOnPredicate(Action<Int32> intent, Int32 maxAttempts, Func<Boolean> condition);
T RetryOnException<T>(Func<Int32, T> retrieve, Int32 maxAttempts);
T RetryOnOperationResult<T>(Func<Int32, T> retrieve, Int32 maxAttempts, Func<T, Boolean> retryCondition);
}
@chester89
chester89 / CustomGeocodeProxyProvider.cs
Created August 12, 2016 14:42
Better design for custom geocoding proxy
public class CustomGeocodeProxyProvider : IGeocodeProxyProvider
{
private Uri baseUri;
public CustomGeocodeProxyProvider(string baseUrl)
{
baseUri = new Uri(baseUrl);
}
public HttpWebRequest CreateRequest(string url)
@chester89
chester89 / NginxProxyRequestBuilder.cs
Created August 12, 2016 09:56
Nginx request builder for GeocodeSharp library
using System.Collections.Generic;
using System.Linq;
namespace GeocodeSharp
{
public class NginxProxyRequestBuilder : DefaultRequestBuilder
{
public NginxProxyRequestBuilder(string domain, bool isProtected = true) : base(domain, isProtected)
{
}
public abstract class RequestBuilderBase
{
protected readonly string _clientKey;
protected readonly UsageMode _mode;
protected readonly string _clientId;
protected readonly string _cryptoKey;
protected string _domain = "https://maps.googleapis.com";
protected const string _apiPath = "/maps/api/geocode/json?";
@chester89
chester89 / gitCommit.cs
Created May 19, 2016 13:02
Working with Git from .NET
static void GitCommit(String message)
{
var processPath = @"C:\Program Files (x86)\Git\bin\git.exe";
var filePath = @"D:\whatever\git-tests\text.txt";
File.AppendAllText(filePath, DateTime.UtcNow.ToString("s") + Environment.NewLine);
using (var process = new Process()
{
StartInfo = new ProcessStartInfo(processPath, string.Format(" commit -am \"{0}\"", message))
@chester89
chester89 / server.js
Last active January 31, 2016 12:53
Express.js error handling - not working
var http = require('http');
var express = require('express');
var winston = require('winston');
//set up Winston - not really relevant
var logger = ...
var app = express();
app.set('view engine', 'jade');
app.set('views', './views');
@chester89
chester89 / server.js
Last active January 31, 2016 12:54
Express.js error handling - working
var http = require('http');
var express = require('express');
var winston = require('winston');
var logger = ...
//setup Winston logger here, not really important
var app = express();
app.set('view engine', 'jade');
app.set('views', './views');