Skip to content

Instantly share code, notes, and snippets.

View akimboyko's full-sized avatar
🙃

Akim Boyko akimboyko

🙃
View GitHub Profile
@controlflow
controlflow / gist:8072635
Last active January 1, 2016 01:28
Primary ctors
class ReverseForLookupItem : ForLookupItemBase
{
public ReverseForLookupItem([NotNull] PrefixExpressionContext context,
[NotNull] LiveTemplatesManager templatesManager,
[CanBeNull] string lengthPropertyName)
: base("forR", context, templatesManager, lengthPropertyName) { }
protected override IForStatement CreateStatement(CSharpElementFactory factory, ICSharpExpression expression)
{
...
@simon-weber
simon-weber / logutil.py
Created December 8, 2013 03:48
A context manager to temporarily disable all logging in Python that supports previous calls to logging.disable.
from contextlib import contextmanager
import logging
@contextmanager
def all_logging_disabled(highest_level=logging.CRITICAL):
"""
A context manager that will prevent any logging messages
triggered during the body from being processed.
:param highest_level: the maximum logging level in use.
@akimboyko
akimboyko / Nat.fs
Created October 17, 2013 05:47
Quiz from Functional Programming Principles in Scala by Martin Odersky, lecture 4.2 implemented on F# with unittests
//Provide an implementation of the abstract class Nat that represents non-negative integers
//
//Do not use standard numerical classes in this implementation.
//Rather, implement a sub-object and sub-class:
//
//class Zero : Nat
//class Succ(n: Nat) : Nat
//
//One of the number zero, then other for strictly positive numbers.
namespace Nat
@aras-p
aras-p / preprocessor_fun.h
Last active May 3, 2025 13:47
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@mausch
mausch / CSharpIterator.cs
Last active December 15, 2015 09:49
Anonymous iterators in C# with Ix
var hello = "";
var enumerable =
EnumerableEx.Create<int>(async Yield => {
await Yield.Return(100);
await Yield.Return(200);
hello = "hello world";
await Yield.Return(300);
});
Console.WriteLine(enumerable.ElementAt(1)); // 200
Console.WriteLine(hello); // empty
@glennblock
glennblock / app.csx
Created March 10, 2013 00:02
Nancy scriptcs sample
using System;
using System.Collections.Generic;
using Autofac;
using Nancy;
using Nancy.Bootstrapper;
using Nancy.Bootstrappers.Autofac;
using Nancy.Hosting.Self;
using Nancy.Routing;
public class Bootstrapper : AutofacNancyBootstrapper
using System;
using System.IO;
using System.Web.Http;
using System.Web.Http.SelfHost;
var address = "http://localhost:8080";
var conf = new HttpSelfHostConfiguration(new Uri(address));
conf.Routes.MapHttpRoute(name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
@vansha
vansha / DapperQueryHierarchy.cs
Created February 24, 2013 21:25
Querying complex object hierarchies with dapper.
public class Order {
public int Id { get; set; }
public DateTime OrderedAt { get; set }
public IList<OrderLine> OrderLines { get; set }
public Person Customer { get; set }
}
public class OrderLine {
public int Id { get; set; }
public int Count { get; set; }
@skalinets
skalinets / AutoNSubstituteDemo.cs
Last active February 29, 2024 02:46
AutoFixture + NSubstitute Demo
using NSubstitute;
using Ploeh.AutoFixture;
using Ploeh.AutoFixture.AutoNSubstitute;
using Ploeh.AutoFixture.Xunit;
using Xunit.Extensions;
namespace AutofixtureDemo
{
public class AutoNSubstituteDemo
{
@alexbeletsky
alexbeletsky / Feedback.js
Created December 18, 2012 19:07
Backbone.View done with TDD
var Feedback = Backbone.Model.extend({
url: '/feedback',
validate: function (attrs) {
var errors = [];
if (!attrs.email || attrs.email === '') {
errors.push({name: 'email', message: 'Please fill email field.'});
}