Skip to content

Instantly share code, notes, and snippets.

@jmgomez
jmgomez / List2.hs
Created Oct 26, 2019
List type implementation in Haskell
View List2.hs
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
View gist:8476420
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 / gist:6779191
Last active Dec 24, 2015
A simple download manager to download files via http. Feature to show percentage and resume downloads.
View gist:6779191
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 {
View TheMoviewDB.fs
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 =
View AdventCalendarTheMovieDV.fs
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 =
View AdventCalendarView.fs
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()
View AdventCalendarAppDelegate.fs
[<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();
View AdventCalendarModel.fs
module Model =
type Movie () =
member val Title = "" with get, set
member val ImagePath = "" with get, set
member val Overview = "" with get, set
View HelloCocosSharp
namespace HelloCocos
open System
open MonoTouch.UIKit
open MonoTouch.Foundation
open CocosSharp
type HelloScene () =
inherit CCLayerColor()
do
View blog-creando-un-typeprovider
namespace TypeProvidersGeeksMs
open System
open System.Reflection
open ProviderImplementation.ProvidedTypes
open Microsoft.FSharp.Core.CompilerServices
open Microsoft.FSharp.Quotations
You can’t perform that action at this time.