Skip to content

Instantly share code, notes, and snippets.

View shishkin's full-sized avatar

Sergey Shishkin shishkin

View GitHub Profile
@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)
package demo
object ScalaDsl {
/*
* Defining a simplistic model for the web app DSL
*/
case class HttpRequest(path: String, headers: Map[String, String], body: Option[String])
@shishkin
shishkin / pom.xml
Created March 22, 2015 12:57
Maven template for Scala+ScalaTest+ScalaCheck
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.shishkin</groupId>
<artifactId>testing-examples</artifactId>
<version>1.0-SNAPSHOT</version>
<name>${project.artifactId}</name>
<prerequisites>
@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 / order.js
Created May 21, 2012 17:03
JSON templates
{
"order": {
"href": "http://...",
"method": "POST",
"template": {
"location": "",
"@location": {
"prompt": "Enter your postal code"
},
"pickupTime": "",
@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 / Meetup.scala
Created October 6, 2015 15:57
Example code for the Singapore scala meetup
import scala.annotation.tailrec
def sum(nums: Seq[Int]) = fold(0)(nums, _ + _)
def filterEven(nums: Seq[Int]): Seq[Int] = filter(nums, _ % 2 == 0)
def filter(nums: Seq[Int], predicate: Int => Boolean): Seq[Int] =
fold(List[Int]())(nums, (l, i) => if (predicate(i)) l :+ i else l)
def square(nums: Seq[Int]): Seq[Int] = map(nums, i => i * i)
[
{
"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",