VirtualBox Kernel Service Is Not Running

I am using oracle virtualbox. I have installed the Virtualbox as well as Guest Additionls and built oracle linux VM. However, after I restarted the system, I got an error after successful reboot “notification in the linux VM to be precise” that says “Virtualbox Kernel service is not running”. I checked the log /var/log/vboxadd-setup.log and it said “restart guest or host”. I did restarted both but the issue persists. I don’t know where to start to investigate. Please assist.

enter image description here

mac – iMac (2011) not running external monitor

I have an iMac (2011, High Sierra) that I’m trying to use with an external monitor. I got it running with a VGA to MiniDisplayPort adapter the other day, but the quality wasn’t great and the external display kept going black randomly.

I got an HDMI to MiniDisplayPort adapter, but it doesn’t work. The Mac recognises that an additional display is present (presumably because something is plugged in the MiniDisplayPort port), but the monitor says ‘no signal’. I tried different monitors, and also tried plugging a DVI to HDMI cord into the monitor’s DVI port, but nothing. VGA doesn’t seem to work either.

I reset the SMC and NVRAM, but that didn’t work. Even reformatting the HDD and reinstalling the OS didn’t fix the problem. I have no idea where to go from here.

Start-AzVM : Cannot bind parameter ‘DefaultProfile’ when running an Azure runbook

I am working on this official tutorial from MS Azure team to run a PowerShell Workflow runbook to start a VM. But when I start the following runbook (from step 6 of the tutorial), I get the error shown below. Question: What I may be missing, and how can we resolve the issue?

Remark: Start-AzVM is from Az.Compute module that I have already imported.

rinbook code:

workflow MyFirstRunbook-Workflow
{
# Ensures that you do not inherit an AzContext in your runbook
Disable-AzContextAutosave –Scope Process

$Conn = Get-AutomationConnection -Name AzureRunAsConnection
Connect-AzAccount -ServicePrincipal -Tenant $Conn.TenantID -ApplicationId $Conn.ApplicationID -CertificateThumbprint $Conn.CertificateThumbprint

$AzureContext = Get-AzSubscription -SubscriptionId $Conn.SubscriptionID

Start-AzVM -Name 'vm-cs-web01' -ResourceGroupName 'rg-cs-ansible1' -AzContext $AzureContext
}

Error:

Start-AzVM : Cannot bind parameter 'DefaultProfile'. Cannot convert the "a76c7e8f-210d-45e5-8f5e-525015b1c881" value of 
type "Deserialized.Microsoft.Azure.Commands.Profile.Models.PSAzureSubscription" to type 
"Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer".
At MyFirstRunbook-Workflow:11 char:11
+ 
    + CategoryInfo          : InvalidArgument: (:) (Start-AzVM), ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.Azure.Commands.Compute.StartAzureVMCommand

systemd – Running awesome-client (which uses dbus) from acpid

I set up a acpid rule to execute the following command, whenever I receive a specific acpi message:

awesome-client "activate_tabletmode()"

Where activate_tabletmode() is just some function that I want to call in my awesome config. I know that awesome-client uses dbus to make IPC with awesome possible.

I get the following error message:

Failed to open connection to "session" message bus: Using X11 for dbus-daemon
autolaunch was disabled at compile time, set your DBUS_SESSION_BUS_ADDRESS instead

Can someone help me understand what that means? I tried to run the command as user instead of root using sudo -u, but it did not help.

linux – Transmission Daemon running under custom user trying to load config from wrong path

I have transmission daemon 2.94 running as a service on my Debian 10 machine.

I changed the user running transmission daemon from default debian-transmission to www-data Apache user, since I want the save files to be readable by Apache and the opposite, Apache files to be readable by transmission.

To do that, I changed to the user setting from the following config files:

  • User=www-data in /lib/systemd/system/transmission-daemon.service
  • USER=www-data in /etc/init.d/transmission-daemon
  • setuid www-data and setgid www-data in /etc/init/transmission-daemon.conf

The transmission JSON config file still resides in /etc/transmission-daemon/settings.json. I made sure both directories /var/lib/transmission-daemon and /etc/transmission-daemon were owned by the new user www-data

But when I relaunch the service with sudo systemctl start transmission-daemon or sudo service transmission-daemon start, I get the following in the transmission logs:

Couldn't create "/var/www/.config": Permission denied (file-posix.c:189)
Couldn't read "/var/www/.config/transmission-daemon/settings.json": No such file or directory (utils.c:238)
Couldn't save temporary file "/var/www/.config/transmission-daemon/settings.json.tmp.jq3qtN": No such file or directory (variant.c:1285)

…and other similar errors.

So it would seem transmission-daemon is trying to use the www-data user home path and recreate its config directory here.

Why is that and how can I make transmission using the previous default config path? I don’t see any transmission configuration depending on the user home path.

Side question: what is the difference between all those three config files where you set up the user running the service?

Utilize These Tips For Running A Home-Based Business

It can be a very exciting opportunity starting your own home-based business. You need to be fully prepared in order to make everything go smoothly, and there are many things to consider in order to make this happen. Continue reading to find out for information, and utilize these tips for running a home-based business.

When you decide what business opportunity that you’re going to do, you need to come up with a solid plan. This needs to be a written plan, full of goals and different strategies according to your business niche. You will continue planning as you get started, but it’s a good idea that you have most everything sorted out beforehand.

When operating a home-based business, you need to come up with a budget to work from. Write down all of your monthly expenses, and make sure you write down your start-up costs and any future one-time expenses as well. As your income starts to come in, you can start to plan out the rest of your budget.

You’re going to have an in[​IMG]ventory of things you need as you start your business. As you are able to free up money from your budget, get the things that you need. Focus on what you absolutely need in order to start your business. You want to keep everything organized, and you want any office equipment that you need to do business on a daily basis.

Now it’s time to get started, and you need to see how the public responds to your products or services. This will give you a good idea as to how things are going to go from the beginning. Find out what is working, and change what isn’t working.

You’re going to have to figure out your advertising strategies. No one can run a home-based business site without search engine optimization strategies as well. You can do the search engine optimization yourself if you learn the right knowledge. You can also seek out advertising strategies that are both free and less costly.

Whenever you see the potential to better your products or the way you offer them, take advantage of this. Offer your customers special promotions or discounts, hold contests, and tell them about new product information.

You must make sure that you stay patient because it will take time to grow your business. Businesses work different than jobs. In your previous occupation, you worked for a salary or hourly wage. Now, you have to build, and income can be quite sporadic. However, you can get a lump sum all at once. Business is a yo-yo process, but it can be very lucrative and rewarding.

Running your own home-based business is a great way to earn extra income or replace your current income altogether. Many people are getting involved in their own home-based businesses these days for many different reasons. Make sure you devise a solid plan, and get ready for a lifestyle change. Make your business setting comfortable at home, and with a disciplined approach, get ready to make some profits.

 

c# – CodeWars kata Fusc function running too long, but very fast locally

I have a solution to this CodeWars challenge that’s being rejected as “too slow”.

Basically, write public static BigInteger Fusc(BigInteger n) given:

  1. fusc(0) = 0
  2. fusc(1) = 1
  3. fusc(2 * n) = fusc(n)
  4. fusc(2 * n + 1) = fusc(n) + fusc(n + 1)

— CodeWars description (from part 1, which is formatted slightly nicer IMO)

I have the class below. FuscInner is a literal, naïve implementation, to offer a “known good” answer if needed; it’s slow, but that’s fine. The trouble that I’m running into is that FuscInnerTest runs against my test driver in a quarter second, but times out on CodeWars.

While I’m open to any suggestionst for cleaning up FuscInnerTest or MediumInt, my primary goal is to ascertain why it’s running so poorly when I submit to CodeWars (of course, I don’t know how many test cases it runs…).

using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

public class FuscSolution {
    public static BigInteger Fusc(BigInteger n) {
        //var timer = System.Diagnostics.Stopwatch.StartNew();
        var answer = FuscInnerTest(n);
        //timer.Stop();
        //Console.WriteLine($"{n} {answer} : {timer.Elapsed}");
        //timer.Restart();
        //answer = FuscInner(n);
        //timer.Stop();
        //Console.WriteLine($"{n} {answer} : {timer.Elapsed}");
        return answer;
    }

    private static BigInteger FuscInner(BigInteger n) {
        if (n == BigInteger.Zero) {
            return BigInteger.Zero;
        }
        if (n == BigInteger.One) {
            return BigInteger.One;
        }

        if (n % 2 == BigInteger.Zero) {
            return FuscInner(n / 2);
        }
        var half = n / 2;
        return FuscInner(half) + FuscInner(half + 1);
    }

    private static readonly Dictionary<BigInteger, BigInteger> _dict = new Dictionary<BigInteger, BigInteger> {
        { BigInteger.Zero, BigInteger.Zero },
        { BigInteger.One, BigInteger.One },
        { new BigInteger(3), new BigInteger(2) },
        { new BigInteger(5), new BigInteger(3) },
    };

    private static BigInteger FuscInnerTest(BigInteger n) {
        // note: making this a Dictionary<BigInteger, BigInteger> worked quickly locally, too
        // the "MediumInt" is an attempt to reduce the number of BigInteger allocations, since
        // they're immutable
        var queue = new Dictionary<BigInteger, MediumInt> {
            { n, new MediumInt(1) },
        };

        BigInteger answer = BigInteger.Zero;

        while (queue.Any()) {
            var current = queue.Keys.Max();
            if (_dict.ContainsKey(current)) {
                answer += _dict(current) * queue(current).ToBigInt();
                queue.Remove(current);
            } else {
                Dequeue(current);
                var half = current / 2;
                Enqueue(half, current);
                if (!current.IsEven) {
                    Enqueue(half + 1, current);
                }
                queue.Remove(current);
            }
        }

        return answer;

        void Dequeue(BigInteger toRemove) {
            if (queue.ContainsKey(toRemove)) {
                if (queue(toRemove).IsPositive()) {
                    queue(toRemove).Decriment();
                } else {
                    queue.Remove(toRemove);
                }
            }
        }

        void Enqueue(BigInteger toAdd, BigInteger parent) {
            if (queue.ContainsKey(toAdd)) {
                queue(toAdd).Incriment();
            } else {
                queue(toAdd) = new MediumInt(1);
            }
            if (parent != null) {
                if (queue.ContainsKey(parent)) {
                    queue(toAdd).Add(queue(parent));
                }
            }
        }
    }

    private class MediumInt {
        private const int max = 2_000_000;
        private const int min = -2_000_000;

        private BigInteger big = BigInteger.Zero;
        private int current = 0;

        public MediumInt(int initialValue) {
            current = initialValue;
            Normalize();
        }

        public bool IsZero() {
            return big == BigInteger.Zero && current == 0;
        }

        public bool IsPositive() {
            if (IsZero()) {
                return false;
            }
            if (current == 0 && big <= 0) {
                return false;
            }
            if (big == BigInteger.Zero && current <= 0) {
                return false;
            }

            if (big == BigInteger.Zero) {
                return current > 0;
            }

            if (big > BigInteger.Zero && big > Math.Abs(current)) {
                return true;
            }
            if (big < BigInteger.Zero && big < Math.Abs(current)) {
                return true;
            }
            throw new Exception("IsPositive unknown state");
        }

        public void Incriment() {
            ++current;
            Normalize();
        }

        public void Decriment() {
            --current;
            Normalize();
        }

        public void Add(MediumInt value) {
            current += value.current;
            big += value.big;
            Normalize();
        }

        public BigInteger ToBigInt() {
            return big + current; ;
        }

        private void Normalize() {
            if (current > max || current < min) {
                big += current;
                current = 0;
            }
        }
    }
}

Driver code:

Assert.AreEqual(BigInteger.Zero, FuscSolution.Fusc(BigInteger.Zero));
Assert.AreEqual(BigInteger.One, FuscSolution.Fusc(BigInteger.One));
Assert.AreEqual(BigInteger.One, FuscSolution.Fusc(new BigInteger(4)));
Assert.AreEqual(new BigInteger(2), FuscSolution.Fusc(new BigInteger(3)));
Assert.AreEqual(new BigInteger(3), FuscSolution.Fusc(new BigInteger(10)));
Assert.AreEqual(new BigInteger(3), FuscSolution.Fusc(5));
Assert.AreEqual(new BigInteger(3), FuscSolution.Fusc(20));
Assert.AreEqual(new BigInteger(8), FuscSolution.Fusc(21));
Assert.AreEqual(new BigInteger(53), FuscSolution.Fusc(9007199254740991L));

// You need to pass these tests very quickly
BigInteger twoPThous = BigInteger.Pow(2, 1000);
Assert.AreEqual(new BigInteger(1001), FuscSolution.Fusc(twoPThous + BigInteger.One));
Assert.AreEqual(new BigInteger(1000), FuscSolution.Fusc(twoPThous - BigInteger.One));
Assert.AreEqual(new BigInteger(2996), FuscSolution.Fusc(twoPThous + 5));
Assert.AreEqual(new BigInteger(7973), FuscSolution.Fusc(twoPThous + 21));
Assert.AreEqual(new BigInteger(50245), FuscSolution.Fusc(twoPThous + 9007199254740991L));
var e = BigInteger.Parse("40441312560834288620677930197198699407914760287917495887121626854370117030034851815445037809554113527157810884542426113562558179684997500659084090344407986124994461497183");
var a = BigInteger.Parse("4496047232746033439866332574607641115185289828815659836877207557974698638551430698226403383854431074455323285812344476437334109742500243442945967768558521790671067401423809250553312923996658420643391496408098163895264498830090255970293513331630261702288646149000136895514918279039816543329290294321200");
Assert.AreEqual(e, FuscSolution.Fusc(a));

Bcoin – running webpack-app issue

I have cloned bcoin repo and installed webpack package. When trynig to run webpack-app I get the error below:

btc@ubuntu:~/bcoin/node_modules$ npm run webpack-app
npm ERR! missing script: webpack

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/btc/.npm/_logs/2020-11-18T08_55_31_312Z-debug.log

I have checked the node_modules folder inside the bcoin dir and couldn’t find webpack-app package. Also, I excatly followed the instructions from https://bcoin.io/guides/browser

nodejs version: v10.19.0
npm version: 6.14.4

MySQL Query running slow when using REPLACE function instead of CASE statement

Is it better to use CASE statements instead of REPLACE functions in MySQL when mapping a comma-separated-string field?

The below query runs extremely slow using replace.
Note, the underlying user_roles table is of format (user_id (bigint), string_of_user_role_ids (varchar(200)))

-- this runs slowly
select      distinct string_of_user_role_ids
            , replace(replace(replace(replace(replace(string_of_user_role_ids, '10', 'Scientist'), '9', 'Superhero'), '8', 'Teacher'), '7', 'Journalist'), '6', 'Farmer')
            , count(1) 
from        user_roles
group by    1,2 
order by    3 desc
-- this runs quickly, but is more difficult to keep adding in multiple new when clauses whenever a new user role is added
select      distinct string_of_user_role_ids
            , case  when string_of_user_role_ids= "6" then 'Farmer'
                    when string_of_user_role_ids= "7" then 'Journalist'
                    when string_of_user_role_ids= "8" then 'Teacher'    
                    when string_of_user_role_ids= "6,7" then 'Farmer, Journalist'
                    when string_of_user_role_ids= "6,8" then 'Farmer, Teacher'
                    when string_of_user_role_ids= "7,8" then 'Journalist, Teacher'
                    when string_of_user_role_ids= "6,7,8" then 'Farmer, Journalist, Teacher'    
                    -- ... etc.
                    else 'Unknown' end as app_user_type
            , count(1) 
from        user_roles  
group by    1,2 
order by    3 desc 

Ideally I would use the REPLACE function instead of a CASE statement, as it seems easier to scale out in terms of expanding the code and less risk to manage.

I can’t understand why one query runs quickly and the other very slowly (seconds versus minutes, after a few mins I killed the slow query).
Ideas/questions are welcome please.