Skip to content

Instantly share code, notes, and snippets.

View mbergal's full-sized avatar

Misha Bergal mbergal

View GitHub Profile
case class Water {}
object Wood extends Enumeration {
val Oak = Value
}
object Countries extends Enumeration {
val Many, Scotland, USA = Value
}
#r "FSharp.Data.TypeProviders.dll"
#r "System.ServiceModel"
open System.ServiceModel
open Microsoft.FSharp.Data.TypeProviders
open Microsoft.FSharp.Linq
type WSDL = Microsoft.FSharp.Data.TypeProviders.WsdlService< @"http://localhost:55322/api/ReviewRequestsWebService.svc">
$clipboardImage = [System.Windows.Forms.Clipboard]::GetImage()
$saveDirectory = 'c:\temp\captured'
if ( $clipboardImage -ne $null )
{
$existingImages = @()
$existingImages = ls 'c:\temp\captured'
if ( $existingImages.Length -eq 0 )
{
#r "System.Data.dll"
#r "FSharp.Data.TypeProviders.dll"
#r "System.Data.Linq.dll"
#r "FSharp.Data.TypeProviders.dll"
#r "FSharp.Core.dll"
#r "System.Data.Linq.dll"
open System
open System.Data
open System.Data.Linq
{
"contentType": "application/gliffy+json",
"version": "1.3",
"metadata": {
"title": "untitled",
"revision": 0,
"exportBorder": false,
"loadPosition": "default",
"libraries": [
"com.gliffy.libraries.ui.ui_v3.containers_content",
@mbergal
mbergal / gist:895860
Created March 31, 2011 05:23
Contexts in Python
def define_context( context, parent_contexts = None, verbose = False ):
if verbose:
print 'Defining context for \"%s\"' % context.__name__
if parent_contexts is None:
parent_contexts = []
def make_test_case_name( parent_contexts, context ):
if len(parent_contexts) > 0:
return '_'.join( [ x.__name__ for x in parent_contexts + [ context ] ] )
@mbergal
mbergal / gist:1130818
Created August 7, 2011 21:35
Array or args?
function foo( args )
{
if( !(promises instanceof Array) )
args = Array.prototype.slice.call(arguments);
...
}
@mbergal
mbergal / speclite.cs
Created October 3, 2011 08:06
RSpec like testing framework for .NET
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SpecLite
{
class Suite
{
@mbergal
mbergal / SingleThreadedSynchronizationContext.cs
Created February 10, 2012 08:15
SingleThreadedSynchronizationContext
class SingleThreadedSynchronizationContext : SynchronizationContext
{
private readonly Queue<Action> messagesToProcess = new Queue<Action>();
private readonly object syncHandle = new object();
private bool isRunning = true;
public override void Send(SendOrPostCallback codeToRun, object state)
{
throw new NotImplementedException();
@mbergal
mbergal / gist:2014754
Created March 11, 2012 02:52
STDEV of Putin's result
select distinct vp.ParentId, stdev( vr.Percents ) over (partition by vp.ParentId ) dev ,
( select FullName from VotingPlace where Id = vp.ParentId )
from VotingResult vr inner join VotingPlace vp on vr.VotingPlaceId = vp.Id where vr.Counter = '23' and vp.ElectionId = 'PRES2012' and vp.Type = 5
order by dev desc