Skip to content

Instantly share code, notes, and snippets.

@hodzanassredin
hodzanassredin / phantom-valid.cs
Created November 30, 2011 23:07
phantom types for validation
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Phantoms
{
interface Validated { }
interface Unvalidated { }
@hodzanassredin
hodzanassredin / Prolog.hs
Created December 1, 2011 10:59
simple type level predicates in haskell
{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, UndecidableInstances #-}
module Prolog (Petja, Vasja, Serg, Father) where
data Petja = Petja
data Vasja = Vasja
data Serg = Serg
class Father a b where
isFather :: a -> b -> ()
isFather x y = ()
@hodzanassredin
hodzanassredin / CheckBoxList.cs
Created January 12, 2012 09:19
bug in system.web.dll
class CheckBoxList
protected override Control FindControl(string id, int pathOffset)
{
return this;
}
@hodzanassredin
hodzanassredin / test.cs
Created February 20, 2012 09:54
sharepoint dsl test
changeBindings.Add(new ChangeBinding(RootSite)
.Add(new ActivateFeature(true, HeMeSiteElementsFeatureId))
.Add(new ActivateFeature(false, HeMeSiteElementsPublishingImagesFeatureId))
.Add(new ActivateFeature(false, HeMeSiteElementsTopNavFeatureId))
);
//these changed will be applied for all sites
changeBindings.Add(new WildcardChanges()
.Add(new ChangePageLayoutFromOneToAnother("smBlankIntroPage.aspx", "hemeBlankIntroPage.aspx", true))
@hodzanassredin
hodzanassredin / search.py
Created February 22, 2012 10:03
python search in yandex
#pip install BeautifulSoup
#pip install requests
from BeautifulSoup import BeautifulSoup
import requests
url = 'http://yandex.ru/yandsearch?text=%(q)s'
payload = {'q': 'Python',}
r = requests.get(url % payload)
soup = BeautifulSoup(r.text)
titles = [item.text for item in soup.findAll('div', attrs={'class': 'b-serp-item__text'})]
for t in titles:
@hodzanassredin
hodzanassredin / vk-oauth.cs
Created March 15, 2012 23:22
vkontakte oauth authorization for asp.net mvc
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Net;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Web;
@hodzanassredin
hodzanassredin / geometry.cs
Created April 3, 2012 16:28
how to represent geometry in classes
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OopGeometry
{
class Program
{
@hodzanassredin
hodzanassredin / Slice.cs
Created July 19, 2012 11:38
Slices for c3 arrays
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Defer
{
@hodzanassredin
hodzanassredin / ComposableSlicesTest.cs
Created July 19, 2012 11:40
Slices rewriten in oomposable classes just to check
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Defer
{
public abstract class Projection<TV,TK>
{
@hodzanassredin
hodzanassredin / SliceSRP.cs
Created July 20, 2012 06:47
slice implemented without generics in srp manner
using System;
namespace Defer
{
public class Slice
{
int i1, i2, step, len, cycles;
public Slice(int length, int ini1 = 0, int ini2 = -1, int inStep = 1, int inCycles = 1)
{
System.Diagnostics.Debug.Assert(inStep > 0);
System.Diagnostics.Debug.Assert(inCycles > 0);