import markdown | |
import std / strutils | |
echo markdown(""" | |
```nim | |
echo "hello" | |
```* | |
""".replace('*', ' '), config=initGfmConfig()) | |
#[ | |
<pre><code class="language-nim">echo "hello" |
# minib (a mini nimib) | |
import strformat, macros | |
import tempfile | |
proc dup*(oldfd: FileHandle): FileHandle {.importc, header: "unistd.h".} | |
proc dup2*(oldfd: FileHandle, newfd: FileHandle): cint {.importc, header: "unistd.h".} | |
macro toStr*(body: untyped): string = | |
(body.toStrLit) |
# compile with: nim c --app:lib -d:release add.nim | |
# examine with: peni info -a add.dll | |
# see https://forum.nim-lang.org/t/9446 | |
proc add*(num1, num2: int): int {.stdcall, exportc, dynlib.} = | |
num1 + num2 |
sudo apt-get update | |
sudo apt-get install libpangocairo-1.0-0 | |
sudo apt-get install libblas-dev liblapack-dev |
A common issue while trying to use https://github.com/Vindaar/ggplotnim on Windows is the fact that it is not easy to satisfy the full list of dll for Cairo.
In an issue (Vindaar/ggplotnim#57) and related gist (https://gist.github.com/Vindaar/6cb4e93baff3e1ab88a7ab7ed1ae5686) one of the best options seems to be to install emacs and add its bin folder to the path.
Using a dll dependency analyzer (https://github.com/lucasg/Dependencies, found through SO: https://stackoverflow.com/questions/7378959/how-to-check-for-dll-dependency), I was able to list all the dlls required, which are the following 17 files (including libcairo-2.dll, total around 9MB).
So another solution instead of installing emacs is to download the dlls (see link to libcairo-deps.rar in comment) and copy them in ~\.nimble\bin
.
List of all recursive dependencies for libcairo-2.dll:
- libbz2-1.dll
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta content="text/html; charset=utf-8" http-equiv="content-type"> | |
<title>world.nim</title> | |
<meta content="width=device-width, initial-scale=1" name="viewport"> | |
<link rel='stylesheet' href='https://unpkg.com/normalize.css/' type='text/css'> | |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/kognise/water.css@latest/dist/light.min.css"> | |
</head> | |
<body> |
## iso week number | |
## see https://en.wikipedia.org/wiki/ISO_week_date#Calculating_the_week_number_of_a_given_date | |
import times | |
type | |
WeekRange = range[1 .. 53] | |
proc lastWeek(year: int): WeekRange = | |
## The long years, with 53 weeks in them, can be described as any year starting on Thursday and any leap year starting on Wednesday | |
let firstWeekDay = initDateTime(1.MonthDayRange, mJan, year, 0, 0, 0).weekday |
# git clone https://github.com/nim-lang/packages.git | |
# then compile and run this file in the git repo | |
import os, parsecsv, json, strutils | |
proc runCommand(command: string) = | |
let errorCode = os.execShellCmd(command) | |
if errorCode != 0: | |
echo "error running command: " & command | |
quit(1) | |
else: |