Skip to content

Instantly share code, notes, and snippets.

@cabhishek
cabhishek / async.nim
Last active December 8, 2017 16:26
Async http in Nim
import os, strutils, asyncdispatch, httpclient
const baseUrl = "http://jsonplaceholder.typicode.com"
proc doRequest(url: string): Future[string] =
echo "Fetching contents from $1" % url
result = newAsyncHttpClient().getContent(url)
proc main() {.async.} =
var requests: seq[Future[string]] = @[]
@cabhishek
cabhishek / nim.txt
Last active September 15, 2017 16:29
Nim: An Introduction
What is Nim?
-----------
Nim is an incredibly fast systems and applications programming language that is expressive, extensible and fun to use.
Why Nim?
---------
Expressive
- Clean syntax
- Universal function call syntax (UFCS)
@cabhishek
cabhishek / promises.md
Created April 12, 2016 16:06 — forked from domenic/promises.md
You're Missing the Point of Promises

This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
 // the rest of your code goes here.