Skip to content

Instantly share code, notes, and snippets.

View retran's full-sized avatar
:octocat:

Andrew Vasilyev retran

:octocat:
View GitHub Profile
@retran
retran / test1.cs
Created October 9, 2012 14:13
Cyclomatic complexity test
// Cyclomatic complexity: 8. Maintanability: 80.
// Coupling: 2
using System;
class Foo
{
private readonly int _mode;
public Foo(int mode)
@retran
retran / gist:3992461
Created November 1, 2012 08:21
Чеклист
C#
LINQ
Core .NET Framework/CLR
Асинхронное программирование
SOA/SOAP/REST
WCF
WebForms
ASP.NET MVC
T-SQL
EF или nHibernate
@retran
retran / gist:4059114
Created November 12, 2012 12:33
Бредовый фейсбучный код
<iframe class="socialFaceBookLike" id="faceBookLikeFrame" src="http://www.facebook.com/plugins/like.php?locale=ru_RU&app_id=356393701111458&href=http%3A%2F%2Fwww.ozon.ru%2Fcontext%2Fdetail%2Fid%2F18096863%2F%3Fitem%3D18096859&show_faces=false&ref=like&font=verdana&send=false&layout=button_count" frameBorder="0" scrolling="no">
window.fbAsyncInit = function () {
// init the FB JS SDK
FB.init({
appId: '356393701111458', // App ID from the App Dashboard
channelUrl: '@ViewBag.PageHref', // Channel File for x-domain communication
status: true, // check the login status upon init?
cookie: true, // set sessions cookies to allow your server to access the session?
@retran
retran / gist:4059828
Created November 12, 2012 14:55
working facebook
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://ogp.me/ns/fb#">
<body>
<div id="fb-root"></div>
<script type="text/javascript">
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
@retran
retran / rabbitmq.cs
Last active December 19, 2015 07:09
Пример работы с RabbitMQ.
using System;
using System.Text;
using System.Threading;
using RabbitMQ.Client;
namespace RabbitMQExample
{
class Program
{
private const string ExchangeName = "exchange2";
@retran
retran / GameObjectContainer.cs
Last active August 29, 2015 14:12
incapsulate updates for object
using System;
using System.Collections.Generic;
using System.Dynamic;
class GameObjectContainer : DynamicObject
{
private readonly Dictionary<string, object> _values = new Dictionary<string, object>();
public object Instance { get; private set; }
@retran
retran / linq.cs
Last active August 29, 2015 14:14
LINQ lazy evaluation example
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static IEnumerable<int> Numbers()
{
int i = 0;
while (true)
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static void Print(IEnumerable<int> array)
{
foreach (var value in array)
{
@retran
retran / gist:706c3f35ef5d97b7f711
Last active August 29, 2015 14:18
object via closures
using System;
class Program
{
static Func<int, dynamic> Atom(dynamic value)
{
return index => value;
}
static Func<int, dynamic> Cons(Func<int, dynamic> a, Func<int, dynamic> b)
@retran
retran / generic.cs
Created May 22, 2015 12:47
Generic method with contraint
using System;
namespace GenericExample
{
interface IWithValue
{
int Value { get; set; }
}
class Foo : IWithValue