algorithms – Understand implementation of exponential moving average (in case of unix load average)

The UNIX load average gives 3 numbers over 1/5/15 minute time intervals. It’s supposed to be an indicator of how busy a UNIX machine is. The global load average is an exponentially decaying average of number of runnable/uninteruptable tasks.

I’m interested to implement such kind of exponential decay algorithm in my project for a slightly different purpose, but also to take averages. So I did some research how exactly this load average is computed in UNIX.

Nowadays the implementation is quite involved for various reasons. Since I’m mostly interested in the exponential decay part when computing the average, I found a simpler description of the original implementation:

#define FSHIFT    11          /* nr of bits of precision */ 
#define FIXED_1   (1<<FSHIFT) /* 1.0 as fixed-point */ 
#define LOAD_FREQ (5*HZ)      /* 5 sec intervals */ 
#define EXP_1     1884        /* 1/exp(5sec/1min) fixed-pt */ 
#define EXP_5     2014        /* 1/exp(5sec/5min) */ 
#define EXP_15    2037        /* 1/exp(5sec/15min) */ 

#define CALC_LOAD(load,exp,n) 
 load *= exp; 
 load += n*(FIXED_1-exp); 
 load >>= FSHIFT;

From http://perfdynamics.blogspot.com/2014/06/load-average-in-freebsd.html, where they say:

The CALC_LOAD macro is updated (internally) every 5 seconds and the m-index in eqn.(1) refers to the weight associated with each of the 1, 5, or 15 minute averaging windows.

What I don’t understand: If there is a loop, which on each iteration gets n, the number of tasks, every 5 seconds, then how do the exponential decay constants here help to take the load average of 1 minute, 5 minutes or 15 minutes?

A simple example that could be calculated with pen & paper would be really useful.

dnd 5e – Is a Dryad able to issue commands to a charmed creature that doesn’t understand Sylvan or Elvish?

A Dryad can use Fey Charm to charm a beast or humanoid. The result is that:

  • The target is charmed; it cannot willingly harm the Dryad.
  • The target is charmed; the Dryad’s social checks against it have advantage.
  • The target ‘regards the dryad as a trusted friend to be heeded and protected.’
  • The target ‘takes the Dryad’s requests or actions in the most favourable way it can.’

The Dryad can issue commands to beasts using its ability to speak with beasts and plants. Can it also issue commands to charmed humanoids who do not share an understanding of Elvish or Sylvan (the two languages spoken by the Dryad), or is the ability’s effect limited in these cases to the effects of the charmed condition and the regarding of the Dryad as a trusted friend?

applescript – How to understand Script Editor dictionaries?

I found here an interesting example of Apple script commands such, for instance,

tell application "System Events" to get properties of every desktop

and I would like to understand, where these commands are documented. I found the explanation for the tell command, and I understand that we have to use the “Systems Events” app for this task. I even discovered the “Script Editor” app and inside it, I opened the Dictionary for “System Events”, and find plenty of definitions, which are likely methods we can invoke on the “System Events” object.

However, I did not find any explanation of the keywords get or every in the above command. Using the Search field and entering “get” and “every” did not bring up anything useful. Perhaps they are some keywords with a predefined meaning.

I could type “desktop” in the search field, and find as explanation something like this (abbreviated):

desktop n : desktop picture settings
elements
contained by application.
properties

name (text, r/o) : name of the desktop

id (integer, r/o) : unique identifier of the desktop
….

My guess is that ‘desktop’ is the instance of some object, which in turn is contained inside another object of class application, and that we can send it methods such as name or id. However, I don’t see any relationship to the tell application command above, and how we could logically conclude from this Dictionary explanation that this command would magically show us information about the desktops.

My programming background is Ruby/Python/Perl/C++/zsh and a bit of Haskell and Java, and I thought I would be able to understand library references of other languages somehow, but this one is too much for me…

Any help appreciated!

Cant understand how share difficulty affects my chances in solo mining with a pool

So obviously I am not solo mining bitcoin but I think the underlying principles are the same so you guys could help me out here.

I am solo mining ergo on a solo pool (herominers solo pool)

What I do not understand exactly is what **share **difficulty is (not to be mistaken with ergo network difficulty which I understand)

I mean I hash with 2GH/s on ergo I am able to switch between varying share difficulty (which I have notices goes up to like 80GH difficulty) or choose a constant share difficulty.

What I noticed is that if I set that difficulty to 8GH I get more solo valid shares…

But does this mean that the probability of me finding a block decreases because finding a block needs a higher GH share or something like that ?

Could you explain in detail what share difficulty is and maybe advice me if I should use varying difficulty in my case or a constant (and at which value? ) ?

How to understand the margin trading in Binance?

I am using Binance. Let’s say I have 0.00102BTC, from which 0.00068BTC. I bought these 0.00068BTC by borrowing Euros. The BTC/EUR ratio is equal to 35,854$. If BTC goes up for 100$ or 0.028BTC then my profit 0.001*0.028 BTC? Maybe there is a way to infer the profit from the ratio given?
Also, I am using cross 3x margin trading, does that “cross 3x” only means that I can borrow 2:1 of what I have?

PostgreSQL upper() and lower() functions don’t understand UNICODE?

I just discovered something very strange! My PostgreSQL database is set up to use UTF-8 internally and locale C and all very straight forward. Yet look at this:

select upper('Lösungsmittel') = upper('LÖSUNGSMITTEL');

 ?column?
----------
 f
(1 row)

select upper('Lösungsmittel') union all
select upper('LÖSUNGSMITTEL');

     upper
---------------
 LöSUNGSMITTEL
 LÖSUNGSMITTEL
(2 rows)

isn’t that strange?! The upper() function was unable to realize upper(‘ö’) = ‘Ö’!

The Java Character class can do that without a problem. I am surprised to see that, and we are on PostgreSQL server 13.1, not something super old.

Is there some configuration parameter to configure this character set stuff beyond selection of UTF-8?

redmi – How to understand the confusing naming conventions of modern Android companies and prevent getting ripped off?

Here’s the reason for this post and my annoyance –

There is a phone called Redmi 9 whose codename is Lancelot and there is a decent amount of community support for it, TWRP is available as well as some ROMS.

Seeing this I was impressed and ordered it off of Amazon. It clearly said Redmi 9 and the same model with the same price is available on Redmi’s official site as well.

However when I got the phone, enabled USB debugging connected it to my pc and ran adb shell, the name I got in the prompt was cattail and not lancelot!!!

And cattail has next to no community support for rooting and stuff, no TWRP either.

Googling cattail vs lancelot gives a bunch of results and there is a difference in camera alignment in the two phones.

Further while Lancelot is a decent enough phone in itself, cattail is absolutely disappointing. Searching for lancelot on amazon or redmi shows up nothing and when I search “Redmi 9 code name” in any search engine, I got lancelot!! I bought the Redmi 9 believing it was something it was not.

Is Redmi and Amazon straight up lying or am I missing something here? Where is the guide to understanding naming conventions of smartphones? How do I and everyone else who uses Android prevent companies from ripping me/us off?

Let me understand the Thunderbolt/USB 4 ports of the new iMac

The top model of the new iMac to be launched by the end of May 2021, is said to come with 2 Thunderbolt/USB 4 ports and 2 USB 3 ports.

In my mind, Thunderbolt is a physically different connector compared to the other 2 USB 3 ports, but looking at this picture they are apparently the same port.

I have an old 2012 iMac connected to two external TVs through the thunderbolt port. Each port using a thunderbolt to HDMI dongle. I am not mirroring the main screen. I have 3 independent monitors, the iMac one and each TV.

So I thought, I could do the same to this new iMac. I disconnect the dongles I have on the old iMac and connect to this new one but apparently these “thunderbolt” ports of the new iMac are in fact USB-C ports that deliver thunderbolt. So, In fact I need USB-C to HDMI dongles, right?

So, physically speaking, this new iMac only has 4 USB-C ports, two of them being able to deliver “thunderbolt”, right?

This new iMac has two of these “thunderbolt” ports but apparently if I use both, I will not get two external independent monitors right?

Why?

oracle – How to organise and understand a terribly modelled database

I have recently joined a company where there are hundreds of schemas and thousands of tables. All the schemas we have are from other vendors who have allowed us access to their database. The entire database is poorly documented (little to no documentation). Vendors also don’t care for documentation, hence they don’t provide us with any documentation.

The other employees themselves find majority of their time figuring out what the data represents and if the data is current. There are numerous front end tools (not built by our company) which allow us to pull data (which is correct and relevant). However, then the issue becomes that we don’t know the schemas, tables or columns the front end is using to pull the data.

I cannot create new tables as the tables are owned by 3rd parties who have allowed us access to their database. How can I go about documentation and how do I figure out what schemas, tables and columns front end tools are using to pull data.

Tables don’t even have foreign keys to figure out how they are linking to other tables. For example in tableA there may be a column called car_id, but in tableB there is a column called cid (which is the car_id). They both link together.