Skip to content

Instantly share code, notes, and snippets.

namespace TypeProvidersGeeksMs
open System
open System.Reflection
open ProviderImplementation.ProvidedTypes
open Microsoft.FSharp.Core.CompilerServices
open Microsoft.FSharp.Quotations
namespace HelloCocos
open System
open MonoTouch.UIKit
open MonoTouch.Foundation
open CocosSharp
type HelloScene () =
inherit CCLayerColor()
do
module Model =
type Movie () =
member val Title = "" with get, set
member val ImagePath = "" with get, set
member val Overview = "" with get, set
[<Register ("AppDelegate")>]
type AppDelegate () =
inherit UIApplicationDelegate ()
override val Window = null with get, set
// This method is invoked when the application is ready to run.
override this.FinishedLaunching (app, options) =
Xamarin.Forms.Forms.Init();
module View =
type MoviePage (movie:Model.Movie) as this =
inherit ContentPage()
do
let title = Label(Text = movie.Title, FontSize = 18., FontAttributes = FontAttributes.Bold, TextColor = Color.Accent)
this.Title <- movie.Title
let img = Image(Source=ImageSource.FromUri(Uri(movie.ImagePath)))
let overview = Label(Text = movie.Overview)
let layout = RelativeLayout()
module TheMovieDB =
open Model
let key = "YOUR_KEY"
let baseUrl = "http://api.themoviedb.org/3"
let baseImageUrl = "https://image.tmdb.org/t/p/w185/"
let [<Literal>] discoverUrl = """{ "page": 1, "results": [{ "adult": false, "backdrop_path": "/dkMD5qlogeRMiEixC4YNPUvax2T.jpg", "genre_ids": [28,12,878, 53 ],"id": 135397,"original_language": "en", "original_title": "Jurassic World", "overview":"overviewremoved", "release_date": "2015-06-12", "poster_path": "/uXZYawqUsChGSj54wcuBtEdUJbh.jpg","popularity": 88.551849, "title": "Jurassic World", "video": false,"vote_average": 7.1, "vote_count": 435 }],"total_pages": 11543, "total_results": 230847}"""
type MovieList = JsonProvider<discoverUrl>
let getMoviesByPage page = async {
let! response =
module TheMovieDB =
open Model
let key = "YOUR_KEY"
let baseUrl = "http://api.themoviedb.org/3"
let baseImageUrl = "https://image.tmdb.org/t/p/w185/"
let [<Literal>] discoverUrl = """{ "page": 1, "results": [{ "adult": false, "backdrop_path": "/dkMD5qlogeRMiEixC4YNPUvax2T.jpg", "genre_ids": [28,12,878, 53 ],"id": 135397,"original_language": "en", "original_title": "Jurassic World", "overview":"overviewremoved", "release_date": "2015-06-12", "poster_path": "/uXZYawqUsChGSj54wcuBtEdUJbh.jpg","popularity": 88.551849, "title": "Jurassic World", "video": false,"vote_average": 7.1, "vote_count": 435 }],"total_pages": 11543, "total_results": 230847}"""
type MovieList = JsonProvider<discoverUrl>
let getMoviesByPage page = async {
let! response =
@jmgomez
jmgomez / gist:6779191
Last active December 24, 2015 09:39
A simple download manager to download files via http. Feature to show percentage and resume downloads.
public interface IDownloadManager {
event DownloadManager.PercentageChangedDelegate OnPercentageChanged;
event DownloadManager.DownloadErrorDelegate OnDownloadError;
event DownloadManager.DownloadCompleteDelegate OnDownloadComplete;
Task DownloadFileAsync(string url, string localPath);
void AbortDownload();
bool IsTheSameFile(string expectedMD5, string filePath);
double Percentage { get; }
}
public class DownloadManager : IDownloadManager {
type MapRecord() =
let value = 0.2
abstract Latitude : double with get, set
default this.Latitude with get() = value and set(v) = ignore()
abstract Longitude : double with get, set
default this.Longitude with get() = 5.0 and set(v) = ignore()
type MapRecord2() =
@jmgomez
jmgomez / List2.hs
Created October 26, 2019 17:31
List type implementation in Haskell
data List2 a = End |Elem a (List2 a)
deriving (Show, Eq)
concatElem :: a -> List2 a -> List2 a
concatElem a End = Elem a End
concatElem a list = Elem a list
instance Monoid (List2 a) where
mempty = End