Skip to content

Instantly share code, notes, and snippets.

View chester89's full-sized avatar

Gleb Chermennov chester89

View GitHub Profile
@chester89
chester89 / example.cs
Created April 7, 2014 20:52
Getting a list of issues from Github closed within date range using Octokit
var credentials = new Credentials(login, password);
var credentialStore = new InMemoryCredentialStore(credentials);
var productHeaderValue = new ProductHeaderValue("MyAmazingApp");
var connection = new Connection(productHeaderValue, credentialStore);
var apiConnection = new ApiConnection(connection);
var issues = new IssuesClient(apiConnection);
var closedSince1Point2 = issues.GetForRepository("ownerLogin", "repoName", new RepositoryIssueRequest()
@chester89
chester89 / gist:5d6a62633abab3969c32
Created May 18, 2014 22:32
List all objects in a bucket using Google Storage API
try
{
// Create the service.
var service = new StorageService(new BaseClientService.Initializer
{
ApplicationName = "TestinInTheCloud",
ApiKey = "API-KEY"
});
// Run the request.
@chester89
chester89 / LatestPoint.cs
Created June 1, 2015 20:12
RavenDb index involving NodaTime functionality
from epi in docs.ExchangePoints
select new
{
Value = epi.FixedAt.AsZonedDateTime().ToOffsetDateTime().Resolve()
};
from result in results
group result by 0
into g
select new
@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');
@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 / 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))
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 / 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)
{
}
@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)
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);
}