Re: copy & move Access is Denied

2020-05-04 Thread sky_khan
copyFile("C:\Users\andys-pc\Downloads\test.filename","E:TEST.FILENAME") 


Re: Code cleanup suggestions: ctors

2020-02-25 Thread sky_khan
> So I realized ptr of Husband can be a key to a Table, ref can't.

Yes, it can

[https://nim-lang.org/docs/tables.html#basic-usage-hashing](https://nim-lang.org/docs/tables.html#basic-usage-hashing)


Re: Why whitespace?

2020-02-19 Thread sky_khan
I dont like at all when I get this answer myself but ...

Nim is open source with MIT license. If you cant live without tabs, fork it.


Re: Newbie question: Why am I getting the too many variables error on my loop index variable?

2020-01-13 Thread sky_khan
Sorry for being lazy earlier and for my poor English. What I meant was this:


import strutils

var
  file = """
Hello,World
Key,Value
  """

for line in file.split("\n"): # iterator returns string
  var data = line.split(",") # proc returns seq[string]
  # but there is no version of split you can use as "for myKey, myValue in"
  if data.len() == 2:
echo data[0]," = ", data[1]



Run


Re: stdlib pegs: Accessing optional subexpressions

2020-01-12 Thread sky_khan
Afaik, stdlib peg is designed for nim compiler itself and somewhat limited. So, 
you may consider using [npeg :](https://github.com/zevv/npeg)


import npeg

let parser = peg("example"):
  example <- >?word * >?number
  word <- +Alpha
  number <- +Digit

echo parser.match("abc").captures # @["abc", ""]
echo parser.match("123").captures # @["", "123"]


Run


Re: Newbie question: Why am I getting the too many variables error on my loop index variable?

2020-01-12 Thread sky_khan
if that "split(',')" is from strutils, it returns seq[string], not tuple. I 
guess you need to use something like this: 


for line in readFile(day02PathAndName):
  var data = line.split(',')
  if data.len() == 2:
myKey = data[0]
myValue = data[1]
result...
  else:
echo "Error in input: ", line


Run


Re: Write Nim by using only 'v'

2019-12-31 Thread sky_khan
Nope, I dont really think its a joke. I dont think its has any purpose either. 
I like power of macros, introspection of code etc as much as next man but I'd 
rather like to see more useful thing, anything.


Re: Write Nim by using only 'v'

2019-12-31 Thread sky_khan
ok, great but why ? its not even April 1st ?


Re: Sqlite: unfinalized statements error

2019-12-29 Thread sky_khan
You better know the tool you're working with. Check "INSERT OR IGNORE ..." and 
"INSERT OR REPLACE..." statements.


Re: hello world issues

2019-12-28 Thread sky_khan
If you're sure that you've installed 64 bit version of mingw, probably you've 
already had 32 bit one from previous installation of some other IDE/tool and it 
takes precedence on your system path.


Re: confirming the purpose of `$` stringify operator

2019-12-13 Thread sky_khan
I'm nobody but I would say if your types are expected to be a transfer format, 
like json or xml or anything database or network related etc I would expect 
them stick to the format. Also It may help if you specify which libraries 
you're talking about.


Re: Using discard for comments

2019-12-06 Thread sky_khan
I think its a documentation artifact from early years of Nim when it didnt not 
have multiline comments. I dont think its necessary anymore. Documentation 
should better be fixed though.


Re: Any possibility of a near term Lazarus/C#-like GUI-designer IDE?

2019-12-04 Thread sky_khan
> Has there been any thought of adapting it to self-reflectively work with Nim?

Well, I had played with this idea a bit. Then I've realized I cant reconcile 
their exceptions. I had to wrap all inter-calls with expensive try-except 
blocks or your program will crash at first run-away exception.


Re: How to create a trojan and reverse shell with NIM

2019-12-01 Thread sky_khan
I would help him. He just needs to send me his IP and root password and I'll 
show him how.


Re: Resolve ambiguous call to open

2019-11-14 Thread sky_khan
let f = system.open("another.txt")


Re: Can I "prune" directories with walkDirRect?

2019-11-14 Thread sky_khan
walkDirRec does recursively search all files/dirs. If you dont want to enter 
some directories, I guess you need to implement your own recursive "walking" 
logic with walkDir, then you can have an "exclude_dirs : seq[string]" variable 


Re: A taxonomy of Nim packages

2019-11-09 Thread sky_khan
> I find it complementary from nimble.directory

IMO, If nimble.directory was showing/grouping projects by using tags in 
packages.json, curated list would be much less needed.


Re: Get contents of directory at given path

2019-11-09 Thread sky_khan
like this? 
[https://rosettacode.org/wiki/Walk_a_directory/Recursively#Nim](https://rosettacode.org/wiki/Walk_a_directory/Recursively#Nim)


Re: Equivalent of Python's sys.getsizeof

2019-10-24 Thread sky_khan
Well, looking at compiler source, it seems like it is uses 
4*sizeof(pointer)+string.length bytes for strings (2*sizeof(pointer) if string 
is empty) but as I said, these are hidden from user.


Re: Equivalent of Python's sys.getsizeof

2019-10-24 Thread sky_khan
String is built-in managed type. Afaik, it's internal structure is not public. 
It's an implementation detail. Why do you need that ?


Re: pegs: match without guessing openarray size

2019-10-22 Thread sky_khan
To be honest, I've never used pegs in Nim before but looking at it's source, it 
has MaxSubpatterns = 20. So, I guess either you can define matches as 
newSeq[string](20) or you can use this,


if fixedString =~ peg"cd\s+{\D}\:":
echo matches[0]


Run

without defining matches at all, because it injects matches variable itself, if 
there is none at current scope.


Re: pegs: match without guessing openarray size

2019-10-21 Thread sky_khan

let
  fixedString = "cd   C:\\something\\sometimes\\someone"
  result = fixedString.findAll(peg"cd\s+{\D}\:")
 echo result


Run


Re: How to create new operator ?

2019-10-20 Thread sky_khan
I dont know how 0...5 works but 0To5 is not valid syntax.

0.To(5) or 0.To 5 works though.


Re: Nim for enterprise software development

2019-10-19 Thread sky_khan
Latest versions of postgresql are 64bit only. So, you need to use 64bit version 
of Nim. Also libpq.dll is not enough because it depends some other dlls in it's 
installation. So you better add "bin" folder of postgresql's installation to 
PATH environment variable.


Re: Inherited objects get "casted" when on an array of it's parent type

2019-10-09 Thread sky_khan
thats because "proc" is static binding. Check this: 
[https://nim-lang.org/docs/manual.html#multiminusmethods](https://nim-lang.org/docs/manual.html#multiminusmethods)


Re: Using NIM for sending emails through Outlook app

2019-10-09 Thread sky_khan
I havent used COM for a long time and I dont have outlook installed but 
examples here should help ?

[https://github.com/khchen/winim/tree/master/examples/com](https://github.com/khchen/winim/tree/master/examples/com)


Re: Global proc/method to print a type and its properties?

2019-10-03 Thread sky_khan
`for v in users: for name, value in fieldPairs(v[]): echo(name, "=", value) `

Run


Re: [RFC] Why use Nim?

2019-09-30 Thread sky_khan
If you use only OS native widgets you'll have multiple-platform library, not 
cross-platform. You'll have to deal with every single detail for each widget on 
each OS you support. If a widget is not exists on one of your target OSes or 
behaves completely different, tough luck. Thats why Lazarus is still behind on 
Mac front.


Re: Convincing my friend about Nim

2018-12-31 Thread sky_khan
Tell him he is right on all matters.

[https://tanndera.com/pin/the-secret-to-eternal-happiness](https://tanndera.com/pin/the-secret-to-eternal-happiness)/


Re: Should we get rid of style insensitivity?

2018-11-19 Thread sky_khan
**I don 't want a vote**

I agree with GULPF too. You should work on stability, Would you please stop 
chasing perfection and start hardening what you already have ? 


Re: On exceptions (again)

2018-07-19 Thread sky_khan
Trying to get rid of GC and now exceptions... I'm afraid that Nim will become a 
Rust dialect eventually.


Re: db_mysql & threads

2018-03-17 Thread sky_khan
> can of worms ?

Yes, according to this : [MySql 
Reference](https://dev.mysql.com/doc/refman/5.7/en/c-api-threaded-clients.html) 
"Multiple threads cannot send a query to the MySQL server at the same time on 
the same connection"

So you'll have to serialize your queries anyway, what's the point then?


Re: feedback on macro

2017-11-29 Thread sky_khan
Are you sure if this works ? Did you try it ? Because I dont see how this 
approach can work unless you embed the compiler in your application.


Re: Forum Request for Enhancement: Fix the "Back Button" in Search

2017-11-11 Thread sky_khan
It may be related to your add-ons or something because i dont have such problem 
with same specs (Firefox 56.0.2, 64-bit, Windows 10)


Re: floating point output formating

2017-11-07 Thread sky_khan
"the index" is good to have but it is helpful **only** if you already know what 
you're searching for. Otherwise if you dont have any clue about what you are 
searching, **how** certain things are done in Nim, It is only a huge pile of 
unorganized identifiers.

BTW, could anyone direct me to how index is built/generated ? I hope it is not 
manual work. I have something in mind I wish to explore. 


Re: Unhandled exception: key not found [KeyError]

2017-10-19 Thread sky_khan
@Araq, English is not my native language. When I started programming as a 
child, my all English knowledge was consisting of "What is this? This is a 
pencil" So I learned programming by reading and tinkering other people's code 
and learned English by trying to understand programming manuals, all by myself. 
My English is still far from perfect and I'm still not fond of reading wall of 
text. I dont think I'm alone. When I looked json document, beginning of that 
text was looking like a preamble and not useful so I jumped directly to procs 
and got lost among unorganized stacks of them.

Anyway,I'll look into document generation process of Nim and I'll see if I can 
do any better.


Re: Unhandled exception: key not found [KeyError]

2017-10-18 Thread sky_khan
hmm, couldnt see that coming. I partly blame documentation. I wish It was 
categorized by purpose. Not stacks of procs, templates, macros but 
constructors/initializers, destructors, getters, setters, (for json module) 
parsing etc. More examples would not be bad either.


Re: Unhandled exception: key not found [KeyError]

2017-10-18 Thread sky_khan
I'm learning Nim myself by trying to write this, seems working


import json

var field1, field2, field3 : string
var jz : JsonNode = %* {"node1": "Node1Value","node3":nil}

template nodeAsStr(n:JsonNode,key:string,default:string="*NoValue*"): 
string =
  if n!=nil and n.hasKey(key):
n[key].getStr(default)
  else:
"*NoKey*"

field1 = jz.nodeAsStr("node1")
field2 = jz.nodeAsStr("node2")
field3 = jz.nodeAsStr("node3")

echo "field1:", field1
echo "field2:", field2
echo "field3:", field3



Re: Pragma for temporarily making strict identifier names?

2017-10-17 Thread sky_khan
IDK, maybe your approach can be helpful on a low-level layer but why would I 
want writing C in Nim? I'd prefer event type as enum and sdl_quit declared as 
just quit. It can be used as sdl2.quit, assuming your wrapper code's module 
name is sdl2, then we can have auto-completion, like

sdl2.nim 


type
  event_type* = enum
quit_event ,
keyboard_event ,
joy_button_event ,
mouse_motion_event
  
  event* = object
etype* : event_type

proc quit* =
discard


test1.nim 


from sdl2 import nil
var
  e : sdl2.event

if e.etype == sdl2.quit_event:
sdl2.quit()



Re: strange copyFile

2017-09-11 Thread sky_khan
'test:test.txt' is a valid filename for NTFS. You create a file named 'test' 
with additional stream 'test.txt'. See: [NTFS Additional Data 
Streams](http://neophob.com/2006/10/ntfs-additional-data-streams-ads/)


Re: Indentation causes compiler errors

2017-08-20 Thread sky_khan

# procedure without return value
proc doThis() =
  discard
#procedure returns value
proc UltimateAnswerOfLifeTheUniverseAndEverything(): int =
  result = 42

echo UltimateAnswerOfLifeTheUniverseAndEverything()



Re: In-Memory Database

2017-07-14 Thread sky_khan
I dont know any of them on that list but are you aware of that you can use 
sqlite as in-memory database by just using ":memory:" as database name?


Re: Add Nim to The Computer Language Benchmarks Game?

2017-06-25 Thread sky_khan
My alternative list

  1. Reaching 1.0 stability
  2. Reaching 1.0 stability
  3. Reaching 1.0 stability



forget standard lib, forget 3rd party (popular or not) packages and 
documentation. Think compiler only. Because they all would need to change if 
you keep changing core language features, like deprecating/removing methods or 
throwing away GC (page 7 on [Community 
Survey](https://forum.nim-lang.org/t/3018) ) or something... 


Re: Version 0.17.0 released!

2017-05-22 Thread sky_khan
I have no idea if Araq has any children but I suspect he would leave any legacy 
for them. I think this is how much he hates inheritance. 

On my own behalf, I dont care much, selfishly, if it is methods or 
vtables/interfaces as long as it will support some kind of polymorphism because 
I have not used it in any serious way yet. I'm just looking forward when Nim to 
stop being a running target even before starting to learn it thoroughly. Sooner 
rather than later, I hope. 


Re: book delayed again

2017-04-26 Thread sky_khan
Fungi talks way too much for a person who dont even want to look at Nim? BTW, I 
think "imbecile" and "non-technical" are equally insulting. Anyway, this means 
you are entering new era. You will be forced to moderate posts like this soon. 
Because forum is starting to attract trolls now! But precisely for this reason, 
I'm convinced Nim's future is bright! lol


Re: Image variable, how?

2017-03-20 Thread sky_khan
This will not show an image but you can embed binary data at compile time with 
something like this


import os, macros, base64

macro embed_binary_file(var_name:untyped,filename:string) : typed =
  let bin64 = base64.encode(slurp(filename.strVal))
  result = newStmtList()
  result.add(newLetStmt(var_name,newStrLitNode(bin64)))

embed_binary_file(img,"digits.bmp")
echo("Image Data:" & $img)



Re: sha256 on files - different hashes

2016-10-15 Thread sky_khan
I think this ( below ) works but IMO this library should provide a way works on 
arrays, not strings. This is inefficient.


import nimSHA2, os, strutils

proc main(): string =
   const blockSize = 8192
   var bytesRead: int = 0
   var buffer: string
   
   var f: File = open("./file.bin")
   var sha: SHA256
   sha.initSHA()
   
   buffer = newString(blockSize)
   bytesRead = f.readBuffer(buffer[0].addr, blockSize)
   setLen(buffer,bytesRead)
   
   while bytesRead > 0:
 echo bytesRead
 sha.update(buffer)
 
 setLen(buffer,blockSize)
 bytesRead = f.readBuffer(buffer[0].addr, blockSize)
 setLen(buffer,bytesRead)
   
   let digest = sha.final()
   
   result = digest.hex()


when isMainModule:
  echo main()



Re: Documentation colour theme

2016-08-21 Thread sky_khan
@flyx The page you referenced uses full black text on full white background.

So, what is so wrong with black, again ?

[Example](https://postimg.org/image/t3p2zslk3/)


Re: Getting

2016-08-08 Thread sky_khan
wow i guess advertisers getting more sneaky day by day