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 Lwt; | |
open Cohttp; | |
open Cohttp_lwt_unix; | |
let body = | |
Client.get(Uri.of_string("https://ianwilson.io/")) >>= (resp, body) => { | |
let code = resp |> Response.status |> Code.code_of_status; | |
let headers = resp |> Response.headers |> Header.to_string; | |
Printf.printf("Response code: %d\n", code); | |
Printf.printf("Headers: %s\n", headers); | |
body |> Cohttp_lwt.Body.to_string >|= (body) => { |
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 Lwt | |
open Cohttp | |
open Cohttp_lwt_unix | |
let body = | |
Client.get (Uri.of_string "https://ianwilson.io/") >>= fun (resp, body) -> | |
let code = resp |> Response.status |> Code.code_of_status in | |
Printf.printf "Response code: %d\n" code; | |
Printf.printf "Headers: %s\n" (resp |> Response.headers |> Header.to_string); | |
body |> Cohttp_lwt.Body.to_string >|= fun body -> |
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
/* the type system knows that the arguments and the return value are ints here */ | |
let add = (a, b) => a + 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
type animal = | |
| Dog | |
| Cat | |
| Octopus; | |
let animalToString = animal => | |
switch(animal) { | |
| Dog => "dog" | |
| Cat => "cat" | |
| Octopus => "octopus" |
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
func hasLanguageDelimiter(line string) bool { | |
if !strings.Contains(line, "```") { | |
return false | |
} | |
for _, lang := range languages { | |
if strings.Contains(line, lang) { | |
return true | |
} | |
} |
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
// Unicode constants | |
const ( | |
TAB = 9 | |
SPACE = 32 | |
NEWLINE = 10 | |
) | |
func removeInitialNewline(content string) string { | |
if content[0] == NEWLINE { | |
content = content[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
function doSomething() { | |
return function(name) { | |
return 'Hello ' + name | |
} | |
} |
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
it('combines like and dislike methods', () => {}) |
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
handleLike = id => { | |
this.props.likeComment(id, this.props.auth) | |
} | |
handleDislike = id => { | |
this.props.dislikeComment(id, this.props.auth) | |
} | |
renderComments() { | |
return this.props.comments.map((comment, i) => ( |
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
const Comment = props => { | |
const isLiked = props.likes.includes(props.currentUser.id) | |
const onClick = isLiked | |
? () => props.onDislike(props.id) | |
: () => props.onLike(props.id) | |
return ( | |
<div className="Comment"> | |
<h4>{props.author}</h4> | |
<p>{props.text}</p> |
NewerOlder