Skip to content

Instantly share code, notes, and snippets.

View shishkin's full-sized avatar

Sergey Shishkin shishkin

View GitHub Profile
@shishkin
shishkin / Install-PdbToGac.ps1
Created October 21, 2010 16:56
PowerShell: Copies *.pdb files from current folder to GAC. Multiple assembly versions are not supported.
resolve-path *.pdb | % {
$pdb = $_
$fileName = split-path $pdb -leaf
$assembly = [io.path]::GetFileNameWithoutExtension($fileName)
$gac = "$env:windir\assembly\GAC_MSIL\$assembly"
if (test-path $gac) {
resolve-path "$gac\*" | % {
copy $pdb -destination $_ -force
}
}
@shishkin
shishkin / a-plus-abs-b.cs
Created November 3, 2011 09:39
a-plus-abs-b
namespace FunctionalCSharp
{
using System;
using Shouldly;
using Xunit;
public class Tests
{
@shishkin
shishkin / jsfiddle-log.js
Created December 7, 2011 12:59
jsfiddle-log.js
$(function(){
$('<pre id="results"></pre>').appendTo('body');
window.log = function(msg) {
if (typeof msg !== 'string') {
msg = JSON.stringify(msg, null, 2);
}
$('#results').append(msg + '\n');
};
});
@shishkin
shishkin / child.js
Created May 21, 2012 16:00
JSON descriptors
{
"@": {
"id": "http://example.org/my-obj",
"description": "This object is described with an embedded descriptor. Other JSON-Schema properties may follow."
},
"prop": "value"
}
@shishkin
shishkin / order.js
Created May 21, 2012 17:03
JSON templates
{
"order": {
"href": "http://...",
"method": "POST",
"template": {
"location": "",
"@location": {
"prompt": "Enter your postal code"
},
"pickupTime": "",
[
{
"title": "Far future",
"startsAt": "2013-01-01 00:00:00Z",
"accept": "http://...",
"decline": "http://..."
},{
"title": "Near future",
"startsAt": "2012-09-01 00:00:00Z",
"rsvp_status": "accepted",
@shishkin
shishkin / KataTennis.scala
Created October 20, 2013 15:44
Kata Tennis in Scala using pattern matching on sealed types.
package kataTennis
sealed trait Player
case object Player1 extends Player
case object Player2 extends Player
sealed trait Score {
def inc: Score = this match {
case Score0 => Score15
case Score15 => Score30
@shishkin
shishkin / FunctionalErrorHandling.cs
Created December 16, 2013 09:31
Functional error handling
using System;
using System.Collections.Generic;
using System.Linq;
using FSharpx;
using Microsoft.FSharp.Core;
using NUnit.Framework;
namespace FunctionalErrorHandling
{
public static class Extensions
@shishkin
shishkin / AskingActor.scala
Created January 3, 2014 22:31
Helper method for akka actor system to keep asking an underlying `service` actor continuously and replying to the original requester upon the underlying request completion.
import akka.actor._
import akka.pattern.ask
import scala.concurrent.duration._
import scala.concurrent.Future
import scala.concurrent.Promise
import scala.concurrent.ExecutionContext
class AskingActor(val service: ActorRef) extends Actor {
case class SomeCommand(id: String)
case class SomeEvent(id: String)
@shishkin
shishkin / semver.fs
Created August 30, 2014 09:18
Making incorrect version specifications impossible with F# typesystem
type VersionNumber =
| Major of major: int
| Minor of major: int * minor: int
| Patch of major: int * minor: int * patch: int
type Version =
| Release of VersionNumber
| PreRelease of VersionNumber * string
static member create (x) = Release (Major x)