Skip to content. | Skip to navigation

Personal tools
Log in
Sections
You are here: Home

jorgenmodin.net - Blog

Breaking changes in Riot-js 4, first impressions from the migration guide

Posted by admin |

Firstly, it's interesting with a migration guide that starts with saying you should not migrate. What is meant afaict is that you should upgrade your brain to write for Riot 4, but keep old components on e.g. Riot3.

Migration Guide · Riot.js

Version 3 documentation is here https://v3.riotjs.now.sh/

A number of things have changed that I have not used, such as the observable pattern and referencing parents and children.

More verbose

Pretty much all changes will make you write more code inside of a web component. That is a minus I think.

Some good things

The general idea is to be more compatible with contemporary javascript syntax.

There is one thing that has changed that I think is for the better and that is that the "refs" way of referring to DOM elements is gone and instead replaced by the jquery-like selector "$". That makes more sense. I have never used the "yield" tag but it sounds like the new term "slot" is a better word for it.

Some things that add lines of code

Methods operating on the component now need to be wrapped inside an "export default" block, which adds code. I guess you could just put the method names in there and keep the rest outside of the export block. The inline logical statements of the form {truthyOrFalsyTing ? 'iftrue': 'iffalse'} seem to have been removed, and instead you are supposed to create or import functions and put them in the template.

Conclusion

I see no reason to upgrade now, which is inline with the recommendation in the upgrade guide. I'll look through a bit more later onto the new things and see if there is some cool stuff that I'd like to use.

Also

It is hard to find the old docs on the riot site for verison 3, I think they have been deleted, and hence many Google links are broken. I had to go to GitHub to find stuff. I now see that the new FAQ refers you to https://riot.js.org/v3, but that page does not exist.

Jun 06, 2019 02:40

How to add a 12GiB swap volume on Ubuntu

Posted by admin |
sudo fallocate -l 12g /mnt/12GiB.swap

sudo chmod 600 /mnt/12GiB.swap

sudo mkswap /mnt/12GiB.swap

sudo swapon /mnt/12GiB.swap

echo '/mnt/12GiB.swap swap swap defaults 0 0' | sudo tee -a /etc/fstab

Source: https://help.ubuntu.com/community/SwapFaq#How_do_I_add_or_modify_a_swap_partition.3F

May 23, 2019 11:20

"docker-compose up" on Ubuntu 19.10, by Jove it stays up!

Posted by admin |

I had to run a docker-compose file today to get access to some cool services and had big problems getting the services out of it that I thought I would. It all seemed a bit old. It turned out that I ran an older version of this file 2 weeks ago, and I never ran "docker-compose down". I did do a ctrl-c though which in older Ubuntu versions seemed to settle the matter. But in 19.10 it seems different. It stays up.

Those old containers have been running on my laptop through hell and high rain for two weeks now, through approximately 20 restarts and shutdowns of the laptop. And I could not get them down afaict with "docker-compose-down" now, since that file has changed. Systemd starts docker every reboot and then docker starts its stuff, including the containers.

I had to resort to docker rm and docker kill to get the new stuff up.

May 22, 2019 03:40

How to set up a semi private Syncthing system

Posted by admin |

Syncthing is designed to be secure even when running mutual discovery between your computers and relaying their data — through servers that are all run by other people. As long as the TLS encryption holds up, the data should be safe. But if you think it may not be safe you may want to run it a little more private. First in order to make it somewhat private you will need to set up a relay server; you can see my notes here for Ubuntu: Notes on getting a syncthing relay server running on Ubuntu 18.04LTS


However, the computers cannot discover each other through the relay server, for that a discovery server is needed. This threw me a bit, since I thought the relay server would be enough. However it is not. This means that you need to run a private discovery server or be cool with the public discovery server. How you feel about depends a bit on whether you're cool with the announcements of your machines being somewhat public or not.

May 06, 2019 05:20

Notes on getting a syncthing relay server running on Ubuntu 18.04LTS

Posted by admin |

I created a dedicated user with a shell so that I could easier see why things did not work. It may also automagically work if you do everything right from the beginning.

It can be good to know that the server is called "strelaysrv" on Ubuntu, which the Ubuntu man page does not mention, but instead uses the "relaysrv" name.

You have to make sure the keys for the server are stored where the server can find them. One way of doing this is to supply the -keys parameter to ExecStart in systemd. For a systemd conf, see https://wiki.archlinux.org/index.php/Syncthing#Running_a_relay

Clients will not connect to the server unless they know the server's key, so you have to configure them with an id parameter and not just protocol, server and port:

relay://server.example.com:22067?id=<id string>

The key is output by the server on startup, which you can catch if you run it from the command line (if you have shell).

If you forget to incude the id of the relay server, these are the errors you get (or at least I got) on the client side:

Disconnecting from relay relay://relay.example.com:22067 due to error: EOF
c.S.listenerSupervisor: Failed service 'relay://relay.example.com:22067' (2.985913 failures of 2.000000), restarting: false, \
error: "{relay://relay.example.com:22067 relay://relay.example.com:22067} returned unexpectedly", stacktrace: [unknown stack trace]

On the server side I believe it was:

read: connection reset by peer

and:

connection refused

 

May 02, 2019 12:55

Serverless Syncthing vs Dropbox — You may need a server anyway

Posted by admin |

Since Dropbox doesn't support my file systems anymore, I decided to take a look at Syncthing and Sparkleshare, free and open source folder synchronization alternatives. Syncthing is by far the most polished of these two offerings. It's also cool in that it is peer-to-peer and hence has no center.

Instead it goes point to point and if that doesn't work it (which due to NAT it often does not) it relies on a public cluster of relay servers, or you can run your own if you do not trust that the public servers are unable to read the encrypted traffic.

However the p2p nature of Syncthing becomes a bit of a problem if you want to sync between your own devices, because obviously the sync can only work if the machines are switched on and online at the same time. For your laptops, this is unlikely. And hence Syncthing does not work for that scenario. Unless you have an always on machine also in the mix (you can sync many machines, not just two).

But what do we call a machine that is always switched on? Yup, a server. Although the system would be robust since if you lose that machine you can just fire up another one and everything works again.

Still Syncthing feels like it is more for synchronizing files between people. And there git may be a contender. Still Syncthing looks great and I will see if I can tailor it to my needs. Worst case scenario I'll put two servers in the mix, one for relaying and one for making sure synching always works!

That would be two-server serverless architecture :) But with great resilience since the servers can be replaced at any time.

Apr 28, 2019 11:15

Autostart programs and scripts in ubuntu

Posted by admin |

There is a GUI for that (tested by me). Just find the autostart GUI application through your application launcher. You can also edit directly the desktop files that are constructed in ~/.config/autostart . Keep in mind though that the GUI decides the names there so if you need to find and edit a specific statup you may need to look around a bit!

Read more: Link - autostart - How do I start applications automatically on login? - Ask Ubuntu

Apr 28, 2019 08:15

Timeout a function in Javascript

Posted by admin |

Here's one way that seems to work, you set a time to change a function-scoped variable and return out of the function when that changes.

function thisShouldTimeOut() {

  var shouldIStopDoingThis = false

  setTimeout(() => {
    shouldIStopDoingThis = true
  }, 2000)

  for () { // some loopy stuff
    if (shouldIStopDoingThis) {
      return
    }
  }
}
Apr 05, 2019 02:50

Updating a part of a Riot.js tag

Posted by admin |

Edit 2019-04-07: This does not work!

 

In order to get a less jumpy page, I'm looking at how to render just a sub part of a Riot.js tag. According to this conversation it should be possible. The example given is this:

var item = this.tags['big-data-tag'].tags.item[0]
item.first_name = 'jack'
item.update()

I think it could be adapted to work like this, untested by me:

 

<maintag>
    <subpart>
        { onlyupdatethis}
    <subpart>
Some other stuff that is static

   <script>
   const tag = this

     this.on('mount', function () {
       stateManager.subscribeToUpdates(function(state){
          tag.tags.subpart.update()
        })
       }   
      )

   </script>

</maintag>

 

Apr 04, 2019 02:55

Notes on order of speech processing and on automix

Posted by admin |

These are just some notes jotted down for my memory, so not authoritative at all, not even inside my own head yet :)

Remove noise → Compress → Normalize

After having watched one of Curtis Judd's videos it was clear it is a good idea to compress/limit before normalizing. There may be some peaks otherwise in your recording that would make the normalizing not be good enough. Also I noted that Judd eyeballs on the left hand dB scale where to put the compressor's knee. That makes sense too.

And completely on my own I realized that noise reduction should go first in the chain. Chances are your noise is at a certain level and it's easier to remove it before compression has introduced a varying noise floor.

Automix

Finally in this post, I have seen that some newer digital recorders and mixers have "automix", that is they mute the microphones of those not talking. This I think would be a great feature to have in post-production! Imagine having six tracks and you just tell the software to automix it. I guess that exists somewhere. Otherwise it would be fun to write an algorithm for it, for post production. You could do voice detection (is this voice?) and amplitude detection, reverberation detection, phase and distance detection (like in a microphone array) and so on.

Update 2019-04-24

Julian Krause has just released a video with his workflow, it's a bit different: https://www.youtube.com/watch?v=GVovXsbCjjU

He normalizes the audio first to a certain LUFS level, then removes rumble and proximity effect with high pass filters, then applies a compressor and a noise gate. What is most interesting for me here is that he sets the attack of the compressor to 1ms and the decay to I think it was 100ms, settings that are on the shorter side but that he argues make sense for voice. Gotta try that.

Mar 27, 2019 09:20