Skip to content

Instantly share code, notes, and snippets.

@hvnsweeting
Created May 21, 2020 01:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hvnsweeting/2fa7654b9f68e1d8338fd295ddd96ee3 to your computer and use it in GitHub Desktop.
Save hvnsweeting/2fa7654b9f68e1d8338fd295ddd96ee3 to your computer and use it in GitHub Desktop.
nim c -d:ssl -r sum.nim 1 2 3 hihi "do ngoc"
import os
import sequtils
import strutils
import unicode
import algorithm
var sum = 0
for i in countup(1, 100_000_000):
sum = sum + i
echo sum
#echo 2**1000
echo 1/0
proc hello(name: string) : int =
echo "Hello world" & name
return 1
let x = hello("HVN")
echo x
import httpClient
var client = newHttpClient()
#let ip = client.getContent("https://httpbin.org/ip")
import json
#let jsonNode = parseJson(ip)
#echo jsonNode["origin"]
#
#
#let j = """[
# { "name": "HVN", "age": 30 },
# { "name": "Susan", "age": 29 }
# ]
#"""
#var jsonNode = parseJson(j)
#echo jsonNode
#for c in jsonNode.pairs():
# echo c
#
var contribs = client.getContent("https://api.github.com/repos/saltstack/salt/contributors")
var jsonNode = parseJson(contribs)
var names: seq[string] = @[]
for c in jsonNode:
names.add(c["login"].getStr())
names.sort(system.cmp)
echo commandLineParams()
echo names.mapIt(unicode.toUpper(it)).join(" ")
#
#let jsonNode = parseJson("""{"key": 3.14}""")
#doAssert jsonNode.kind == JObject
#doAssert jsonNode["key"].kind == JFloat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment