Skip to content

Instantly share code, notes, and snippets.

View iwilsonq's full-sized avatar
🏈
Huck it, chuck it, football!

Ian Wilson iwilsonq

🏈
Huck it, chuck it, football!
View GitHub Profile
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) => {
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 ->
/* the type system knows that the arguments and the return value are ints here */
let add = (a, b) => a + b;
type animal =
 | Dog
 | Cat
 | Octopus;
let animalToString = animal =>
 switch(animal) {
 | Dog => "dog"
 | Cat => "cat"
 | Octopus => "octopus"
func hasLanguageDelimiter(line string) bool {
if !strings.Contains(line, "```") {
return false
}
for _, lang := range languages {
if strings.Contains(line, lang) {
return true
}
}
@iwilsonq
iwilsonq / go-gist-1.go
Created May 7, 2018 05:07
A Go script generated gist.
// Unicode constants
const (
TAB = 9
SPACE = 32
NEWLINE = 10
)
func removeInitialNewline(content string) string {
if content[0] == NEWLINE {
content = content[1:]
@iwilsonq
iwilsonq / go-gist-0.js
Created May 7, 2018 05:07
A Go script generated gist.
function doSomething() {
return function(name) {
return 'Hello ' + name
}
}
@iwilsonq
iwilsonq / react-testing-17.js
Last active April 30, 2018 01:22
A Go script generated gist.
it('combines like and dislike methods', () => {})
@iwilsonq
iwilsonq / react-testing-16.js
Last active April 30, 2018 01:23
A Go script generated gist.
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) => (
@iwilsonq
iwilsonq / react-testing-15.js
Last active April 30, 2018 01:24
A Go script generated gist.
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>