Live data from Hacker News

Show HN: I created a URL shortener that can be entirely hosted on GitHub Pages

github.com

141–150 of 182 posts

Re: Show HN: I created a URL shortener that can be entirely hosted on GitHub Pages

#141

Interesting, I just did http://nlsn.cf/54 . I just found a "bug" that can be abused (in chrome at very least). URL('http:53') returns https://0.0.0.53 (it casts the int32 number to an ip address, dont' ask why). But window.location.replace behaves differently and treats it as a relative URL.

Wow.. I don't even know where to start.. Thanks for the heads up that's cool beans!

Re: Show HN: I created a URL shortener that can be entirely hosted on GitHub Pages

#142

> Unlike many URL shorteners, this one does not need a database and can be entirely hosted on GitHub pages. it does need a database though. it just uses someone else's database

A URL shortener can be done with no database - I did it using only Lambda functions once, but I wouldn't recommend it. :) https://kevinkuchta.com/2018/03/lambda-only-url-shortener/

Haha this is fantastic. Are the IDs still coming from that single counter lambda? Or put another way, do you now have 1,750,785 lambdas in your AWS account? :)

Re: Show HN: I created a URL shortener that can be entirely hosted on GitHub Pages

#143

This currently uses about 100KB of JavaScript (over 99KiB of polyfills, about 3KiB of actual code), loading the HTML file, then three JavaScript files, then making an API call to GitHub, then finally doing the actual redirect, by a substantially inferior JavaScript technique. Also, it doesn’t work on IE because the polyfills were insufficient. Yes, this is an interesting technical demonstration of a concept, but it a…

Thank you for the reply! I definitely learnt a lot from your comprehensive replies. Personally, I am just getting started in web development and I have traditionally written everything with the help of frameworks like ReactJS and the like and the abstractions these frameworks provide means I actually don't know the nitty gritty of how things work. Cross browser compatibility or efficiency was definitely not something I considered and they are definitely very valid considerations. And HTTP redirects via service workers sounds damn interesting! I will go read up on those now! Thank you for the comment I did learn a lot and will work these suggestions into the code base when I do have the time :')

Re: Show HN: I created a URL shortener that can be entirely hosted on GitHub Pages

#144
post #129

I was always fixated with URL shorteners and always wanted to write one myself. While it would be easy to write one that works with a server, I loved the idea of hosting and running one for free. Thus, I wrote this URL shortener which does not need a backend to work at all. It uses GitHub issues as a "database", and unlike most other URL shorteners that do not need backends, this one doesn't need a # prefixed to the…

"I was always fixated with URL shorteners and always wanted to write one myself. While it would be easy to write one that works with a server, I loved the idea of hosting and running one for free." I felt exactly the same way and did, in fact, build one.[1] It was pretty simple. There's an interesting twist to the particular one I built - it's not specifically a URL shortener, it's a "Universal Shortener".[2] Also no…

Since we're on HN, and this isn't addressed in either FAQ: did anyone end up paying for custom codes?

Re: Show HN: I created a URL shortener that can be entirely hosted on GitHub Pages

#146

Earlier quoted context omitted.

A URL shortener can be done with no database - I did it using only Lambda functions once, but I wouldn't recommend it. :) https://kevinkuchta.com/2018/03/lambda-only-url-shortener/

Haha this is fantastic. Are the IDs still coming from that single counter lambda? Or put another way, do you now have 1,750,785 lambdas in your AWS account? :)

Yeeeeeeep. :) Someone automated spinning up new IDs at some point and flooded this service with urls. I wrote a script to delete old ones, but it takes a few days to run and I haven't gotten around to letting it finish.

Re: Show HN: I created a URL shortener that can be entirely hosted on GitHub Pages

#147

Earlier quoted context omitted.

A URL shortener can be done with no database - I did it using only Lambda functions once, but I wouldn't recommend it. :) https://kevinkuchta.com/2018/03/lambda-only-url-shortener/

I've seen people suggest using pi as a "database." In this instance you could map ranges of pi to characters. Then you search pi until you find the right range. The URL would contain the range(s) needed. This is terrible and so computationally wasteful. But it's interesting to think about.

Seems technically possible - example.com/12_3456 would calculate out pi, read 12 digits starting at position 3456, then convert those digits to ascii and you'd have your result. Given how far into the digits pi you'd have to go to find the exact right sequence that matches, eg, https://google.com, though, I suspect the resulting position number would be longer than the original url!

Also, conceptually, it seems like you're not so much using pi as a database as you are using it as an encoding mechanism: turning "abc.com" into a string of numbers whose length is relative to the original string. At that point you might as well pick an easier encoding, like base64. :)

Re: Show HN: I created a URL shortener that can be entirely hosted on GitHub Pages

#148
post #140

Earlier quoted context omitted.

I've seen people suggest using pi as a "database." In this instance you could map ranges of pi to characters. Then you search pi until you find the right range. The URL would contain the range(s) needed. This is terrible and so computationally wasteful. But it's interesting to think about.

In a similar vein, almost every algorithm can be converted into a O(1) space version simply by converting it into the dumbest possible search algorithm over the solution space: just sample from the solution space randomly (with a seeded PRNG or something) until you get the right answer. A well-known example of this is bogosort: https://en.wikipedia.org/wiki/Bogosort

Interestingly, bogosort cannot actually be implemented in constant space -- at least, not if you're talking about a deterministic algorithm. In order for your PRNG to have a large enough state space to cover all possible permutations, it needs O(n log n) bits.

In the Turing machine model of computation, algorithms that use O(1) space are theoretically equivalent to finite state machines (potentially with a very large number of states). Logarithmic space is where things start to get interesting, because it's enough to store a constant number of pointers into an arbitrarily large input.

Re: Show HN: I created a URL shortener that can be entirely hosted on GitHub Pages

#149
post #129

Earlier quoted context omitted.

"I was always fixated with URL shorteners and always wanted to write one myself. While it would be easy to write one that works with a server, I loved the idea of hosting and running one for free." I felt exactly the same way and did, in fact, build one.[1] It was pretty simple. There's an interesting twist to the particular one I built - it's not specifically a URL shortener, it's a "Universal Shortener".[2] Also no…

Since we're on HN, and this isn't addressed in either FAQ: did anyone end up paying for custom codes?

Yes! People do, in fact, buy codes.

I've spent almost zero time on "Oh By" in the last 24 months as things at rsync.net have been very busy. So, we haven't made a sale in months due to lack of publicizing it.

However, I think there are unknown, emergent use-cases out there for "Oh By" that I hope people will discover. I am going to pivot back to "Oh By" next year ...

Re: Show HN: I created a URL shortener that can be entirely hosted on GitHub Pages

#150
post #129

Earlier quoted context omitted.

"I was always fixated with URL shorteners and always wanted to write one myself. While it would be easy to write one that works with a server, I loved the idea of hosting and running one for free." I felt exactly the same way and did, in fact, build one.[1] It was pretty simple. There's an interesting twist to the particular one I built - it's not specifically a URL shortener, it's a "Universal Shortener".[2] Also no…

Oh that is cool! It does remind me of https://telegra.ph/ by Telegram! (Even though they weren't really advertising it as a universal shortener). Just a quick question, how did you promote your platform!

I've done almost nothing to promote it. I just mention it once in a while (like now) when the topic of shorteners comes up.

I also sent a notice to all rsync.net customers, years ago, when we launched it.

That's it.

Post reply on HN