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 / 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
@retran
retran / batch.cs
Last active August 29, 2015 14:25
public static IEnumerable<IEnumerable<T>> Batch<T>(this IEnumerable<T> collection, int batchSize)
{
var list = collection.ToList();
if (list.Any())
{
yield return list.Take(batchSize);
}
while (list.Any())
using System;
namespace clojure_test
{
class Program
{
static void Main(string[] args)
{
var eval = clojure.lang.RT.var("clojure.core", "load-string");
def createEventHandler(value):
def eventHandler():
print(value)
return eventHandler
button1Handler = createEventHandler("FUCK")
button2Handler = createEventHandler("SHIT")
button1Handler()
@retran
retran / with.cs
Created September 24, 2015 11:57
using System;
using System.Collections.Generic;
using System.Linq;
namespace WithExample
{
static class IEnumerableExtension
{
public static IEnumerable<T> With<T>(this IEnumerable<T> collection, Func<IEnumerable<T>, IEnumerable<T>> proc)
{
(defun throw-zigulka ()
(interactive)
(dolist (font-family (font-family-list))
(let ((str font-family))
(insert (propertize (concat "o/ o/ o/ o/ o/ o/ o/ o/ o/ o/ o/ o/ o/ o/ (" str ")")
'face `((:family ,font-family))))
(newline))))