Tuesday Picks 003

Read more →

Tuesday Picks 001

Read more →

Friday Picks 046

Read more →

Learn Nim: Create a README Template Downloader

Create a command-line tool which downloads a README template for your coding projects Why Nim? Nim is a statically typed systems programming language. Nim generates small, native dependency-free executables. The language combines a Python-like syntax with powerful features like meta-programming. Nim supports macOS, Linux, BSD, and Windows. The language is open-source and has no corporate affiliation. Nim compiles to multiple backends, for example, C, C++, or JavaScript. The ecosystem and community are small, but the language has reached its first stable release.
Read more →

Run Nim Docker Container as Non Root

Today I improved my Nim web application by running the docker container as non=root-user: ## base imageFROMnimlang/nim:1.0.4-regular## install dependenciesRUN apt-get update && \ apt-get install -y --no-install-recommends libpq-dev netcat-openbsd## set working directoryWORKDIR/usr/src/app## add userRUN addgroup --system nim && adduser --system --group nimRUN chown -R nim:nim /usr/src/app && chmod -R 755 /usr/src/app## Nim environmentENV NIM_ENV=production ENV NIMBLE_DIR=/home/nim/.nimbleENV PATH=$PATH:/home/nim/.nimble/bin## copy entrypoint, make executableCOPY ./entrypoint.sh .RUN chmod +x entrypoint.sh## install dependencies, bundle assets, compileRUN nimble refresh && nimble install nimassets jesterCOPY .
Read more →

Feat Accomplished: Nim Jester App Finished

Read more →

How to Serve Static Files With Nim and Jester on Heroku

The Problem Let’s say that you create a simple web application with the Nim Heroku Buildpack. Project structure: ├── nim_heroku.nimble ├── Procfile ├── src │ ├── nim_heroku │ ├── nim_heroku.nim │ └── views │ └── general.nim ├── static_dir │ ├── favicon.ico │ └── style.css └── tags 3 directories, 8 files Bin file (src/nim_heroku.nim): import jester, asyncdispatch, os, strutils import views/general var settings = newSettings() if existsEnv("PORT"): settings.port = Port(parseInt(getEnv("PORT"))) settings.staticDir = ".
Read more →

TIL: PostgreSQL Insert ID Only Works With id as Primary Key

I’ve created a database table for my PostgreSQL database with Nim: import db_postgres, os ## some code proc setup*(database: Database) = database.db.exec(sql""" CREATE TABLE IF NOT EXISTS Url( shortcode SERIAL PRIMARY KEY, orig_url VARCHAR(255) NOT NULL ); """) ## more code My primary key is shortcode as a SERIAL data type. That means the shortcode column automatically increments. I want to insert data into the database and return the generated ID for the row.
Read more →

Refactoring My Nim sqlite DB to Postgres

Today I’ve spent all my coding time on re-factoring my sqlite3 database to postgres. Nim and Jester (a web framework) ship with inbuilt sqlite3 features. I couldn’t get them working within Docker. I know how to use Docker and Postgres. Plus, the wrapper library for Nim around SQL databases offers a consistent API. My re-factoring only needed minimal changes. The project is still in flux. And I have some annoying errors with Nim and SQL queries.
Read more →

Working on Nim URL Shortener With Docker

Read more →

Sign up for the newletter!

powered by Buttondown