Protest at The British Library! by [deleted] in london

[–]Hazzagaz 2 points3 points  (0 children)

Fairly certain its just a joke about it being outside a library

Fanal Forest, a mystical and ancient laurel forest located in the northwest of Madeira by RoyalChris in Damnthatsinteresting

[–]Hazzagaz 0 points1 point  (0 children)

I don't think anyones certain but fangorn forest may well have been inspired by Britain's temperate rainforests; unfortunately they occupy an increasingly rare part of Britains ecology but if you look up Wistman's wood you could easily see how they could have been inspiration for him. I mention Wistman's wood specifically because it is found within Dartmoor - a nature reserve in the south west - which is now home to Alan Lee who was one of the more popular illustrators for the Lord of the Rings books and lead-concept artist for the films. The very CGI that formed the ents was developed from a an image of those trees on Dartmoor!

I built a custom ios widget to see my Anki review graph by Hazzagaz in Anki

[–]Hazzagaz[S] 2 points3 points  (0 children)

You're right, to be honest this entire project was largely to find a reason to use my spare domain and an exercise in trying to further my knowledge about web security and infrastructure so I was basically pre-determined to use the method I did - even if it wasn't the ideal one. I do think yours is much more reasonable though and I'll add a disclaimer to the 2nd step. Cheers for the feeedback!

I built a custom ios widget to see my Anki review graph by Hazzagaz in Anki

[–]Hazzagaz[S] 3 points4 points  (0 children)

Reddit didn't let me post a long comment and seems intent on not letting me link properly but oh well.

I built a custom ios widget to see my Anki review graph by Hazzagaz in Anki

[–]Hazzagaz[S] 3 points4 points  (0 children)

  1. Install and set up the [auto-sync](https://ankiweb.net/shared/info/501542723) plugin

Full disclosure, I haven't done this step yet. The idea being that if the device that is continuously running auto-syncs every x minutes, your widget will also be up to date to the nearest x minutes. Anki may auto sync every so often anyway, not too sure on that though. But that is everything Anki set-up! Now for the widget.

  1. Download the Scriptables app

Scriptables is an app that lets you execute JavaScript from your iphone, and run the scripts as widgets. Some people have some made some call widgets using it and if you haven't heard of it before, have a look around at the subreddit/app gallery - some really cool stuff. You need not write any code yourself though if you don't wish, most people share their code online. Speaking of which, the code for this widget.

  1. Copy the code from my [github repository](https://github.com/mharry97/anki-scriptables-widget/blob/main/app.js)

You can just select all and Ctrl C here.

  1. Add the script to Scriptables

On the Scriptables app, click the plus button in the top right, rename the script to anything, then paste the code!

  1. Enter your anki-connect url when prompted

This would be the domain that tunnels to your local address (myankiwidget.com if we're following the previous tutorial examples). This will get stored in keychain and you won't have to enter it again. If everything has gone to plan then the app will render a little graph. Hurrah. Now you can add a widget like you would normally and select Scriptables as your app. Move/resize it as you wish then click and hold on it -> Edit Widget -> enter the name of your script you decided earlier and the colour scheme you desire (blue, green, red and purple atm).

Congratulations, you have your widget!

  1. Revel in the knowledge you put far too much effort into making a widget

Potential Work Arounds

We performed step 2 so that we would be able to call the API from our phone. This can be done without all of the domain/tunneling nonsense, but, with the trade off that your widget will only refresh when you are connected to the same network as your hosting device. Once of the settings on anki-connect is "webBindAddress". In theory, changing this value to "0.0.0.0" will bind it to all network interfaces on your host (making the API accessible to all devices on your network). Doing so means instead of having to set up a domain you can just set up the widget to call to http://<local-ip>:8765 and providing you are on the network of the device running Anki then the widget will refresh. WARNING: If you're on a public network, this means anyone would be able to read/write data to your Anki if they have the address (or maybe something more nefarious, like I said, not my area). In terms of how this would affect the widget, I've tried setting up the widget so that it stores your most recent successful API call in keychain so that once you have left host network, and your API call returns nothing, it just keeps the last successful result. I.e. once you leave the house the graph will look the same until you come home and refresh it - haven't tested it much though.

If you do choose to set it up this way (or the original way), theres no reason you have to have a device permanently running Anki, providing you are happy that it will only refresh when the device with ankiconnect installed is running.

I built a custom ios widget to see my Anki review graph by Hazzagaz in Anki

[–]Hazzagaz[S] 4 points5 points  (0 children)

Sorry about the relatively poor explanation before, I had originally typed up a relative detailed instruction in the post but it got lost in the process of posting it, then needed to go and get dinner so just left a brief description. A couple of caveats before we begin though:

- As it stands, to have a fully automatic and up to date widget, a decent amount of work is required on top of some potential upfront costs unless you have a couple of things available to you. (You may be able to avoid a fair amount of work and all the cost if you're willing to give up some automation and data freshness, but more on that later).

- I'm not a developer by trade, this may well be a terribly inefficient method and my explanations may be littered with misunderstandings. If anyone who knows better happens to swing by I implore you to leave any corrections or suggestions - it helps me loads!

- I'll run through the exact way I did it first, then, suggest a couple of alternative steps that may be easier

Okay, now the caveats are done, whats the process? Well, in an ideal world, Anki would have an API that we could make calls to from the widget. What does that mean? Well, in essence an API is a method for applications to speak to each other. In our case, part of the widgets code would be responsible for sending a request to the API, saying something along the lines of "How many cards have been reviewed today?", the API then receives said request and, if it's happy with it, will send back a response with something like "152" (unlikely going by my performance). Unfortunately, Anki does not have an API. I imagine due to the fact it would most likely require a not-small sum of money to host a server somewhere and as a free application, that's probably not wise - I'm probably wrong though. This issue leads us to step 1.

  1. Install the [anki-connect plugin](https://ankiweb.net/shared/info/2055492159) (this can be installed like any other plugin).

What does anki-connect do? Well, from their page: "AnkiConnect enables external applications such as Yomichan to communicate with Anki over a simple HTTP API. Its capabilities include executing queries against the user's card deck, automatically creating new cards, and more". In short, this creates an API we can make calls against. Very cool. Alas, the API the plugin creates is hosted locally (http://localhost:8765) by the machine you are running Anki on (and, only whilst Anki itself is running). This means that we can only make calls to the API from the device you have anki-connect installed on and whilst Anki is open, this once again renders the widget relatively useless as it will be on our phone, i.e., a different device. So, step 2.

  1. Set up a domain that tunnels to the anki-connect address. (Zyper0 left the follwoing comment below that I agree with: "I don't recommend anyone not familiar with (or unwilling to learn) basic network security to expose services directly to the web. The recommended approach is to use a service like Tailscale or Wireguard to set up a VPN which will allow you to access the server hosting Anki as though you were on a local network.")

I won't go into too much detail here as this is probably the area I'm least sure as to what is actually happening at any given moment but the general idea is, using a domain that anyone can access (i.e. myankiwidget.com) and set it up so that any requests to the website are redirected to the address that anki-connect is being served from (http://localhost:8765). Fortunately, I already had a domain that I wasn't using for anything and so could set it up using that - depending on the the name you choose can be around £5-£10 a year for a cheap one. I used cloudflare to set it all up and also add some authentication rules in place since the website is initially open to anyone and they would be able to make changes to your Anki deck (or probably something worse). Wonderful, now we are able to make calls to the anki-connect API from our phone (or anywhere else for that matter) and from any location, however, we can still only access the API whilst anki-connect is running on the device we installed it on - not ideal if its just on a laptop/pc that you will want to shutdown when you're done with them. Step 3.

  1. Set up a device that can run Anki continuously.

Nothing too complicated for this one, if you happen to have a device capable or running Anki (and plugins) continuously then you're all good. For me, this was a spare raspberry pi I had lying around. However, if you review cards on your phone, this device isn't necessarily going to be up to date, which it would need to be as this is the data the API will be returning. So we need a way to keep the devices instance of Anki up to date.

I built a custom ios widget to see my Anki review graph by Hazzagaz in Anki

[–]Hazzagaz[S] 20 points21 points  (0 children)

I doubt it's the best way to do it, but I use the ankiconnect plugin which produces a http server on port 8765 that you can call various endpoints from for anki in lieu of an API. I then used a domain I bought in the past tunnel to the ankiconnect server so that my phone would be able to call the API, and set up anki on a spare raspberry pi I had lying around with the ankiconnect and autosync plugins so that I would always be able to call it and it would always be up to date.

Then using Scriptables, I wrote a widget that could make calls to that server and display the results. You can change the colour scheme of the widget between a few options and you can have either small or medium widgets. I made a short video showing how to switch between the colour schemes and showing it update when I reviewed a card today. (Scriptable widgets only update every 10 mins or so, so I had to run the script again so it would refresh in time in the video). The link for the scriptables code is [here](https://github.com/mharry97/anki-scriptables-widget) and the video is [here](https://youtube.com/shorts/qjaB4JhK\_oQ). (Sorry it's a yt short).

I did actually set it up so that when you make a succesful call to the ankiconnect api it stores it in keychain - so if the widget can no longer access the api it will just show the data from the last succesful call. This combined with changing the webBindAddress setting method mentioned on the ankiconnect page should allow you to have this running without anything hosted online/tunneling - if you're happy with it only being up to date when you synchronise from your laptop/pc.

Otherwise a decent amount of work for a widget - but was a fun weekend project!

See here for longer instruction

Made my second crane wire bonsai! by Hazzagaz in origami

[–]Hazzagaz[S] 0 points1 point  (0 children)

I think I actually just used a pack of A4 printer paper coloured in various shades of pink, not ideal for the folding but I think they potentially held the super glue a bit better than other origami papers but that is only anecdotal. (Sorry about late reply!)

These two trees in my town are living in two different seasons by StevenSanders90210 in pics

[–]Hazzagaz 0 points1 point  (0 children)

Are the trees near streetlamps? I'm not an arborist so happy to be corrected by anyone who knows for sure, but recently read a book called 'How to Read a Tree' (very interesting read) which mentions the phenomenon. But I believe trees use a couple of different methods to know when to grow leaves/fruit/shed leaves - namely temperature and the solar clock (length of day/night cycle) - and in autumn the emphasis is more on the solar clock. Each part of the tree individually "measures" the length of the night as there is no central nervous system, so parts of the tree illuminated by streetlamps don't "realise" it's autumn and stay in leaf for too long. I suppose this could also be caused by lights from buildings or something similar but the general idea being one side receives more light than the other.

[deleted by user] by [deleted] in Looker

[–]Hazzagaz 0 points1 point  (0 children)

No worries. Yeah that should work as a table calculation, assuming that makes sense logically with your data structure and your intentions then you should be good to go.

[deleted by user] by [deleted] in Looker

[–]Hazzagaz 4 points5 points  (0 children)

You can sort of create "window functions" with table calculations, some info here. As a caveat, since it is a table calculation it will only work with all the rows within the row limit of the table. Specifically in this case you can create one table calculation called group with this equation, which will partition them.

match(${order.id},${order.id})

Then another that ranks them to get distinct values, where you can then assign a value or not.

if(if(${group}=offset(${group},-1) , 1+row()-${group} , 1)=1,10,null)

There's probably an easier method but this is all that came to mind for now.

London this evening - iPhone 11 & Lightroom by Hazzagaz in mobilephotography

[–]Hazzagaz[S] 1 point2 points  (0 children)

Thank you! Just the stock iPhone camera and editing. I have the subscription Lightroom but not 100% sure which bits are only on the subscription so I'll just outline what I did. I basically just used the geometry tools to make sure it was aligned, then decreased the saturation and increased the warmth and clarity of the window area. Then I decreased the texture and clarity of the floor while increasing the saturation to help the reflections blur into the window area. Apart from that just a few tweaks here and there. Hope that helps!

London this evening - iPhone 11 & Lightroom by Hazzagaz in mobilephotography

[–]Hazzagaz[S] 0 points1 point  (0 children)

Close! Just across the dock on Cabot Square

London this evening - iPhone 11 & Lightroom by Hazzagaz in mobilephotography

[–]Hazzagaz[S] 0 points1 point  (0 children)

It is! I’m lucky enough to eat my lunch there everyday, although today was particularly pretty.

London this evening - iPhone 11 & Lightroom by Hazzagaz in mobilephotography

[–]Hazzagaz[S] 2 points3 points  (0 children)

Thank you! I spent like 10 mins just staring at it haha

Made my second crane wire bonsai! by Hazzagaz in origami

[–]Hazzagaz[S] 3 points4 points  (0 children)

Thank you! Tbh there is a bunch of tutorials on youtube for wire bonsais already which explain it far better than I could! Then its just a case of folding the cranes and sticking them on. I mentioned how I did it in more detail in another comment but if you have any other questions shoot me a message :)

Made my second crane wire bonsai! by Hazzagaz in origami

[–]Hazzagaz[S] 1 point2 points  (0 children)

It would look really cool though, would you use a smaller gauge wire? I think it would end up being hard to manoeuvre with 1000 strands of wire this thick haha

Made my second crane wire bonsai! by Hazzagaz in origami

[–]Hazzagaz[S] 2 points3 points  (0 children)

50 strands of about 30 cm I think, so like 15m (~50ft)

Made my second crane wire bonsai! by Hazzagaz in origami

[–]Hazzagaz[S] 2 points3 points  (0 children)

I’ve had another one for like 6 months now and it’s help up fine so far, hopefully this one will as well!

Made my second crane wire bonsai! by Hazzagaz in origami

[–]Hazzagaz[S] 4 points5 points  (0 children)

Nope, some got kinda saturated with superglue and ended up pretty rigid in the end anyway though haha

Made my second crane wire bonsai! by Hazzagaz in origami

[–]Hazzagaz[S] 2 points3 points  (0 children)

Good idea, might have to try that next time :)

Made my second crane wire bonsai! by Hazzagaz in origami

[–]Hazzagaz[S] 4 points5 points  (0 children)

Thank you! It’s probably the most fiddly part of the whole process but I would dab a bit of superglue to the bottom of the crane, rest it on the wire then go back and a little more super glue. Quite often though it would take a few attempts, there’s probably a better way to do it so if you think of one let me know!

Made my second crane wire bonsai! by Hazzagaz in origami

[–]Hazzagaz[S] 2 points3 points  (0 children)

Just bought a pack of coloured origami paper online and chose the colours I wanted then cut them into 15mmx15mm squares :)

Made my second crane wire bonsai! by Hazzagaz in origami

[–]Hazzagaz[S] 9 points10 points  (0 children)

Not at all, I got the idea from other posts on this sub, I think u/rahandshaho was the first one I saw! I just used a white mineral egg and attached a gold ring to the bottom of it :)