This file contains hidden or 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
let mulVectors v1 v2 = List.fold2(fun s x y -> s + x * y) 0 v1 v2 | |
let mulMatr m1 m2 = | |
let rec mulMatr'' m1 m2 m3 = | |
let rec mulMatr' m1 m2 v = | |
match m1, m2 with | |
| h1::t1, h2::t2 -> mulMatr' t1 m2 ((mulVectors h1 h2)::v) | |
| [], _ -> List.rev v | |
| _ -> failwith "error in format" | |
match m1, m2 with | |
| h1::t1, h2::t2 -> let v = mulMatr' m1 m2 [] |
This file contains hidden or 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
open System.Net | |
open System.IO | |
let date = "2012-08-28" | |
let getDataAsync (url:string) = async{ | |
let r = WebRequest.Create(url) | |
let! resp = r.AsyncGetResponse() | |
use stream = resp.GetResponseStream() | |
use reader = new StreamReader(stream) | |
let data = reader.ReadToEnd() | |
return data} |
This file contains hidden or 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
async void AcquireFromCamera(object sender, RoutedEventArgs e) | |
{ | |
try | |
{ | |
var imageStream = await _cameraCapture.Shoot(); | |
var dto = new Dto(){ImageStream = imageStream}; | |
dto.Id = Guid.NewGuid().ToString(); | |
var file = await _fileHndlr.CreateFileAsync(dto.Id); | |
dto.ImageFilePath = file.Path; | |
_fileOperator.StoreStream(dto.ImageStream, file); |
This file contains hidden or 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
async void AcquireFromCamera(object sender, RoutedEventArgs e) | |
{ | |
try | |
{ | |
var imageStream = await _cameraCapture.Shoot(); | |
var dto = new Dto(){ImageStream = imageStream}; | |
_handler.ImageCaptured(dto); | |
Frame.Navigate(typeof(EditDataPage), dto.Id); | |
} | |
catch (Exception ex) |
This file contains hidden or 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
async void ImageCaptured(Dto dto) | |
{ | |
dto.Id = Guid.NewGuid().ToString(); | |
var file = await _fileHndlr.CreateFileAsync(dto.Id); | |
dto.ImageFilePath = file.Path; | |
_fileOperator.StoreStream(dto.ImageStream, file); | |
SaveNewDataItem(dto); | |
var dataItem = dataSource.GetItem(dto.Id); | |
StoreData(dataItem); | |
} |
This file contains hidden or 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 interface IRepository<TEntity> where TEntity : class | |
{ | |
IEnumerable<TEntity> Get( | |
Expression<Func<TEntity, bool>> filter = null, | |
Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null, | |
string includeProperties = ""); | |
TEntity GetById(object id); | |
void AddOrUpdate(TEntity entity); | |
void Delete(object id); |
This file contains hidden or 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
class mosquitto { | |
exec { 'apt-get update': | |
command => '/usr/bin/apt-get update' | |
} | |
package { 'python-software-properties': | |
ensure => installed, | |
require => Exec['apt-get update'], | |
} | |
exec { 'sudo add-apt-repository ppa:mosquitto-dev/mosquitto-ppa': | |
command => 'add-apt-repository ppa:mosquitto-dev/mosquitto-ppa', |
This file contains hidden or 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
[STAThread] | |
static void Main() | |
{ | |
_nui = new Runtime(); | |
var app = new Application(); | |
var window = new Window(); | |
InitializeNui(); //Initializing the Runtime object and opening video streams | |
CreateGUI(window); //Setting up a canvas to hold the RGB video and the image attached to the hand of captured person | |
var skeletonFrameReadyObservable = Observable.FromEventPattern(_nui, "SkeletonFrameReady"); | |
var trackedSkeletons = from ev in skeletonFrameReadyObservable |
This file contains hidden or 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
open System.Net.Sockets | |
open System.IO | |
open System | |
let port = 1234 | |
let clientProc i = | |
printfn "Connecting" | |
let client = new System.Net.Sockets.TcpClient("192.168.48.43", port) | |
let inew = i+uint64(1) | |
let sw = new StreamWriter(client.GetStream()) |
This file contains hidden or 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
let initMask length = List.init length (fun i -> if i = length - 1 then 1 else 0) | |
let addOne mask = List.foldBack (fun t (resList, c) -> (if (t = 1 && c = 1) then (0::resList, 1) elif (t = 0 && c= 0) then (0::resList, 0) else (1::resList, 0))) mask ([], 1) |> fst | |
let subsetsWhosSumsSatisfiesPredicate lst pred = | |
let rec work mask = seq{ | |
let sum, subSet = List.fold2 (fun (accSum, subSet) m l -> if m = 0 then (accSum, subSet) else (accSum + l, l::subSet)) (0, []) mask lst | |
if pred sum then | |
yield (List.rev subSet) | |
if List.exists (fun t -> t = 0) mask then | |
yield! work (addOne mask) | |
} |