Re: [dev] [dwm] swallow without patching dwm -- or losing focus

2023-05-25 Thread Spenser Truex
On 23/05/26 07:24AM, Sagar Acharya wrote:
> Beautiful code. As a rookie user, how will this code be used? Can this be a 
> complete Xenocara/Xorg alternative?
> Thanking you

A very humourous response. I just want my windows to open where I opened
them. There is no kitchen sink included.

It is used like this

./swallow mpv

cheers

> Sagar Acharya
> http://humaaraartha.in 
>
>
>
> 26 May 2023, 05:45 by tr...@equwal.com:
>
> > Greetings,
> >
> > I converted this swallow program to C, not that it makes any difference
> > at this code size. It's just a couple of malloc'd strings.
> >
> > https://github.com/equwal/swallow-c--
> >
> > I'd like to make it actually transfer the terminal's focus rather than
> > async open and hide itself. That way you get the program you opened in the
> > tag you opened it in, which is something I've been trying to do for a
> > long time in multiple window managers.
> >
> > The author pointed out that "startup hooks" can do this in some window
> > managers, but I like the idea of not even having that be part of the WM
> > itself.
> >
> >
> > --
> > CAEE B377 FC82 BAF9 102C  D22F C5CE D003 1AA8 E281
> > Spenser Truexhttps://equwal.com
> >
>

-- 
CAEE B377 FC82 BAF9 102C  D22F C5CE D003 1AA8 E281
Spenser Truexhttps://equwal.com


signature.asc
Description: PGP signature


Re: [dev] [dwm] swallow without patching dwm -- or losing focus

2023-05-25 Thread Sagar Acharya
Beautiful code. As a rookie user, how will this code be used? Can this be a 
complete Xenocara/Xorg alternative?
Thanking you
Sagar Acharya
http://humaaraartha.in 



26 May 2023, 05:45 by tr...@equwal.com:

> Greetings,
>
> I converted this swallow program to C, not that it makes any difference
> at this code size. It's just a couple of malloc'd strings.
>
> https://github.com/equwal/swallow-c--
>
> I'd like to make it actually transfer the terminal's focus rather than
> async open and hide itself. That way you get the program you opened in the
> tag you opened it in, which is something I've been trying to do for a
> long time in multiple window managers.
>
> The author pointed out that "startup hooks" can do this in some window
> managers, but I like the idea of not even having that be part of the WM
> itself.
>
>
> -- 
> CAEE B377 FC82 BAF9 102C  D22F C5CE D003 1AA8 E281
> Spenser Truexhttps://equwal.com
>



[dev] [dwm] swallow without patching dwm -- or losing focus

2023-05-25 Thread Spenser Truex
Greetings,

I converted this swallow program to C, not that it makes any difference
at this code size. It's just a couple of malloc'd strings.

https://github.com/equwal/swallow-c--

I'd like to make it actually transfer the terminal's focus rather than
async open and hide itself. That way you get the program you opened in the
tag you opened it in, which is something I've been trying to do for a
long time in multiple window managers.

The author pointed out that "startup hooks" can do this in some window
managers, but I like the idea of not even having that be part of the WM
itself.


-- 
CAEE B377 FC82 BAF9 102C  D22F C5CE D003 1AA8 E281
Spenser Truexhttps://equwal.com


signature.asc
Description: PGP signature


Re: [dev] running a shortlink provider

2023-05-25 Thread Anthony
Thanks for the details! I have tough about hash maps but actually not 
about simultaneous requests... this seems quite bad tho. (if you have 
more than a few hundreds users?)

I know it is insecure, but I would store everything in a txt file where each
line is a link.

Why is that insecure?
Because you can just fetch every shorted links by "bruteforce". this is 
"insecure" in the sense that it is not "private".

If you don't want your id to be consecutive, a tsv file would do the trick
with a hash then the link.

BINGO

I suppose that this doesn't help with complexity tho...




Re: [dev] running a shortlink provider

2023-05-25 Thread Spenser Truex
On 23/05/25 10:29AM, Anthony wrote:
> On 5/25/23 07:29, Страхиња Радић wrote:
> > Perhaps the most minimal solution for keeping data would be TSV files, but 
> > they
> > are not suitable for storing data entered from the web because of 
> > concurrency,
> > so a "real" database would be needed.
> >
> What do you mean by, "because of concurrency"?

Performance:

A hash table would be O(1) because you lookup the hash and get it. For a
text file you could only hope for O(log n) with bisecting.

Locks:
No need to lock a hashtable. Needed very much to lock a file though.

I don't support this database heavy database stuff. A key-value pair
dataset would be enough. It's basically a perl one-liner. If you have a
markup language for your database it's bloat.

>
> I know it is insecure, but I would store everything in a txt file where each
> line is a link.

Why is that insecure?

>
> Then you can reach your link with http://myperfectsite.org/

Neat.

>
> If you don't want your id to be consecutive, a tsv file would do the trick
> with a hash then the link.

BINGO

>
> Is there a problem with this approach ?
>

Why use a hammer when you can beat the nail with your hand?

-- 
CAEE B377 FC82 BAF9 102C  D22F C5CE D003 1AA8 E281
Spenser Truexhttps://equwal.com


signature.asc
Description: PGP signature


Re: [dev] running a shortlink provider

2023-05-25 Thread Страхиња Радић
On 23/05/25 10:29AM, Anthony wrote:
> What do you mean by, "because of concurrency"?

At any given moment, several HTTP clients can request posting data at the same 
time. They can hang indefinitely in the middle of sending data. If the process 
involves writing to a file, this can lead to data corruption or data loss. Even 
with a file lock, other such requests can be delayed or even denied. That's why 
a more sophisticated approach, possibly with caching, transactions and other 
methods which are present in database systems, is needed.


signature.asc
Description: PGP signature


Re: [dev] running a shortlink provider

2023-05-25 Thread Anthony

On 5/25/23 07:29, Страхиња Радић wrote:

Perhaps the most minimal solution for keeping data would be TSV files, but they
are not suitable for storing data entered from the web because of concurrency,
so a "real" database would be needed.


What do you mean by, "because of concurrency"?

I know it is insecure, but I would store everything in a txt file where 
each line is a link.


Then you can reach your link with http://myperfectsite.org/

If you don't want your id to be consecutive, a tsv file would do the 
trick with a hash then the link.


Is there a problem with this approach ?





Re: [dev] running a shortlink provider

2023-05-25 Thread Teodoro Santoni
2023-05-25 7:29 GMT+02:00, Страхиња Радић :
> Perhaps the most minimal solution for keeping data would be TSV files, but
> they
> are not suitable for storing data entered from the web because of
> concurrency,
> so a "real" database would be needed.
>

Probably it can be duct-taped writing new entries/edits on separate
random files to be merged, however it's a poor man's write-ahead
journal so an sqlite file or more would be more consistent.



Re: [dev] running a shortlink provider

2023-05-25 Thread Spenser Truex
Highlight:

Link shorteners always go down due to non-funding and bloatware
backends. Let's have a suckless one that is cheap to run!

On 23/05/25 07:02AM, Marcel Plch wrote:
> On Thu, May 25, 2023 at 12:47:20AM -0300, Spenser Truex wrote:
> > Hello,
> >
> > My internet friends and I have been wanting a shortlinks provider. How
> > can I do this in a suckless way? I'd like to be able to host the
> > shortlinks provider and easily let my friends point their own domains at
> > my VPS.
> >
> > I used to just upload a HTML file with a redirect to the desired
> > location in my webserver root. This doesn't work for a shared service
> > though.
> >
> > There are a lot of bloated projects that I've found. Any suggestions?
> >
> >
> > --
> > CAEE B377 FC82 BAF9 102C  D22F C5CE D003 1AA8 E281
> > Spenser Truexhttps://equwal.com
>
> 1) VPS
> 2) Pick favorite Web stack
> 3) Make a website that takes the specified URL, stores the URL and its
>hash as a key-value pair (possibly in a database if that's suckless
>enough for you, directory+file structure is probably okay as well.)
> 4) Store the hash value in base64
>
>
> I personally would go for Python/Django, I'm not sure how suckless that's
> considered (probably not at all) but I found Django to be about the
> least bloated fully functional web framework. Web is in a sad state so
> I'm sure Unix gods are gonna reward you even if you write a minimalistic
> web in Django.
>
> Django also uses sqlite by default as a database backend, so it's not even
> a glass cannon. It knows that unless you bother to set something up, you
> probably don't need something special.
>
>
> I'm sure this suggestion is going to be either extremely helpful or
> upsetting. Let me know what you picked. ^_^

If we are going with "write your own backend" I'll do it in Common Lisp
since I like it. It's even more lindy than C. I guess the suckless lisp
is LISP 1.5. I suppose C could make a decent backend too, although I'm
not really up to the task of doing it with C. That being said, it's a
lot of work for something that has been redone a million times already.

I did some more research and found hda.me's codebase. It uses nginx and
postgresql. I'm not sure I want to use all that, but if I could make a
backend that is compatible for the F-Droid app then that would be neat.
The feature of either making 3-character tiny links that disappear, or
longer links that last a long time is very smart.

I found a bloatware that lets you just choose whatever link you want,
but I don't think I'd want to let anyone use my domain to make vanity
links like mydomain.com/mydomains-owner-is-a-cunt

The hda.me owner said he stopped funding it because he needed multiple
VPSes and cloudflare service to avoid getting his data-holding VPS shut
down for malicious use of the link shortener. This is avoidable by just
using a decent VPS provider and doing routine full disk backups just
in case. My intended use case is for each person to use their own domain
to make their own links, not really as a public link shortener.
-- 
CAEE B377 FC82 BAF9 102C  D22F C5CE D003 1AA8 E281
Spenser Truexhttps://equwal.com


signature.asc
Description: PGP signature