You can try to use my library:
[https://github.com/enthus1ast/nimMime](https://github.com/enthus1ast/nimMime)
it could be that you need to patch one or two things (pr welcome ;))
As far as I understand dylib this specifies in which shared library the
function is located. What happenes when you just choose the correct library?
Try client.recv(fileSize)
i've created a little example, with asyncnet and self signed keys:
[https://github.com/enthus1ast/nimSslExample](https://github.com/enthus1ast/nimSslExample)
@treeform it seems
[https://github.com/niv/websocket.nim](https://github.com/niv/websocket.nim)
also have wss support.
can the server rpc call the client?
What you also could do (since we're talking about the _key_ not the _value_
right?) write a hash proc for each of your keys and let the table use that hash
as its key.
[https://nim-lang.org/docs/hashes.html](https://nim-lang.org/docs/hashes.html)
There where issues when the rtl was dynamically linked. But i've not tried it
recently.
Maybe i do not understand correctly but for me it "just works"
coolLib.nim
proc abs*(x: int): float =
return 0.1
proc abs*(x: float): float =
return 0.2
proc coolProc*[T](x: T): T =
let a = abs(x)
echo a
Run
coolMain.nim
Why you read it in completely in the first place when you want to operate on
lines? When you mystring.split('n') you double the amounth of memory used. For
small files this seems ok but for larger ones your programm could explode. It's
much better to use the splitLines iterator as Stefan_Salewsk
what might work is if you have a
seq[tuple[elemType: EnumOfElem, ref: refToData]]
Run
then cast it based on the elemType. But not tested and might have other issues
i'm not aware of right now.
this simple beginning of a c/js form validator produces strange strings on the
js platform
import strutils
type
Error* {.exportc.} = enum
NoError, InvalidError
Valid* {.exportc.} = object
value: cstring
error: cstring
errorCode: Error
ok, i've pulled in the latest changes now it works.
I cannot say anything about protobuf, never used it, but your usage of nim's
async is wrong:
you could waitFor futures, but every waitFor drives its own async poll loop.
After the waitFor there is no async poll loop any more. waitFor is usefull when
you want to call async procs from non async c
I receive different types of object from network, packed as msgpack. Now i need
a construct that creates objects of the given type, to work with them further.
I'm struggeling to create a proc/template that does this in one call. My goal
is to get something like this:
var msgObj = u
The problem is that every serializer that i've tried (except json), cannot
downcast a serialized message to its base type.
json, the only serializer that does the job (but only on non ref types):
import json
type
MsgBase* = object of RootObj
version*: byte
cligen
([https://github.com/c-blake/cligen/](https://github.com/c-blake/cligen/))
how can i do:
./proc call "1. positional required" "2. positional required" "3.
positional optional"
# eg: ./proc call "*" "cmd.ping"
# eg: ./proc call "*" "os.shell" "ifconfig" --json
They're in strutils: parseInt(str) parseFloat(str) etc. To get a str
representation use $
They're in strutils: parseInt(str) parseFloat(str) etc. To get a str
representation use $
also crashes for me. It seems that waitForExit is buggy. Maybe open a bug
report in asynctools.
I've done this as well in the past, but it is a _SUPER HACKY_ solution (but
it's still working for me, in a non mission critical application).
proc callAsync*(cmd: string, arguments: seq
ref is also needed for async:
is not working:
import asyncdispatch
type Foo = object
num: int
proc dostuff(foo: var Foo): Future[void] {.async.} =
foo.num = 0
return
var foo = Foo()
waitFor foo.dostuff()
#Error: 'foo' is of t
thank you i'll try that.
keys is an iterator so either iterate over it with a for loop or use toSeq from
the sequtils module
I'am not sure what you want to do but, is a file descriptor just an integer?
The you could just send an integer.
If you want to send a struct/nim object, you can try:
await mysock.send(addr myobj, myobj.sizeof)
Run
Try this:
import os
from posix import onSignal, SIGINT
type
App = object
template cleanup(app: App) =
discard
proc start*(app: App) =
onSignal(SIGINT):
echo "Exiting: ", sig
app.cleanup
while true:
You have to specify a password for anonymous login.
This works for me:
import asyncdispatch, asyncftpclient
proc main() {.async.} =
echo "trying to connect..."
var ftp = new_async_ftp_client("speedtest.tele2.net", user =
"anonymous",
pass = "in ancients
your example works for me (on win10, Nim Compiler Version 1.1.0 [Windows:
amd64])
how would you then write inline pragmas? like:
foo(callback = proc() {.closure, gcsafe.} = echo "baa")
Run
I must say I do not see the benefit. the pragma above the proc reminds me of
this special python syntax, though
is the js file "readable by others" like dom96 stated:
"Note: Jester will only serve files, that are readable by others. On Unix/Linux
you can ensure this with chmod o+r ./public/css/style.css."
type
App = ref object
Run
should also work
Ok then I think you must use ProxyMatch instead of ProxyPass
Or maybe this works as well
RewriteRule ^/(*) http://localhost:8000/$1 [P,L]
Run
Looks like nimble is out of date. I would try to update nimble or nim tools in
general
The best/most advanced gui library for nim is afaik gintro (gtk).
I can also recommend web view for smaller things.
There is also cheatfate's asyncdns in asynctools repo. But have not tried it
lately.
Just a guess but maybe you have to compile with -d:ssl
`import tables type Person = ref object name: string age: int jobSal:
Table[string, int] # tell me how to declare proc newPerson() : Person = result
= new Person result.name = "A Name" result.age = 50 result.jobSal = {"A Job":
35000}.toTable # And tell me how to initialize it. proc print(me : Pe
yeah i must say the table examples are a little bit strange.
Here is some basic usage
import tables
var table: Table[string, string] # simple table with string as key, and
string as values
## Set entries, examples
table = {"key": "value", "key2": "value2"}.toTa
how can i force nimble to always install the newest version of a repository
when it was specified with an url?:
requires "https://url/repo.git@#head";
# nor
requires "https://url/repo.git#head";
Run
works properly.
.code0.xyz/sn0re/nimAsyncHttpTools.git #head"
requires "https://github.com/enthus1ast/flatdb #head"
Run
$ nimble install
Run
[david@eb quark]$ nimble install
Error: Could not read package info file in
/home/david/quar
done:
[https://github.com/nim-lang/nimble/issues/759](https://github.com/nim-lang/nimble/issues/759)
or with psutils module (
[https://github.com/johnscillieri/psutil-nim](https://github.com/johnscillieri/psutil-nim)
)
import psutil
echo net_if_addrs()
Run
I would create a browser cookie with a session id and also store the session id
somewhere on the server (database, memory, etc) then on every request check if
the transmitted session id is still in your datastore.
To invalidate session keys you could register a function with asyncCheck that
loo
well, as i've already written, i would not use globals to store sessions. I
would create a session object that holds all your data and pass it to every
procedure.
so feed the session table into your http callback:
import asynchttpserver, asyncdispatch, tables
type
[https://github.com/mrhdias/StatorHTTPServer](https://github.com/mrhdias/StatorHTTPServer)
can do this. It could be that
[https://github.com/andreaferretti/rosencrantz](https://github.com/andreaferretti/rosencrantz)
can do this as well, but never tried this with rosencrantz
How can i add a large documentation string to cligen's help output?
Thank you cblake i got it to work now!
dispatch(cli, doc = """
Foo
baa
""")
Run
before i tried:
const help = "some help"
dispatch(cli, doc = help)
Run
without noticing that not the content of the help string was printed
done a PR but not sure if this has unwanted side effects
thank you @mashingan for this snippet, i did not know that jester can websocket
nowadays. And the slice thing is a nice trick as well.
@mashingan it seems there is a offset error in the code (files are not
identically but shifted by some bytes at certain offsets)
IRC is far more accessible than discord. I would vote for bridging everything,
maybe create some more IRC channels then?
I have a strange issue with karax. When the text in the buttons are the same
(so both are "FOO") then i can not toggle back and forth. When the text in one
of them is changed, lets say
= "BAA"
Run
than toggle works.
Is this a bug?
include karax / prelude
I can force redraw with:
# ...
of 0:
text "Hello World!"
button(onclick = () => (comp.menu = 1; avoidDomDiffing())):
text "FOO"
of 1:
text "Other World!"
button(onclick = () => (comp.menu = 0; avoidDomDiffing())):
e) textbox
We've tried to still give you this "immediate mode" feeling.
Please try and report if its working for you (or not :) ). If it works well,
i'll create a pull request to merge upstream.
* Illwill with mouse support fork:
[https://github.com/enthus1ast/illwill]
German umlaute (öäüß) are also not supported :). And the funny thing is, on
windows typing them even crashes cmd.exe.
in a production app i would let the real webserver serve all the public/static
files. i've never used heroku, but i would assume you have some kind of
webserver configuration (.htaccess ?). The best option imho would be to change
the webserverconfig to share your public files.
export json
Run
in the api.nim also works
is @mratsim 's video also coming?
You must cast the pointer to a datatype.
I actually have modularized this (and some already made fun of the "smallest
module in nimble" ;) )
[https://github.com/enthus1ast/nimDbg](https://github.com/enthus1ast/nimDbg)
i think of adding this macro to the module, though:
import macros
macro decho*(ele
go for it! :)
(But be aware that there is
[https://nimble.directory](https://nimble.directory)/ already)
did not know dump, thanks for this!
just testet dump, it is not quite the same but still usefull imho:
dump("foo" & "123")
#"foo123" = foo123
decho("foo" & "123")
#"foo" & "123" => foo123
Run
Since the process streams has not implemented peak functionallity, it seems the
only way to do this is with threads.
Please format your question properly.
I'm still waiting too :)
[https://forum.nim-lang.org/t/5866](https://forum.nim-lang.org/t/5866)
Write karax code that generates a dom, add classes and id's etc. to your
elements , then you use css to style the dom elements.
you load the css in the html (not from karax), you could if you really like
create a link element from karax, but i would just write it in the html , then
when the dom
you can also consider creating shared object files and load them. Depending on
your use case this might be "dynamic" enough?
Maybe also have a look at cligen (
[https://github.com/c-blake/cligen](https://github.com/c-blake/cligen) )
I do not know your use case, but i think embedding a compiler is a little
overkill. Why can't you just include every required module? What are you'r
concerns?
Can you elaborate what your use case for the REST api is?
ok, being compiled or dynamic, it might be a bad idea to let users run
arbitrary code on your machine.
Better define some procedures users can call.
What kind of code the users will provide?
(If your goale is to build something like a nim playground have a look how nim
playground solves this i
Please try addr reallyWannaSendThis
Think it is called dqeues now
[https://nim-lang.org/docs/deques.html](https://nim-lang.org/docs/deques.html)
I think the "kernel" is more or less a proof of concept / experiment. If you
find it Interesting: play with it! I can imagine dom96 is open for pr's.
You should close the HttClient after each request to avoid running out of file
descriptors. Then try to make the requests with 'withTimeout' from the
asyncdispatch module. This way you can react when a request timesout. If you
still having troubles let me know. Later I can help you better (i'm o
i don't know much about arc but this is a common error on async. I would try to
change the type to a "ref T"
Code looks good to me.
you can drive your async loop with:
runForever()
Run
which boils down to:
while true:
poll()
Run
or you can
waitFor() # drives an async loop and also returns value.
Run
Then inside a
please share example code
btw.
when you wanna use udp in an async manner, i've written a small library that
can do so:
[https://github.com/enthus1ast/nimAsyncUdp](https://github.com/enthus1ast/nimAsyncUdp)
I use this pure library in one of my projects
[https://github.com/nitely/nim-regex](https://github.com/nitely/nim-regex)
http is a state less protocol so`connection open` is kind of a wrong term.
There is something like http connection reuse though, but afaik the
authentication process is the same.
So save the cookie data somewhere, maybe in a file. Then on a new http request,
read it in and set it to the http he
A simple example code for doing by hand:
# index.php (sorry for php here but i was lazy)
#
import httpClient
var client = newHttpClient()
# our "login", index.php just sets a cookie
let resp = client.get("http://127.0.0.1:80/ttt/index.php";)
That's a weird issue Indeed! Can you check if you have saved your file. Or that
you are compiling the correct one? (maybe "cat twitter.nim" reveals the issue?).
Also check your imports if there is anything fishy going on.
Then if you have triple checked and it's still not working, I would consid
nim-templates Front onionhammer is a good replacement IMHO.
Can you share a code example? I've never done multipart with cgi in nim, but
you maybe can just send a multipart msg from the browser and in one part you
send json.
There are several ways,
if the python app is fired only once, then maybe command line params and stdout
are enough for communication.
or both applications communicate with network sockets:
Socket one
nim -socket-> python
- python do this
- python do that
R
sure you can but then its not so simple to have an "eval loop"
socket1:
--connection->
--do this->
<--ok-some info---
--do that->
<--ok-some info---
Run
socket2:
-connection->
<-update this--
ok>
<-update that--
--
in the browser via js. Natively i'm not aware of any ready to use libraries for
webrtc. There is status-im/libp2p, though.
Some days ago i tried to scrape data from a game trading site and build a small
cookie handling "nim browser" (unfortunately the site was behind cloudflares
anti crawling engine und behaved funny).
import httpClient, asyncdispatch, httpclient, strtabs, uri, strformat,
strutils, os
you must poll with a very small timeout (eg. 20-50 miliseconds), while it works
i still recommend to do the network stuff in another thread and keep the gui
thread for gui stuff. The gui will feel much more responsive then.
yeah the UTF-8 input fix is still only in my head ...
We also should implement some programming learning games like "Turtle".
i usualy got for
* nginx as reverse proxy
* "nim-templates" whith plain asynchttpserver with a small "path matching"
library, since i find it easier to incoperate asynchttpserver into bigger
applications than jester (for example in the past it was not possible to use
websocket with jester s
I create a type in a macro which depends on other type ( i create the World
type) The issue is that the world type depends on other types (Store and
Entity) which are in the same typeblock. It seems that i cannot call the create
macro inside the type block to create the type. When i call the gen
Got it! :)
at first i dumped the ast:
World {.dumpAstGen.} = ref object
guids: GUID
storeHealthAble: Store[CompHealthAble]
storeDrawAble: Store[CompDrawAble]
storeNameAble: Store[CompNameAble]
Run
this works because the ast that generate
Also have a look at the sfml bindings. Sfml draws with gl.
I would add a description what your library is all about.
I just skimmed it and I saw vte. Ok I know that vte is the gnome terminal
emulator but what is your project doing with terminal?
Another way would be to port a RunPe to nim and run it directly from memory.
please speak english so that we all can participate
I could have a look at gintro (gtk) or wnim (winapi)
1 - 100 of 138 matches
Mail list logo