Skip to content

Instantly share code, notes, and snippets.

@iffy
iffy / .gitignore
Last active August 15, 2024 09:27
Example using electron-updater with `generic` provider.
node_modules
dist/
yarn.lock
wwwroot
@iffy
iffy / index.html
Created August 15, 2024 00:54
passkey test case
<html>
<body>
<button id="create-button">Create Passkey</button>
<button id="test-button">Test Passkeys</button>
<script>
async function addPasskey() {
let options = {
"rp": {
"name": "Passkey Demo"
@iffy
iffy / brew --config
Created March 2, 2011 17:40
brew --config
$ brew --config
HOMEBREW_VERSION: 0.7.1
HEAD: 511c404a2047f7148efec20332b98a3a52bf3cd4
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_REPOSITORY: /usr/local
HOMEBREW_LIBRARY_PATH: /usr/local/Library/Homebrew
Hardware: 8-core 64-bit nehalem
OS X: 10.6.6
Kernel Architecture: i386
@iffy
iffy / Dockerfile
Created January 20, 2023 13:15
Fly.io example demonstrating libsodium use failure. Launch with `fly launch` and see the logs for the error.
# -- Stage 1 -- #
FROM nimlang/nim:1.6.10-alpine@sha256:408ebac99ad2d170a59e7a09c10e82e7336cf71fa38c7a1322aaa598a54d32c2 as builder
WORKDIR /app
RUN apk update && apk add libsodium-static libsodium musl-dev
RUN nimble install -y libsodium
COPY . .
RUN nim c -o:testapp main.nim
RUN ls -al
# -- Stage 2 -- #
@iffy
iffy / nbody.nim
Created October 26, 2022 17:49
I wanted to see how Nim compared (readability and speedwise) with what's reported here: https://jott.live/markdown/py3.11_vs_3.8
## Compile for speed with `nim c -d:danger nbody.nim`
## Run `./nbody 10000000`
import std/os
import std/sequtils
import std/strformat
import std/strutils
import std/tables
from std/math import pow
@iffy
iffy / proposal.md
Created March 30, 2021 12:51
Idea for making Nim's `staticExec`/`staticRead` auditable

I agree that it's impossible for Nim to protect you if you're willing to compile other people's code.

However, it could be good if Nim provided a means for auditing calls to staticExec/staticRead. Or at least provided means for someone else to write an auditing library. I imagine something like the following could work and not be onerous either to the user or the compiler:

  1. nim c --strictStatic myfile.nim

This would fail on all instances of staticExec with a message like:

ERROR: Prevented execution of myfile.nim:staticExec("/bin/echo foo") Pass --allowStatic:'myfile.nim:staticExec("/bin/echo foo")' to allow it

@iffy
iffy / results.txt
Created November 5, 2018 16:22
Small, probably non-representative benchmark of JSON Changelog with SQLite https://blog.budgetwithbuckets.com/2018/08/27/sqlite-changelog.html
python testsqlite.py 10000 :memory: 0
6.65568494797 seconds to do 10000 records db=:memory:, triggers=False
6.66251087189 seconds to do 10000 records db=:memory:, triggers=False
6.69321203232 seconds to do 10000 records db=:memory:, triggers=False
python testsqlite.py 10000 :memory: 1
6.76699709892 seconds to do 10000 records db=:memory:, triggers=True
6.82708096504 seconds to do 10000 records db=:memory:, triggers=True
6.82913088799 seconds to do 10000 records db=:memory:, triggers=True
@iffy
iffy / equalproc.nim
Last active May 7, 2019 18:20
How to make proc `==`(a,b: Thing):bool for a variant object.
import sequtils
import strutils
import macros
import sugar
export macros
proc replaceNodes*(ast: NimNode): NimNode =
## Replace NimIdent and NimSym by a fresh ident node
##
## Use with the results of ``quote do: ...`` to get
@iffy
iffy / dumpMem.nim
Last active February 13, 2019 19:07
Print out memory in Nim
import strutils
import terminal
template lowerHex(x:untyped):untyped =
toHex(x).toLower()
proc charRepr(x:byte):char =
case x
of 32..126: result = chr(x)
else: result = '.'

v1

$ nim objc -r v1_manual.nim 
Hint: used config file '/Users/matt/lib/Nim/config/nim.cfg' [Conf]
Hint: system [Processing]
Hint: v1_manual [Processing]
CC: v1_manual
CC: stdlib_system
Error: execution of an external compiler program 'clang -c -w -I/Users/matt/lib/Nim/lib -o /Users/matt/.cache/nim/v1_manual_d/v1_manual.m.o /Users/matt/.cache/nim/v1_manual_d/v1_manual.m' failed with exit code: 1