Re: [dev] mkws(1) - simple static site generator

2020-09-05 Thread Adrian Grigore
Removed stat dependency.

I really didn't want to do OS/feature detection so I wrote this:
https://mkws.sh/lts.html.

On Tue, Sep 1, 2020 at 7:55 PM Adrian Grigore
 wrote:
>
> Thanks for your feedback!
>
> I agree that shell script is sort of a natural fit for templating, you
> just take plain text and massage it into HTML.
>
> There are 3rd party solutions for ugc for static sites like
> https://staticman.net/ which are acceptable.
>
> OpenBSD stat is used to generate the timestamp for invalidating the
> cache on css and js files for example.
>
>  '%Y-%m-%dT%H:%M:%SZ' "theme.css">
>
> GNU stat has a different parameter signature, so I just bundled the
> OpenBSD one in the binary packages
> for distribution reasons. I could create a set of simple utilities to
> generate that timestamp and bundle
> them in the binary package.
>
> I plan to create "plugin" scripts stored in ./share/libexec which
> would be called from the main mkws binary.
>
> On Tue, Sep 1, 2020 at 11:59 AM Thomas Oltmann
>  wrote:
> >
> > Am Di., 1. Sept. 2020 um 10:49 Uhr schrieb Thomas Oltmann
> > :
> > > Take navigation menus as an example. It is my understanding that werc
> > > offers a pre-baked solution for this.
> > > In mkws, if I needed a navigation bar on my pages, what I might do is
> > > I could write a mknav.sh script that scans
> > > through my source folder and outputs a list of links in HTML markup,
> > > which I then call at the start of each .upphtml file.
> >
> > Nevermind, I just found out about l.upphtml, so this example is mute.
> >
>
>
> --
> Thank you,
> Adi,
> Freelance Developer
> http://adi.tilde.institute/



-- 
Thank you,
Adi,
Freelance Developer
http://adi.tilde.institute/



Re: [dev] mkws(1) - simple static site generator

2020-09-01 Thread Adrian Grigore
Thanks for your feedback!

I agree that shell script is sort of a natural fit for templating, you
just take plain text and massage it into HTML.

There are 3rd party solutions for ugc for static sites like
https://staticman.net/ which are acceptable.

OpenBSD stat is used to generate the timestamp for invalidating the
cache on css and js files for example.



GNU stat has a different parameter signature, so I just bundled the
OpenBSD one in the binary packages
for distribution reasons. I could create a set of simple utilities to
generate that timestamp and bundle
them in the binary package.

I plan to create "plugin" scripts stored in ./share/libexec which
would be called from the main mkws binary.

On Tue, Sep 1, 2020 at 11:59 AM Thomas Oltmann
 wrote:
>
> Am Di., 1. Sept. 2020 um 10:49 Uhr schrieb Thomas Oltmann
> :
> > Take navigation menus as an example. It is my understanding that werc
> > offers a pre-baked solution for this.
> > In mkws, if I needed a navigation bar on my pages, what I might do is
> > I could write a mknav.sh script that scans
> > through my source folder and outputs a list of links in HTML markup,
> > which I then call at the start of each .upphtml file.
>
> Nevermind, I just found out about l.upphtml, so this example is mute.
>


-- 
Thank you,
Adi,
Freelance Developer
http://adi.tilde.institute/



[dev] mkws(1) - simple static site generator

2020-08-31 Thread Adrian Grigore
Hi all,

Can you give me a review for this https://mkws.sh?

-- 
Thank you,
Adi,
Freelance Developer
http://adi.tilde.institute/



Re: [dev] Re: My take at a static site generator

2019-12-12 Thread Adrian Grigore
What exactly are your dissatisfactions?

On 12/12/19, Marc Chantreux  wrote:
> hello,
>
> On Wed, Dec 11, 2019 at 09:02:00PM +0200, Adrian Grigore wrote:
>> That was my issue, the need to implement things. Along my HTML code, I
>> also have to implement or include libraries for common functionality.
>
>> loop(‘i’,10,‘Counter is i’)
>> vs
>> i = 1
>> while ...
>> #!
>
> well ... i can't get satisfaction from both of them. that's why i wrote
> zpp and finally started to use and abuse the pandoc template langage:
> there is no minimalist tool that is good enough for me.
>
> the best template langage i know is by far template toolkit
> (https://metacpan.org/release/Template-Toolkit) and i will
> try to port it in rust.
>
> regards,
> marc
>
>


-- 
Thank you,
Adi,
Freelance Developer
http://adi.tilde.institute/



[dev] Re: My take at a static site generator

2019-12-11 Thread Adrian Grigore
That was my issue, the need to implement things. Along my HTML code, I
also have to implement or include libraries for common functionality.

define(loop,
‘ifelse($2,0,,
‘define(‘$1’,$2)$3‘’loop(‘$1’,decr($2),‘$3’)’)’)


...

loop(‘i’,10,‘Counter is i’)

vs



...

#
i = 1
while ...
#!

Also, I think most loops would be on files.

On Wednesday, December 11, 2019, Marc Chantreux  wrote:
>
> On Wed, Dec 11, 2019 at 01:39:38PM +0200, Adrian Grigore wrote:
> > Regarding m4(1) I remember I wasn't a big fan of the dnl macro, no
> > loops and also other goodies sh(1) has to offer.
>
> this paper is worth reading:
>
>     http://www.cs.stir.ac.uk/~kjt/research/pdf/expl-m4.pdf
>
> it demonstrate how to:
>
> * implement loops
> * use divert to avoid lot of dnl usages
>
> regards
> marc
>



[dev] Re: My take at a static site generator

2019-12-11 Thread Adrian Grigore
Regarding m4(1) I remember I wasn't a big fan of the dnl macro, no
loops and also other goodies sh(1) has to offer.

Markdown is simple with pp(1). Just

#!
  smu file.md
#!

https://github.com/Gottox/smu

On Tuesday, December 10, 2019, Laslo Hunhold  wrote:
>
> On Mon, 9 Dec 2019 16:17:55 +0200
> Adrian Grigore  wrote:
>
> Dear Adrian,
>
> > Thanks for answering!
> >
> > Do you still have a link to your m4(1) static site generator?
>
> it was never online and had some design decisions that made it close to
> swerc, including multi-hierarchical menus and a focus on markdown. If I
> get the chance I could dig it up.
>
> With best regards
>
> Laslo



Re: [dev] My take at a static site generator

2019-12-09 Thread Adrian Grigore
Hi,

Thanks for answering!

Do you still have a link to your m4(1) static site generator?

On 12/9/19, Laslo Hunhold  wrote:
> On Sun, 8 Dec 2019 20:28:16 +0200
> Adrian Grigore  wrote:
>
> Dear Adrian,
>
>> https://adi.tilde.institute/mkws/
>
> I've already seen this site on Lobsters and found the idea of using
> pp(1) to be pretty interesting. I wrote a static site generator using
> m4(1), the macro preprocessor that is basically the same thing, a few
> years ago.
>
> It's nice to see different approaches to this problem.
>
> With best regards
>
> Laslo
>


-- 
Thank you,
Adi,
Freelance Developer
http://adi.tilde.institute/



[dev] My take at a static site generator

2019-12-08 Thread Adrian Grigore
https://adi.tilde.institute/mkws/

-- 
Thank you,
Adi,
Freelance Developer
http://adi.tilde.institute/



Re: [dev] URI Parser

2019-07-05 Thread Adrian Grigore
Hi all,

Sorry for the late reply!

Laslo:

1. I'm in period of experiment with different stuff, including self
hosting, I bought a
https://www.pine64.org/devices/single-board-computers/rock64/ so ,
I'll maybe host a git or cvs (I get it, I never worked with cvs
ever so I think it's a good idea to to work with it a while just to
understand where software versioning mostly started). Thanks for
attaching the files.

2. I usually add LICENSE files, thanks for the suggestion!

3. Thanks for the suggestion, wasn't aware of the convention!

4. I already have a test program, I don't know if it's a good idea
to include it the actual package or have it separately. Also, I don't
know if it's a good idea to have tests, I can write shell scripts for
the testing, simple stdin stdout testing, but it looks like in C land
most people don't write tests. I was thinking of copying the Go test
suite, also your forgot to mention the [0]. :)

5. In naming, I was looking at the `libc` in OpenBSD, where functions
are stored in single files, that's why the file is named `parseuri.c`,
I'm thinking if it might be good practice to have it as separate
functions.

6. I was thinking I can maybe use the standard `errno` mechanism if
possible, somehow...

7. I usually start programs with dynamic memory allocations and
afterwards decide on default sizes. I somehow missed checking for
mallocs and strdups, weird, thank you! Later edit: you caught me
in the middle of the migration!

8. Yes, I've been given the same advice by somebody else and I can
understand why it could be a good idea. I was reading Go code at the
time and returning structures seemed elegant. It is questionable
indeed, I know at least one function in the standard library that does
the allocation itself, `strdup`. Later edit: If I don't alloc in the functions,
I guess it's a good idea to return structures?

9. I usually leave simplifications for the last moment, I'd rather not
worry about simplicity until it actually works at least in a decent
matter. I think that's fair. I think comments are also reviewable also
I don't think the code has to necessarly be clean if it's in an
incomplete state, cleaning up also comes at the end also
simplifications. I posted mostly to make sure I don't do something
really stupid. It's good to ask.

Thanks for your feedback!

Kurt:

That's one of the reason I posted, making sure I haven't missed an
existing library. Thank you!. Links don't work tho.

I think Plan9 had a URI parsing library (I really can't find it right
now) and I think they used regex, I'd rather not.

The incomplete parts are are query parsing, but I think I'm going to
leave that as simple character array, validations starting from and
including hostname, cleaning up and simplifications.

Sylvain:

Thanks for pointing to the guideline, I mostly follow the Suckless
coding standards and get a lot of inspiration from reading the code.

I was thinking my use of `goto`s was elegant,
I don't think it's confusing.

Thanks all for the feedback, I'll continue working on it when I'll feel
like it, I'd rather not force myself. :)

On Thu, Jun 13, 2019 at 1:26 PM  wrote:
>
> Hi,
>
> Try to follow roughly the coding guideline from the linux kernel.
>
> lower case, no typedefs, sized types (u8, u32, s32...) and cast in case of the
> use of an external API, use of goto for "very sequential code error
> management", etc.
>
> I do even remove keywords from the already way too rich syntax of C:
>  - one loop statement: #define loop for(;;)
>  - no enum.
>  - try to avoid qualifiers (const...).
>
> --
> Sylvain
>


-- 
Thank you,
Adi,
Freelance Developer
http://adi.tilde.institute/



[dev] URI Parser

2019-06-12 Thread Adrian Grigore
Hi guys,

I started writing a RFC3986 compliant URI parser. It's not done yet.
Can I get some feedback?

https://adi.tilde.institute/tmp/uri.h
https://adi.tilde.institute/tmp/parseuri.c

-- 
Thank you,
Adi,
Freelance Developer
http://adi.tilde.institute/



[dev] Linters

2019-05-12 Thread Adrian Grigore
Hey,

I also created a set of linters that check for max line length,
indenting style, trailing whitespace and trailing newlines.

Please let me know your opinions.

-- 
Thank you,
Adi,
Freelance Developer
http://adi.tilde.institute/


linters.tar.gz
Description: application/gzip


Re: [dev] Preprocessor

2019-05-03 Thread Adrian Grigore
In HTML5, attribute quotes are optional so I'm going to remove all sanitization.

On Thu, May 2, 2019 at 3:44 AM Adrian Grigore
 wrote:
>
> In the code itself as in compile your own `pp.c`.
>
> On Thu, May 2, 2019 at 2:45 AM Adrian Grigore
>  wrote:
> >
> > I sanitized double-quotes because they have a high frequency in HTML files 
> > and
> > you would have to do lots of escaping. I was also playing with HTML files 
> > while
> > developing.
> >
> > I sanitized backticks before "$()" are the POSIX preferred method for 
> > command
> > substitution. Rest are normal POSIX sh(1) strings.
> >
> > I may remove all form of sanitization and people could add it themselves in 
> > the
> > code itself as and if necessary.
> >
> > What do you think? What's your preference?
> >
> > On Wed, May 1, 2019 at 10:57 PM Teodoro Santoni  wrote:
> > >
> > > Hi,
> > >
> > > 2019-05-01 18:21 GMT, Adrian Grigore :
> > > > I think it's done:
> > > >
> > > > http://adi.tilde.institute/tmp/pp.c
> > > >
> > > >
> > > >
> > > > On Thu, Apr 25, 2019 at 6:44 AM Adrian Grigore
> > > >  wrote:
> > > >>
> > > >> Ok, refactored.
> > > >>
> > > >> http://adi.tilde.institute/tmp/pp.c
> > > >>
> > > >> Sorry, was experimenting before.
> > > >>
> > > >> On Wed, Apr 24, 2019 at 11:58 PM opal hart  wrote:
> > > >> >
> > > >> > On Tue, 23 Apr 2019 12:26:04 -0400
> > > >> > Cág  wrote:
> > > >> > > http://porkmail.org/era/unix/award.html
> > > >> >
> > > >> > `ls | cat` is actually useful to combat the differences between
> > > >> > implementations of ls(1) and ensure a one-column, uncoloured list
> > > >> >
> > > >> > --
> > > >> > wowaname <https://wowana.me/pgp>
> > > >> >
> > > >>
> > > >>
> > > >> --
> > > >> Thank you,
> > > >> Adi,
> > > >> Freelance Developer
> > > >> http://adi.tilde.institute/
> > > >
> > > >
> > > >
> > > > --
> > > > Thank you,
> > > > Adi,
> > > > Freelance Developer
> > > > http://adi.tilde.institute/
> > > >
> > > >
> > >
> > > Since you've ditched cat with heredocs for echo, and started to
> > > sanitize double-quotes and backticks running down the PHP path of
> > > doom, you may want to think about whether to sanitize or not dollar
> > > ($) symbols, too.
> > > It's a very good idea this one, I prefer this way to the m4 quirkies.
> > >
> >
> >
> > --
> > Thank you,
> > Adi,
> > Freelance Developer
> > http://adi.tilde.institute/
>
>
>
> --
> Thank you,
> Adi,
> Freelance Developer
> http://adi.tilde.institute/



-- 
Thank you,
Adi,
Freelance Developer
http://adi.tilde.institute/



Re: [dev] Preprocessor

2019-05-01 Thread Adrian Grigore
In the code itself as in compile your own `pp.c`.

On Thu, May 2, 2019 at 2:45 AM Adrian Grigore
 wrote:
>
> I sanitized double-quotes because they have a high frequency in HTML files and
> you would have to do lots of escaping. I was also playing with HTML files 
> while
> developing.
>
> I sanitized backticks before "$()" are the POSIX preferred method for command
> substitution. Rest are normal POSIX sh(1) strings.
>
> I may remove all form of sanitization and people could add it themselves in 
> the
> code itself as and if necessary.
>
> What do you think? What's your preference?
>
> On Wed, May 1, 2019 at 10:57 PM Teodoro Santoni  wrote:
> >
> > Hi,
> >
> > 2019-05-01 18:21 GMT, Adrian Grigore :
> > > I think it's done:
> > >
> > > http://adi.tilde.institute/tmp/pp.c
> > >
> > >
> > >
> > > On Thu, Apr 25, 2019 at 6:44 AM Adrian Grigore
> > >  wrote:
> > >>
> > >> Ok, refactored.
> > >>
> > >> http://adi.tilde.institute/tmp/pp.c
> > >>
> > >> Sorry, was experimenting before.
> > >>
> > >> On Wed, Apr 24, 2019 at 11:58 PM opal hart  wrote:
> > >> >
> > >> > On Tue, 23 Apr 2019 12:26:04 -0400
> > >> > Cág  wrote:
> > >> > > http://porkmail.org/era/unix/award.html
> > >> >
> > >> > `ls | cat` is actually useful to combat the differences between
> > >> > implementations of ls(1) and ensure a one-column, uncoloured list
> > >> >
> > >> > --
> > >> > wowaname <https://wowana.me/pgp>
> > >> >
> > >>
> > >>
> > >> --
> > >> Thank you,
> > >> Adi,
> > >> Freelance Developer
> > >> http://adi.tilde.institute/
> > >
> > >
> > >
> > > --
> > > Thank you,
> > > Adi,
> > > Freelance Developer
> > > http://adi.tilde.institute/
> > >
> > >
> >
> > Since you've ditched cat with heredocs for echo, and started to
> > sanitize double-quotes and backticks running down the PHP path of
> > doom, you may want to think about whether to sanitize or not dollar
> > ($) symbols, too.
> > It's a very good idea this one, I prefer this way to the m4 quirkies.
> >
>
>
> --
> Thank you,
> Adi,
> Freelance Developer
> http://adi.tilde.institute/



-- 
Thank you,
Adi,
Freelance Developer
http://adi.tilde.institute/



Re: [dev] Preprocessor

2019-05-01 Thread Adrian Grigore
I sanitized double-quotes because they have a high frequency in HTML files and
you would have to do lots of escaping. I was also playing with HTML files while
developing.

I sanitized backticks before "$()" are the POSIX preferred method for command
substitution. Rest are normal POSIX sh(1) strings.

I may remove all form of sanitization and people could add it themselves in the
code itself as and if necessary.

What do you think? What's your preference?

On Wed, May 1, 2019 at 10:57 PM Teodoro Santoni  wrote:
>
> Hi,
>
> 2019-05-01 18:21 GMT, Adrian Grigore :
> > I think it's done:
> >
> > http://adi.tilde.institute/tmp/pp.c
> >
> >
> >
> > On Thu, Apr 25, 2019 at 6:44 AM Adrian Grigore
> >  wrote:
> >>
> >> Ok, refactored.
> >>
> >> http://adi.tilde.institute/tmp/pp.c
> >>
> >> Sorry, was experimenting before.
> >>
> >> On Wed, Apr 24, 2019 at 11:58 PM opal hart  wrote:
> >> >
> >> > On Tue, 23 Apr 2019 12:26:04 -0400
> >> > Cág  wrote:
> >> > > http://porkmail.org/era/unix/award.html
> >> >
> >> > `ls | cat` is actually useful to combat the differences between
> >> > implementations of ls(1) and ensure a one-column, uncoloured list
> >> >
> >> > --
> >> > wowaname <https://wowana.me/pgp>
> >> >
> >>
> >>
> >> --
> >> Thank you,
> >> Adi,
> >> Freelance Developer
> >> http://adi.tilde.institute/
> >
> >
> >
> > --
> > Thank you,
> > Adi,
> > Freelance Developer
> > http://adi.tilde.institute/
> >
> >
>
> Since you've ditched cat with heredocs for echo, and started to
> sanitize double-quotes and backticks running down the PHP path of
> doom, you may want to think about whether to sanitize or not dollar
> ($) symbols, too.
> It's a very good idea this one, I prefer this way to the m4 quirkies.
>


-- 
Thank you,
Adi,
Freelance Developer
http://adi.tilde.institute/



Re: [dev] Preprocessor

2019-05-01 Thread Adrian Grigore
I think it's done:

http://adi.tilde.institute/tmp/pp.c



On Thu, Apr 25, 2019 at 6:44 AM Adrian Grigore
 wrote:
>
> Ok, refactored.
>
> http://adi.tilde.institute/tmp/pp.c
>
> Sorry, was experimenting before.
>
> On Wed, Apr 24, 2019 at 11:58 PM opal hart  wrote:
> >
> > On Tue, 23 Apr 2019 12:26:04 -0400
> > Cág  wrote:
> > > http://porkmail.org/era/unix/award.html
> >
> > `ls | cat` is actually useful to combat the differences between
> > implementations of ls(1) and ensure a one-column, uncoloured list
> >
> > --
> > wowaname <https://wowana.me/pgp>
> >
>
>
> --
> Thank you,
> Adi,
> Freelance Developer
> http://adi.tilde.institute/



--
Thank you,
Adi,
Freelance Developer
http://adi.tilde.institute/



Re: [dev] Preprocessor

2019-04-24 Thread Adrian Grigore
Ok, refactored.

http://adi.tilde.institute/tmp/pp.c

Sorry, was experimenting before.

On Wed, Apr 24, 2019 at 11:58 PM opal hart  wrote:
>
> On Tue, 23 Apr 2019 12:26:04 -0400
> Cág  wrote:
> > http://porkmail.org/era/unix/award.html
>
> `ls | cat` is actually useful to combat the differences between
> implementations of ls(1) and ensure a one-column, uncoloured list
>
> --
> wowaname 
>


-- 
Thank you,
Adi,
Freelance Developer
http://adi.tilde.institute/



Re: [dev] Preprocessor

2019-04-23 Thread Adrian Grigore
Ignore the shell stuff, I know it's bad (I also usually use find(1)
for these cases), good comments however.
It's good you mentioned it so anybody reading this would know it's
bad, thank you!

On Tue, Apr 23, 2019 at 11:07 PM Peter Nagy  wrote:
>
> This was a question about the preprocessor, please take your sh (off-)topic 
> to a different thread.
>
> That main, mostly the switch part, is huge! Having more than 3 levels of 
> nesting of loops+conditionals (if, for, while, switch) is a code smell; it is 
> hard to read, hard to reason about and easy to get wrong.
>
> Bonus points for not using lex/yacc etc, writing a parser by hand needn't be 
> hard. Still, some refactoring to create smaller, readable and maintainable 
> functions would go a long way. Maybe trying out to write out the states the 
> parser can be in as a table would help to see if the parser can be simplified 
> or the token choices changed. Toying with an FSM implementation might be fun 
> too :)
>

I'm VERY aware of that, I'm still toying with it, I'll probably
abstract those just not sure about the abstractions yet so I
kept them there in my face.

I'd rather not change the token as "#!" reminds me of the shell.
Changing the token however would remove some code.

>
> Why are you building this tool? Fun, education, prototype? What is the end 
> goal? Who is the audience?
>

Generating static web sites would be an idea or could be embedded in
Markdown files.

My doubts are mostly about error handling and undefined behaviour.

I updated it, still no refactoring tho.

Speeds are comparable to PHP for simple IO code.

http://adi.tilde.institute/tmp/pp.c

Thanks for the feedback!

> Good luck with your project!
> --
> Peter Nagy
>
>  - To reach a goal one has to enjoy the journey
>
> On April 23, 2019 7:44:57 PM UTC, Evan Gates  wrote:
> >On Tue, Apr 23, 2019 at 12:42 PM Hadrien Lacour
> > wrote:
> >> That was just shitposting. I use `find` to avoid most of the UNIX
> >braindamage
> >> in this case.
> >
> >Which is good as long as you use -exec correctly. Or if you're going
> >to use xargs make sure to use nul separated lists. Xargs without the
> >nul option is broken by design.
>


-- 
Thank you,
Adi



[dev] Re: Preprocessor

2019-04-22 Thread Adrian Grigore
Ooops sorry, something broke.

The format is the following:

#!/home/adi/src/pp/pp




#!
ls -1 "$1" | while IFS= read -r p
do
#!
  

   $p

  
#!
done
#!



Code is here  http://adi.tilde.institute/tmp/pp.c.

On Mon, Apr 22, 2019 at 4:55 PM Adrian Grigore
 wrote:
>
> Hi,
>
> I built a preprocessor. It allows embedding shell code in any type of files.
> Can you guys give some tips or a code review?
>
> The file format it accepts is the following:
>
> #!/home/adi/src/pp/pp
> 
> 
> 
> 
> #!
> ls -1 "$1" | while IFS= read -r p
> do
>
> 
> 
>
>
> --
> Thank you,
> Adi,



-- 
Thank you,
Adi



Re: [dev] [sbase] Split libutil

2018-10-24 Thread Adrian Grigore
I was thinking it maybe has a generic name and could be splitted in
smaller, more specific, libraries?
On Mon, Oct 22, 2018 at 10:14 PM Hiltjo Posthuma  wrote:
>
> On Mon, Oct 22, 2018 at 08:18:43PM +0300, Adrian Grigore wrote:
> > Is there any interest in splitting llibutil from sbase in smaller libraries?
> > --
> > Thanks,
> > Adi
> >
>
> No, why?
>
> --
> Kind regards,
> Hiltjo
>


-- 
Thanks,
Adi



[dev] [sbase] Split libutil

2018-10-22 Thread Adrian Grigore
Is there any interest in splitting llibutil from sbase in smaller libraries?
-- 
Thanks,
Adi



[dev] diff -x

2018-09-28 Thread Adrian Grigore
How would you implement diff -x in a POSIX compliant manner?

-- 
Thanks,
Adi



[dev] Re: diff -x

2018-09-28 Thread Adrian Grigore
In a diff -ur situation?
On Fri, Sep 28, 2018 at 5:48 PM Adrian Grigore
 wrote:
>
> How would you implement diff -x in a POSIX compliant manner?
>
> --
> Thanks,
> Adi



-- 
Thanks,
Adi



[dev] Dynamic DNS

2018-09-27 Thread Adrian Grigore
Do you know any good free Dynamic DNS provider?

-- 
Thanks,
Adi



Re: [dev] Shell script testing functions

2018-06-09 Thread Adrian Grigore
> 1) use shellcheck. Check out shellcheck.net or install locally. It
catches the most common shell scripting problems.

I already do. Thanks for the other recommendations.
On Sat, Jun 9, 2018 at 6:32 PM Evan Gates  wrote:
>
> On Sat, Jun 9, 2018, 08:20 Adrian Grigore 
> wrote:
>
> > I sometimes enjoy testing my shell scripts. Opinions?
>
> I'm away from my computer so I can't give full feedback but for now
> I'd recommend
>
> 1) use shellcheck. Check out shellcheck.net or install locally. It
> catches the most common shell scripting problems.
>
> 2) mywiki.wooledge.org has a great guide, faq, and list of pitfalls.
> The pitfalls is a great place to start. It's a list of very common
> problems with explanations of why they are wrong and how to fix them.
>
> 3) #bash on freenode. Helpful if occasionally snarky community. If you
> ask them for feedback and avoid the xy problem you can learn a lot.
>
> emg
>


-- 
Thanks,
Adi



[dev] Re: Shell script testing functions

2018-06-09 Thread Adrian Grigore
Sorry, minor bugs fixed.

#!/bin/sh

tap_inited=false
tap_i=0
tap_exitstatus=0

tap_printline()
{
[ "$1" -eq 0 ] && printf "ok %d - %s\n" $tap_i "$current" && return;

printf "not ok %d - %s\n" $tap_i "$current"
tap_exitstatus=1
}

tap_test() {
lastexitstatus=$?

! $tap_inited && current="$1" && tap_inited=true && tap_pretest && return;

tap_i=$((tap_i+1))

tap_printline $lastexitstatus
tap_posttest
current=$1
tap_pretest
}

tap_printplan() {
printf "1..%s\n" "$tap_i"
}

tap_finish() {
lastexitstatus=$?
[ -z "$current" ] && exit
tap_printline $lastexitstatus
tap_printplan
exit $tap_exitstatus
}

trap tap_finish EXIT

tap_pretest() {
true
}

tap_posttest() {
true
}

tap_test "one plus zero is zero"
sum=$((1+0))
[ $sum -eq 0 ]

tap_test "one plus one is one"
sum=$((1+1))
[ $sum -eq 2 ]

tap_test "one plus one is three"
sum=$((1+1))
[ $sum -eq 3 ]

tap_test "two plus two is four"
sum=$((2+2))
[ $sum -eq 4 ]
On Sat, Jun 9, 2018 at 6:19 PM Adrian Grigore
 wrote:
>
> I sometimes enjoy testing my shell scripts. Opinions?
>
> #!/bin/sh
>
> tap_inited=false
> tap_i=0
> tap_exitstatus=0
>
> tap_printline()
> {
> [ "$1" -eq 0 ] && printf "ok %d - %s\n" $tap_i "$current" && return;
>
> printf "not ok %d - %s\n" $tap_i "$current"
> exitstatus=1
> }
>
> tap_test() {
> lastexitstatus=$?
>
> ! $tap_inited && current="$1" && tap_inited=true && tap_pretest && return;
> tap_i=$((tap_i+1))
>
> tap_printline $lastexitstatus
> tap_posttest
> current=$1
> tap_pretest
> }
>
> tap_printplan() {
> printf "1..%s\n" "$tap_i"
> }
>
> tap_finish() {
> lastexitstatus=$?
> [ -z "$current" ] && exit
> tap_printline $lastexitstatus
> tap_printplan
> exit $exitstatus
> }
>
> trap tap_finish EXIT
>
> tap_pretest() {
> true
> }
>
> tap_posttest() {
> true
> }
>
> tap_test "one plus zero is zero"
> sum=$((1+0))
> [ sum -eq 0 ]
>
> tap_test "one plus one is one"
> sum=$((1+1))
> [ sum -eq 2 ]
>
> tap_test "one plus one is three"
> sum=$((1+1))
> [ sum -eq 3 ]
>
> tap_test "two plus two is four"
> sum=$((2+2))
> [ sum -eq 4 ]
>
> --
> Thanks,
> Adi



-- 
Thanks,
Adi



[dev] Shell script testing functions

2018-06-09 Thread Adrian Grigore
I sometimes enjoy testing my shell scripts. Opinions?

#!/bin/sh

tap_inited=false
tap_i=0
tap_exitstatus=0

tap_printline()
{
[ "$1" -eq 0 ] && printf "ok %d - %s\n" $tap_i "$current" && return;

printf "not ok %d - %s\n" $tap_i "$current"
exitstatus=1
}

tap_test() {
lastexitstatus=$?

! $tap_inited && current="$1" && tap_inited=true && tap_pretest && return;
tap_i=$((tap_i+1))

tap_printline $lastexitstatus
tap_posttest
current=$1
tap_pretest
}

tap_printplan() {
printf "1..%s\n" "$tap_i"
}

tap_finish() {
lastexitstatus=$?
[ -z "$current" ] && exit
tap_printline $lastexitstatus
tap_printplan
exit $exitstatus
}

trap tap_finish EXIT

tap_pretest() {
true
}

tap_posttest() {
true
}

tap_test "one plus zero is zero"
sum=$((1+0))
[ sum -eq 0 ]

tap_test "one plus one is one"
sum=$((1+1))
[ sum -eq 2 ]

tap_test "one plus one is three"
sum=$((1+1))
[ sum -eq 3 ]

tap_test "two plus two is four"
sum=$((2+2))
[ sum -eq 4 ]

-- 
Thanks,
Adi



Re: [dev] ASCII Delimited Text

2018-05-22 Thread Adrian Grigore
> Maybe a nice thing to have would be to get the terminal emulator to
treat the field and record separator in a special way. So the programs
all output fs and rs, and the terminal emulator uses these characters to
layout the data in a tabular way.

There's no terminal that does this, right?

On Tue, May 22, 2018 at 3:24 AM, Raphaël Proust <s...@bnwr.net> wrote:
> Hello,
>
> On 2018-05-22 00:38, Connor Lane Smith wrote:
>> On 21 May 2018 at 17:12, Adrian Grigore <adrian.emil.grig...@gmail.com> 
>> wrote:
>>> I'm having problems compiling usul:
>>
>> This is a surprise. Where did you get usul from?
>
> I sent the copy. I use usul regularly so I still have the whole repo
> locally.
>
>
>>
>> I have been wondering lately about resurrecting usul, since 'tabular
>> munging' with Unix utilities without the ability to set $FS and $RS
>> can be really unpleasant, and I've had to do quite a bit of it
>> recently.
>>
>> I did also write a program to complement usul which performs elastic
>> tabbing on its input, the idea being that you end up with a nice
>> tabular view in your terminal. I think ideally you might want 'real'
>> terminal support for it though, as when printing to the tty you either
>> need to buffer a lot of data (i.e. until a line with no FS), or you
>> need to do crazy tty-rewriting ANSI escapes, which it did support but
>> is a massive hack.
>
> In what way is the elastic tabbing different from what Plan9's mc(1)?
>
>
> Ciao,
> -- Raphaël
>



-- 
Thanks,
Adi



Re: [dev] ASCII Delimited Text

2018-05-21 Thread Adrian Grigore
> Try putting the library at the end. Some linkers display rather...
classic behavior when linking statically (i.e. only linking in the files
that are needed, but if you name a library as first thing, then no file
is needed at that point).

Works!

On Mon, May 21, 2018 at 9:30 PM, Markus Wichmann <nullp...@gmx.net> wrote:
> On Mon, May 21, 2018 at 07:12:46PM +0300, Adrian Grigore wrote:
>> cc -lutf -o cat cat.o util.o
>> cat.o: In function `main':
>> cat.c:(.text+0x179): undefined reference to `chartorune'
>> cat.c:(.text+0x1dd): undefined reference to `runetochar'
>> cc: error: linker command failed with exit code 1 (use -v to see invocation)
>> gmake: *** [Makefile:15: cat] Error 1
>
> Try putting the library at the end. Some linkers display rather...
> classic behavior when linking statically (i.e. only linking in the files
> that are needed, but if you name a library as first thing, then no file
> is needed at that point).
>
> Ciao,
> Markus
>



-- 
Thanks,
Adi



Re: [dev] ASCII Delimited Text

2018-05-21 Thread Adrian Grigore
> This is a surprise. Where did you get usul from? I'm not sure even I
have a copy any more! The only reason I can think of, though, is that
you need to specify the -L libdir.

Attachment above. :)

cc -lutf -L. -o cat cat.o util.o gives:

cat.o: In function `main':
cat.c:(.text+0x179): undefined reference to `chartorune'
cat.c:(.text+0x1dd): undefined reference to `runetochar'
cc: error: linker command failed with exit code 1 (use -v to see invocation)

I have libutf.a in the current directory.

I can't event compile this:
#include 

int
main(int argc, char *argv[])
{
Rune r;
chartorune(, "");
return 0;
}

with
cc -L. -lutf -o utf utf.c
getting
/tmp/utf-1e880d.o: In function `main':
utf.c:(.text+0x33): undefined reference to `chartorune'
cc: error: linker command failed with exit code 1 (use -v to see invocation)

> I did also write a program to complement usul which performs elastic
tabbing on its input, the idea being that you end up with a nice
tabular view in your terminal. I think ideally you might want 'real'
terminal support for it though, as when printing to the tty you either
need to buffer a lot of data (i.e. until a line with no FS), or you
need to do crazy tty-rewriting ANSI escapes, which it did support but
is a massive hack.

This sounds interesting.

On Mon, May 21, 2018 at 7:38 PM, Connor Lane Smith <c...@lubutu.com> wrote:
> Hi,
>
> On 21 May 2018 at 17:12, Adrian Grigore <adrian.emil.grig...@gmail.com> wrote:
>> I'm having problems compiling usul:
>
> This is a surprise. Where did you get usul from? I'm not sure even I
> have a copy any more! The only reason I can think of, though, is that
> you need to specify the -L libdir.
>
> I have been wondering lately about resurrecting usul, since 'tabular
> munging' with Unix utilities without the ability to set $FS and $RS
> can be really unpleasant, and I've had to do quite a bit of it
> recently.
>
> I did also write a program to complement usul which performs elastic
> tabbing on its input, the idea being that you end up with a nice
> tabular view in your terminal. I think ideally you might want 'real'
> terminal support for it though, as when printing to the tty you either
> need to buffer a lot of data (i.e. until a line with no FS), or you
> need to do crazy tty-rewriting ANSI escapes, which it did support but
> is a massive hack.
>
> Thanks,
> Connor
>



-- 
Thanks,
Adi



Re: [dev] ASCII Delimited Text

2018-05-21 Thread Adrian Grigore
> Maybe a nice thing to have would be to get the terminal emulator to
treat the field and record separator in a special way. So the programs
all output fs and rs, and the terminal emulator uses these characters to
layout the data in a tabular way

But would it still be plain text?

I'm having problems compiling usul:
cc -lutf -o cat cat.o util.o
cat.o: In function `main':
cat.c:(.text+0x179): undefined reference to `chartorune'
cat.c:(.text+0x1dd): undefined reference to `runetochar'
cc: error: linker command failed with exit code 1 (use -v to see invocation)
gmake: *** [Makefile:15: cat] Error 1

I mention have libutf.a in my path.

On Mon, May 21, 2018 at 12:09 PM, Truls Becken  wrote:
> As an anecdote, I actually wanted to use US/RS delimited text at work
> a while ago to consume XML downloaded from some service. The idea was
> to use XSLT to convert the data to a sane format that I could easily
> ingest. As it turns out, that was a no-can-do because XSL transforms
> are defined in an XML dialect, and XML is not allowed to contain ASCII
> control characters, not even on escaped form  So you cannot
> express this transformation to any of the XSLT engines I tested! I
> ended up using a pair of Unicode control chars instead.
>
> -Truls
>



-- 
Thanks,
Adi



Re: [dev] ASCII Delimited Text

2018-05-17 Thread Adrian Grigore
How would you have other tools like cat(1) or ls(1) handle them?

On Thu, May 17, 2018 at 6:16 AM, Greg Reagle <greg.rea...@umbc.edu> wrote:
> On Wed, May 16, 2018, at 10:05, Adrian Grigore wrote:
>> What do  you guys think of this:
>>
>> https://ronaldduncan.wordpress.com/2009/10/31/text-file-formats-ascii-delimited-text-not-csv-or-tab-delimited-text/
>
> Seems reasonable to me.  For the purpose of transferring data between two 
> different spreadsheet programs that cannot read each other's native formats, 
> seems much better than using tabs or commas.
>
> If I were doing editing of this text format directly, I'd want my 
> editor/pager to have some tools to make it easier.  Maybe display the Unit 
> Separator as a special-color pipe and the Record Separator as a special-color 
> newline and the Group Separator as a special-color double newline (i.e. blank 
> line).  And an easy way to type in these characters in the editor.  For 
> example, Unit Separator can be entered in Emacs as C-x 8 RET 1 f RET, so a 
> better shortcut would be useful, e.g. C-| (control pipe).
>



-- 
Thanks,
Adi



[dev] ASCII Delimited Text

2018-05-16 Thread Adrian Grigore
What do  you guys think of this:

https://ronaldduncan.wordpress.com/2009/10/31/text-file-formats-ascii-delimited-text-not-csv-or-tab-delimited-text/

-- 
Thanks,
Adi



[dev] Ranger inspired file manager in Go

2017-02-13 Thread Adrian Grigore
https://github.com/gokcehan/lf

-- 
Thanks,
Adi



Re: [dev] Shell style guide

2016-09-07 Thread Adrian Grigore
Thanks!

On Thu, Sep 8, 2016 at 12:29 AM, Evan Gates <evan.ga...@gmail.com> wrote:
> On Wed, Sep 7, 2016 at 2:11 PM, Adrian Grigore
> <adrian.emil.grig...@gmail.com> wrote:
>> Rendering was just an example, I doubt a shell script would be rendering.
>>
>> Example of camelCase I find ok is here:
>> https://raw.githubusercontent.com/adriangrigore/bootstrap/master/bootstrap
>>
>> Be free to critique the script, but note that I'm new to the whole
>> UNIX/C scene so learning as I go (if I did some blatant mistakes,
>> please point them).
>>
>
> In this line:
>
>>&2 echo usage: bootstrap name [description] [license]
>
> You must quote. [description] is a glob, if you have a file named e in
> the directory it will print: usage: bootstrap name e e
>
> This line:
>
> if [ $(license -list | tail -n +3 | awk '{ print $1 }' | grep "$type") ]; then
>
> No need for [] nor $(), just useif license -list | ... | grep -q
> "$type"; then
> Also you should rarely, if ever, need both awk and grep in a single
> pipeline (you can get rid of tail too and just license | awk)
>



-- 
Thanks,
Adi



Re: [dev] Shell style guide

2016-09-07 Thread Adrian Grigore
Rendering was just an example, I doubt a shell script would be rendering.

Example of camelCase I find ok is here:
https://raw.githubusercontent.com/adriangrigore/bootstrap/master/bootstrap

Be free to critique the script, but note that I'm new to the whole
UNIX/C scene so learning as I go (if I did some blatant mistakes,
please point them).

On Thu, Sep 8, 2016 at 12:04 AM, Charlie Kester <corky1...@comcast.net> wrote:
> On Wed 07 Sep 2016 at 11:43:48 PDT Adrian Grigore wrote:
>>
>> Tbh, I'm nor a big fan of camelCase either, but when dealing with
>> names composed of multiple words, it looks cleaner to me.
>>
>> renderimage vs renderImage
>
>
> It's mostly a matter of taste.  But as someone whose tastes
> were formed by the naming conventions of K and the C runtime
> library, I think the camelcased version of your example looks
> less "clean".
>
> And I have to ask: what else would your script be rendering?
> Is it really necessary to specify the object if "render" will
> suffice?
>
>
>



-- 
Thanks,
Adi



Re: [dev] Shell style guide

2016-09-07 Thread Adrian Grigore
Tbh, I'm nor a big fan of camelCase either, but when dealing with
names composed of multiple words, it looks cleaner to me.

renderimage vs renderImage

On Wed, Sep 7, 2016 at 8:21 PM, Adrian Grigore
<adrian.emil.grig...@gmail.com> wrote:
> Tbh, I'm nor a big fan of camelCase either, but when dealing with names
> composed of multiple words, it looks cleaner to me.
>
> renderimage vs renderImage
>
>
> On Wednesday, September 7, 2016, Antenore Gatta <anten...@simbiosi.org>
> wrote:
>> On Wed, 7 Sep 2016 03:23:55 +0300
>> Adrian Grigore <adrian.emil.grig...@gmail.com> wrote:
>>
>>> What do you think of camelCase names for functions/variables?
>>
>> For me it's important being consistent, at least on a project level
>> (across projects would be the best).
>>
>> I personally dislike camelCase but are good to save columns.
>>
>>
>> --
>> -BEGIN GEEK CODE BLOCK-
>> Version: 3.12
>> GIT !d s: !a C++ UL P+++ L+++ E--- W+++ N+++ o-- K- w---
>> O+ M-- V-- PS+++ PE Y+ PGP t+++ 5++ X R++ tv- b+ DI D++
>> G e+ h r+++ y
>> --END GEEK CODE BLOCK--
>>
>>
>
> --
> Thanks,
> Adi



-- 
Thanks,
Adi



Re: [dev] Shell style guide

2016-09-06 Thread Adrian Grigore
What do you think of camelCase names for functions/variables?

On Tue, Sep 6, 2016 at 11:53 PM, Greg Reagle  wrote:
> On Tue, Sep 6, 2016, at 03:27 PM, Evan Gates wrote:
>> Sadly there is a lot of software these days that requires bash.
>> Hopefully we can avoid most of it, but I'm sure it'll pop up now and
>> then. I'd say anything that can't be done well/safely in sh should be
>> done in rc, but bash is ubiquitous. (The biggest problem with sh is
>> that it does not support arrays)
>
> I think that the use of bash for suckless projects should be strongly
> discouraged or prohibited.  Yes there are programs that require bash,
> but we don't need to make any more.
>
> Also, the Plan 9 rc shell *clearly* sucks *much* less than the other
> shells and is freely available with a free software/open source license.
>  It is even part of 9base.  I don't know why any shell script in stali
> would be written in anything other than Plan 9 rc.
>



-- 
Thanks,
Adi



Re: [dev] Re: Linux distros that don't suck too too much

2016-05-12 Thread Adrian Grigore
I jumped from Ubuntu, to Arch and currently am very happy with
OpenBSD. I think only 9front can supersede it. Note tho, that it's
very bare bones so you'll spend some time understanding it but it's
definitely worth it.

On Thu, May 12, 2016 at 12:54 PM, Rubén Llorente
 wrote:
> hiro <23h...@gmail.com> wrote:
>> So that's why I want an alternative that is fit
>> to be used by anyone.
>
> I doubt you can make a suckless anything that fits that criteria.
>
> Modern user expectations often require the use of code or technologies
> that are just a conceptual mess. Web applications are a great example.
> In order to fullfill user expectations, you need to instal a piece of
> software that executes every single piece of client-side script it runs
> into and then prays for it not to be malware. It also has to deal with
> ill-formated pages, which requires some sort of quirk mode on the
> parser, which is sucky because it could be rendering anything but what
> the web developer intended. Users expect one of these to work, and an
> alternative that is not js-happy - for example, requires a confirmation
> before executing each script - or does not tolerate malformed pages
> therefore does not fit your criteria.
>
> Many people has been trained to expect crappy behaviours from their
> software in many fields, and thus any software which is to be used by
> anyone in that field must behave in the crappy way the user is
> expecting. Some of these fields are expected to be of interest for most
> users, like web browsing.
>
> Therefore I submit the theory that software that does not suck but is
> usable by everybody is not possible in certain fields, and since at
> least some of those fields must be covered by any user-friendly
> distribution, then such a distribution must include these bad tools. If
> it didn't, it would not be computer-illiterate-friendly.
>
> Which means that a distribution that tries to fit every shoe cannot
> possibly be suckless by any means.
>
> I stopped caring too much about user-friendlyness long ago, because
> no matter what you do, lambs will always find a way to make a mess out
> of the easy to use software. The only way a computer-illiterate is going
> to be able to use a computer properly is by educating herself or by
> hiring somebody to do the administration.
>
> --
> OpenPGP Key Fingerprint:
> BB5A C2A2 2CAD ACB7 D50D  C081 1DB9 6FC4 5AB7 92FA
>
>



-- 
Thanks,
Adi



Re: [dev] Auto-preview man pages

2016-01-07 Thread Adrian Grigore
On Fri, Jan 8, 2016 at 5:05 AM, Greg Reagle  wrote:
>   echo Readme.md | entr sh -c 'markdown Readme.md | w3m -T text/html'
>
> Still not ideal, because you have to quit from w3m manually.  If you use
> -dump with w3m you don't have to quit, but you lose formatting and other 
> goodies.
>

This is exactly where I'm stumped.


-- 
Thanks,
Adi



Re: [dev] Auto-preview man pages

2016-01-07 Thread Adrian Grigore
On Thu, Jan 7, 2016 at 8:56 PM, Greg Reagle  wrote:
> I find it a real pain to work with things like man page source and markdown
> source and so forth because of the extra steps of making the output/object
> format.
>

I have yet to find a solution for markdown. I would really prefer
something with w3m.

-- 
Thanks,
Adi



[dev] Auto-preview man pages

2016-01-06 Thread Adrian Grigore
Don't know if it's worth posting, but this is a comfortable way for me
to write man pages:

ls *.1 | entr -cd sh -c 'MANPAGER="less -FX" man -l $0' /_

entr is http://entrproject.org/

-- 
Thanks,
Adi



[dev] C package manager-ish

2015-12-15 Thread Adrian Grigore
Hey guys,

I wanted to know what's your general opinion on https://github.com/clibs/clib.

Disclaimer: I'm not a C programmer, but planning to learn.

-- 
Thanks,
Adi



Re: [dev] C package manager-ish

2015-12-15 Thread Adrian Grigore
Need to install sta.li and see how that works out. :) It's on my todo list.

On Tue, Dec 15, 2015 at 12:26 PM, Anselm R Garbe <garb...@gmail.com> wrote:
> On 15 December 2015 at 11:20, Adrian Grigore
> <adrian.emil.grig...@gmail.com> wrote:
>> I wanted to know what's your general opinion on 
>> https://github.com/clibs/clib.
>
> My proposal is using git for binaries as well (for whole core systems).
>
> get checkout 0.1
>
> get diff 0.2
>
> etc.
>
> BR,
> Anselm
>



-- 
Thanks,
Adi