Re: re or nre. What should i use? What will be supported in future?

2020-03-08 Thread stbalbach
For performance, last I checked, re is faster than nre by a lot.

Re: Sqlite: unfinalized statements error

2019-12-31 Thread stbalbach
Ok re: not a crash. I learned the best way to do SQL in Nim is first via the command-line utility to test the syntax and methods, when satisfied then add to Nim. The Nim error messages as you say something wrong here is difficult to debug for a new user, the sqlite3 utility gives more info and

Re: Sqlite: unfinalized statements error

2019-12-29 Thread stbalbach
Alright, I thought SQL gracefully ignored adding a duplicate key but guess not. I've added this function: proc exists(database: Database, id: string): bool = result = if len(database.db.getValue(sql"SELECT id FROM Pages WHERE id = ?;", id)) > 0: true else: false

Sqlite: unfinalized statements error

2019-12-29 Thread stbalbach
I'm new to SQL so don't know if I'm doing something wrong or this is a bug. The following produces runtime error: "Error: unhandled exception: unable to close due to unfinalized statements or unfinished backups [DbError]" The code is mostly adapted from 'Nim in Action'. The first run on db

Re: What’s your favorite programming language and why?

2019-12-21 Thread stbalbach
GNU awk - sometimes considered a "toy" language but far from it these days. I've done entire websites, http servers and OAuth. The syntax is easier than Nim, runs nearly as fast, and being a single executable and POSIX can be found pre-installed most places. Used for all my scripting work and

Re: Memory leak

2019-11-15 Thread stbalbach
Memory leak fixed! Switched to boehm per Stefan's suggestion. Thanks everyone for the ideas.

Re: Memory leak

2019-11-14 Thread stbalbach
Unfortunately I have been unable to do that as mentioned in the post.

Memory leak

2019-11-14 Thread stbalbach
I've been trying to find a memory leak. The program is processing data retrieved over the net, uploading results to another site, and runs for days at a time with multiple copies running at once. There is no database. After a few days, the memory usage increases to a point then the program

Re: Calling functions between files

2018-09-21 Thread stbalbach
Another way is with include and proc definitions. It keeps everything at the top so imports are not buried in the code, though it creates one big module. proc putPixel*(x, y: int) include drawing proc putPixel*(x, y: int) = echo "hi" while true:

Re: Looking for efficient API for regexp library

2018-03-10 Thread stbalbach
> it requires the variables to receive the captures to be declared ahead of > time: This might work (untested): template match(src: string, pat: string, c0, c1: untyped): bool = when compiles(c0): c0 = "" else: var c0 = "" when

Re: Increasing Nim exposure

2018-01-12 Thread stbalbach
> I am going to ignore Rust, D and Nim as they have too few users. Programming > is a social activity: if nobody can use your code, it does not matter that it > runs fast. What the professor really means: his students can't get hired at AAA firms when trained in languages that aren't in the

Re: Any future for true associative arrays?

2017-09-04 Thread stbalbach
Excellent, thanks. That's all I need is a variable for the key. I'd never looked into tables.

Any future for true associative arrays?

2017-09-03 Thread stbalbach
I use associative arrays regularly in Lua and awk but Nim doesn't really have the same. Is there a roadmap or is it too angular to implement? I'd like to be able to do something like this (pseudo-code to unique a list of words): import strutils var arr = split("Blue

Re: Fastest way to pack CSV file

2017-04-23 Thread stbalbach
@jlp765 - implemented the grep solution and is ridiculously fast (10 mins for awk vs 2 seconds for grep). Not sure why the awk script is slow.. ah it doesn't use "|". For a 30,000 line log file and 1000 line names file = 300,000,000 regex matches.. ugh. @Araq - you're right SQL (or maybe JSON)

Re: Fastest way to pack CSV file

2017-04-22 Thread stbalbach
_First of all you need to memory map your CSV file_ Got it, thanks. Found Module memfiles and will give it a try.

Re: Fastest way to pack CSV file

2017-04-22 Thread stbalbach
_Import the CSVs into an sqlite database and run a DELETE query on it. Then use the database for further queries and throw away "The Art of Unix Programming"._ It's funny.. I'm working on a project with someone else who is creating a similar app and he went with the SQL approach. Because of the

Fastest way to pack CSV file

2017-04-22 Thread stbalbach
What would be the fastest way to remove lines from a medium-size CSV file? For example given a CSV: Bill,0,0,0 Bill,1,1,1 Mary,0,0,0 Todd,0,0,0 etc.. And a list of names to delete: Mary Todd Remove the lines with those names. The CSV's

Re: Extract a substring

2017-04-01 Thread stbalbach
There is also system.substr()

Re: base64 encoding crashes

2017-03-01 Thread stbalbach
Sorry to hijack the thread but I am in need of a bas62 decoder .. currently shelling out to another language that has it. In case anyone knows of something.

Re: Nim Syntax ''Skins''

2017-02-27 Thread stbalbach
The skin is a language's personality. To copy other personalities is no personality.

Re: nre, am I using it wrongly?

2017-01-15 Thread stbalbach
With the awk.nim library import awk, strutils from nre import escapeRe let line = "; abc " var pos = match(line, "[^ \t\r\n\f]", theMatch) - 1 if pos > -1: let isComment = match("#;", escapeRe(theMatch) ) echo "$# $#" % [$pos, $isComment]

template/generic instantiation from here

2017-01-11 Thread stbalbach
Hi, Given two templates splitre() and splitnre() which are almost identical import strutils, re, nre proc makeDiscardable[T](a: T): T {.discardable.} = a template splitre*(source: string, dest: untyped, match: string): int = when compiles(dest):

Re: re/nre performance issues

2016-10-15 Thread stbalbach
There was an earlier thread about performance of regex [https://forum.nim-lang.org/t/2312](https://forum.nim-lang.org/t/2312) > I inserted those options into re module and... voila, 0.2 s I'd be interested to know how or what you did there.

Re: Community Code of Conduct

2016-07-01 Thread stbalbach
CoC's are unnecessary evils unless they become so through hard won experience and develop bottom up through democratic consensus mechanisms.