This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// for a 2D array of pixels with some pixel type | |
var pixels = new TPixel[100,100]; | |
// turn into a sequence | |
var pixelSequence = pixels.Cast<TPixelType>(); | |
// group the sequence and turn to a dictionary, with pixel values as key and bin count as value | |
var histo = pixelSequence.GroupBy(px => px).ToDictionary(grp => grp.Key, grp => grp.Count()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#load "FsSampleImage.fsx" | |
open System.Collections.Generic | |
open FsSampleImage | |
let rows<'T> (samples: Map<Index,'T>) = | |
samples // extracts rows of samples from the "image" Map | |
|> Seq.sortBy (fun samp -> samp.Key.x) | |
|> Seq.groupBy (fun samp -> samp.Key.y) | |
|> Seq.map snd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum Orientation | |
{ | |
Transverse, | |
Sagittal, | |
Coronal | |
} | |
public static class MprGenerator<TPixel> | |
{ | |
// generates an MPR from a volume given an orientation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// | |
/// </summary> | |
public class ComplexGeometry : List<LineSegments> | |
{ | |
// stores the dictionary | |
Dictionary<Point, LineSegments> _segments = | |
new Dictionary<Point, LineSegments>(); | |
/// <summary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using System.Collections; | |
using System.Collections.Generic; | |
// width/height helpers | |
static int Width<TPixel>(this TPixel[,] pixels) => pixels.GetLength(0); | |
static int Height<TPixel>(this TPixel[,] pixels) => pixels.GetLength(1); | |
// range helper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
findstr /S "version" config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
findstr /S/R "public.interface" *.cs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string source = string.Format(@" | |
using System.ServiceModel; | |
namespace CreateTypeForSvcNamespace | |
{{ | |
[ServiceContract(Namespace=""{0}"",Name=""{1}"")] | |
public interface {1} {{ }} | |
}}", ns, name); | |
var asmName = Path.GetRandomFileName(); | |
var compilation = CSharpCompilation.Create(asmName, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.17; | |
contract Contract { | |
string ipfsHash; | |
function setHash(string x) public { | |
ipfsHash = x; | |
} | |
function getHash() public view returns (string x) { | |
return ipfsHash; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.5.12; | |
contract PhotoContestContract { | |
bytes32 _name; | |
address _owner; | |
bytes32[] _ipfsPhotoHashes; | |
address payable[] _submissionAddresses; | |
constructor(bytes32 name) public { | |
_owner = msg.sender; | |
_name = name; |
OlderNewer