Skip to content

Instantly share code, notes, and snippets.

iffy / .gitignore
Last active April 17, 2024 07:19
Example using electron-updater with `generic` provider.
iffy / brew --config
Created March 2, 2011 17:40
brew --config
$ brew --config
HEAD: 511c404a2047f7148efec20332b98a3a52bf3cd4
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_LIBRARY_PATH: /usr/local/Library/Homebrew
Hardware: 8-core 64-bit nehalem
OS X: 10.6.6
Kernel Architecture: i386
iffy / Dockerfile
Created January 20, 2023 13:15 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
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 / nbody.nim
Created October 26, 2022 17:49
I wanted to see how Nim compared (readability and speedwise) with what's reported here:
## 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 /
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 / results.txt
Created November 5, 2018 16:22
Small, probably non-representative benchmark of JSON Changelog with SQLite
python 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 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 / 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 / dumpMem.nim
Last active February 13, 2019 19:07
Print out memory in Nim
import strutils
import terminal
template lowerHex(x:untyped):untyped =
proc charRepr(x:byte):char =
case x
of 32..126: result = chr(x)
else: result = '.'


$ 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
--- /tmp/orig.nim 2018-10-24 09:01:22.000000000 -0600
+++ /tmp/frommanual.nim 2018-10-24 09:00:51.000000000 -0600
@@ -1,7 +1,6 @@
-{.passL: "-lobjc".}
{.emit: """
-#include <objc/Object.h>
-@interface Greeter:Object
+#include <Cocoa/Cocoa.h>
+@interface Greeter:NSObject