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
import Random | |
data Brick = Line | LeftSquiggle | RightSquiggle | LeftStick | RightStick | Box | |
rand = Random.range 0 6 (constant 1) | |
brick n = if | n == 0 -> Line | |
| n == 2 -> LeftSquiggle | |
| n == 3 -> RightSquiggle | |
| n == 4 -> RightStick | |
| n == 5 -> LeftStick | |
| otherwise -> Box | |
brickText = asText <~ (brick <~ rand) |
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
import Random | |
data Brick = Line | LeftSquiggle | RightSquiggle | LeftStick | RightStick | Square | |
rand a = Random.range 0 6 (constant a) | |
brick n = if | n == 0 -> Line | |
| n == 2 -> LeftSquiggle | |
| n == 3 -> RightSquiggle | |
| n == 4 -> RightStick | |
| n == 5 -> LeftStick | |
| otherwise -> Square | |
main = asText <~ (brick <~ (rand 1)) |
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
time = lift (inSeconds . fst) (timestamp (fps 40)) | |
a dy = let c = filled blue (circle 10) | |
in collage 300 300 | |
[c |> move (0, 100 * cos dy)] | |
b = lift a time | |
main = b |
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
import Signal | |
import Mouse | |
cl = (clamp 100 200) <~ Mouse.x | |
reactiveCircle = (filled blue) <~ (circle <~ (toFloat <~ cl)) | |
main = lift (collage 300 300) (Signal.combine [reactiveCircle]) |
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
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) | |
} |
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
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 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 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 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 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); | |
} |