😶🌫️
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
| namespace Samples.FSharp.StringTypeProvider | |
| open System | |
| open System.Reflection | |
| open Samples.FSharp.ProvidedTypes | |
| open Microsoft.FSharp.Core.CompilerServices | |
| open Microsoft.FSharp.Quotations | |
| [<TypeProvider>] | |
| type StringTypeProvider(config: TypeProviderConfig) as this = |
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 | |
| open Config | |
| open MyApp.Messages | |
| [<EntryPoint>] | |
| let main argv = | |
| let bus = busBuilder() | |
| { Value = "Hey from F#" } | |
| |> bus.Send |
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
| namespace FSharpWeb.Controllers | |
| open System.Web.Mvc | |
| open Services | |
| type CustomersController(service: CustomerService) = | |
| inherit Controller() | |
| member x.Index () = | |
| x.View(service.GetCustomers ()) |
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
| process.stdin.setEncoding('utf8'); | |
| var what = process.argv[2] || ''; | |
| process.stdin.on('readable', function () { | |
| var chunk = process.stdin.read(); | |
| if (chunk) { | |
| var obj = JSON.parse(chunk); |
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
| var dateItems = [].slice.call(document.querySelectorAll('.log-date span')); | |
| var dates = dateItems.map(function (item) { | |
| return { span: item, date: Date.parse(item.getAttribute('title')) }; | |
| }).map(function (item, index, arr) { | |
| var next = arr[index + 1] || item; | |
| return { | |
| span: item.span, | |
| date: item.date, | |
| next: next |
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
| var request = require('requst'); //npm install request | |
| var assert = require('assert'); //build in to Node.js | |
| request('http://httpstat.us/200', function (err, res, body) { | |
| assert.equal(res.statusCode, 200, 'Expected a 200 response'); | |
| }); |
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
| var add = function (x, y) { | |
| return x + y; | |
| }; | |
| var log = console.log; | |
| var add1 = add.length <= 1 ? add(1) : add.bind(null, 1); | |
| var three = add1.length <= 1 ? add1(2) : add1.bind(null, 2); | |
| var four = add.length <= [2].length + 1 ? add(2, 2) : add.bind(null, 2, 2); | |
| log(three); | |
| log(four); |
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
| var express = require('express'); | |
| var app = express(); | |
| get '/404' send(404) 'Not Found' | |
| get '/foo' with (req, res) { | |
| res.json({ foo: 'bar' }); | |
| } |
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 get = macro { | |
| rule { $path:lit $do $res:lit } => { | |
| app.get($path, function (req, res) { | |
| res.$do($res); | |
| }); | |
| } | |
| rule { $path:lit $do:ident($sc:lit) $res:lit } => { | |
| app.get($path, function (req, res) { | |
| res.$do($res); | |
| res.status($sc); |
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
| macroclass typedef { | |
| pattern { $x:ident : $type:ident } | |
| pattern { $x:ident : $type:lit } | |
| } | |
| let function = macro { | |
| rule { $name ($params:typedef ...) { $body ... } } => { | |
| function $name ($params$x ...) { | |
| $(if (typeof $params$x !== typeof $params$type) { | |
| throw new Error('Found type ' + (typeof $params$x) + ' but expected ' + typeof $params$type); |