Skip to content

Instantly share code, notes, and snippets.

View mratsim's full-sized avatar
:shipit:

Mamy Ratsimbazafy mratsim

:shipit:
  • Paris
View GitHub Profile
@mashingan
mashingan / crud_web.nim
Last active June 11, 2023 00:45
Simplistic crud example using Jester and Nim
# This example using
# Nim: 0.18.0
# Jester: 0.2.1
# Using Jester >= 0.3.0 is preferrable if your Nim version > 0.18.0
# In case you're using Jester >= 0.3.0, look the syntax different
# in its example because it's not backward compatible
import db_sqlite, asyncdispatch, json, strformat, strutils, sequtils
import jester
@axic
axic / README.md
Last active December 15, 2021 03:14
ewasm “WRC20” token contract coding challenge

ewasm “WRC20” token contract coding challenge

This document describes a simple contract in pseudocode and gives a couple of test cases for it.

The challenge is designed to be fairly easy to implement in a language of choice, compiled to wasm and interacted with. It is loosely based on the ERC20 token standard, named "WRC20", where the W stands for WebAssembly.

External interface

The contract has two features:

/*
Copyright (C) 2018 Rich Talbot-Watkins
This file is part of VirtualBeeb.
VirtualBeeb is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
@apahl
apahl / nim_magic.py
Last active October 21, 2019 13:53
Nim cell magic for Jupyter and JLab Notebooks
"""
nim_magic.py
Jupyter cell magic for your favorite programming language.
This is now also available as a proper repo:
https://github.com/apahl/nim_magic
All further changes will be tracked there.
Requirements: Nim (https://nim-lang.org), nimpy (`nimble install nimpy`, thanks to @yglukhov for this great library!)
@tclementdev
tclementdev / libdispatch-efficiency-tips.md
Last active May 9, 2025 09:50
Making efficient use of the libdispatch (GCD)

libdispatch efficiency tips

The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).

My take-aways are:

  • You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.

  • Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse

import asyncdispatch
import asynctools
import docopt
import json
import nre
import os
import ospaths
import sequtils
import sha256/sha256sum
import strutils
import macros
macro lc(init, body): untyped =
# analyse the body, find the deepest expression 'it' and replace it via
# 'result.add it'
let res = genSym(nskVar, "lcResult")
proc detectForLoopVar(n: NimNode): NimNode =
if n.kind == nnkForStmt:
result = n[0]
@letientai299
letientai299 / mermaid-pandoc-guide.md
Last active April 28, 2025 22:01
Render PDF from markdown that using mermaid

Render PDF from Markdown that using mermaid

You will need:

This guide is based on Ubuntu, for other OS, use their package manager instead.

F1 = GF(21888242871839275222246405745257275088696311157297823662689037894645226208583)
G1 = EllipticCurve(F1,[0,3])
print(G1)
P1 = G1(1,2)
F2 = GF(21888242871839275222246405745257275088696311157297823662689037894645226208583^2,"i",modulus=x^2 + 1)
TwistB = 3*F2("9+i")^(-1)
G2 = EllipticCurve(F2,[0,TwistB])
@jarun
jarun / disassemble.md
Last active May 3, 2025 05:25
Guide to disassemble

prerequisites

  • Compile the program in gcc with debug symbols enabled (-g)
  • Do NOT strip the binary
  • To generate assembly code using gcc use the -S option: gcc -S hello.c

utilities

objdump