beginner – C code to reset all usb devices (because ubuntu laptop disables usb mouse after sleep)

I don’t program much in c, but cobbled together some code from different places in google. I’m sure this is backwards especially in how it works with strings and directory files. Please let me know what the best practices would have been.

/* usbresetall -- reset all of the usb devices on bus 001 */

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>

#include <dirent.h> 
#include <string.h>

#include <linux/usbdevice_fs.h>

int main(int argc, char **argv)
    int fd;
    int rc;

    DIR *d;
    char filename(256);  
    struct dirent *dir;

    d = opendir("/dev/bus/usb/001/");
    if (d) {
        while ((dir = readdir(d)) != NULL) {
            printf("%sn", filename);
        fd = open(filename, O_WRONLY);
        if (fd < 0) {
        perror("Error opening output file");
        } else {

        printf("Resetting USB device %sn", filename);
        rc = ioctl(fd, USBDEVFS_RESET, 0);
        if (rc < 0) {
            perror("Error in ioctl");
        } else printf("Reset successfuln");

    return 0;

uploads – Removing extra large generated images disables all crops

function filter_image_sizes( $sizes) {
    unset( $sizes('1536x1536')); // disable 2x medium-large size
    unset( $sizes('2048x2048')); // disable 2x large size
    return $sizes;
add_filter('intermediate_image_sizes_advanced', 'filter_image_sizes');

I check the uploads folder and only the original image is being added now. I check the docs and I don’t think I see it removing all the crops because of it.

Am I doing something wrong? When removing those sizes, do I need to add back the default sizes?

gnupg – pinentry-mac completely disables prompt for GPG passphrase

This is weird. I am using pass and pinentry-mac to unlock my passwords. My gpg-agent.conf uses pinentry-mac as its pinentry-program.

I’m not sure if I updated some dependency recently but suddenly decrypting passwords is now possible without asking for passphrase which I find as a serious problem. This is not a problem with pass as if I try using gpg directly to decrypt my encrypted files directly in terminal session, it’s the same.

If I disable pinentry-mac then it starts working and I’m asked to put my passphrase every time. Any idea what can be the cause? I have tried restarting / killing gpg-agent and logging out of my user account (even restarting the machine) but result is the same.

plotting – Frame disables Ticks in Plot and ListLinePlot

I stumbled upon a weird behaviour of Plot and ListLinePlot functions.

Let’s plot a simple function

plot1 = Plot(Sin(x), {x, 0, 10})

enter image description here

Now let’s say I want to extract the “Ticks” element from the plot to later on manipulate it (a good example of manipulating ticks that I found very useful is here How can I scale tick marks without scaling my function?

AbsoluteOptions(plot1, Ticks)

which gives me the ticks of the plot

(* {Ticks -> {{{0.,0., {0.00625, 0.}, {GrayLevel(0.),AbsoluteThickness(0.25)}}, .......*)

Now I plot the same function but add a frame

plot2 = Plot(Sin(x), {x, 0, 10}, Frame -> True) 

enter image description here

but when I try to extract the Ticks element, they are gone!?

AbsoluteOptions(plot2, Ticks)

{Ticks -> {{}, {}}}

Unless I’m missing something (which is likely) this is very strange. I haven’t found a fix for this issue and it’s is a problem if you want to have nice graphs with frame labels etc and also want to manipulate the Ticks.

Any help/ideas/feedback is always appreciate it.

man in the middle – Arp spoofing inside Docker containers disables network on a victim container

I’m trying to create a lab environment to experiment with MiTM attacks. I want to learn docker also so I’ve decided to do this with docker. I created 2 images (attacker, victim):

Victim – based on Alpine, with curl installed
Attacker – based on Ubuntu, with installed iputils-ping iproute2 curl iptables vim ettercap-text-only dsniff and tshark.

They’re both in bridged network, so the router here would be docker0 interface (default:

I’m running the attacker container with –privileged flag, to enable using ettercap.

So when both images is running I’m executing ettercap from attacker container with:

ettercap -T -o -S -i eth0 -M arp:remote //victim_ip/ //

And the network of victim container is loosing connection. I’m trying to ping, but with no effect. The MiTM attack is working because I can see this traffic on victim containers but something is blocking it.

enter image description here

I’ve tried with arpspoof tool too, but with the same effect.

Tried also
echo 1 > /proc/sys/net/ipv4/ip_forward

I’ve checked it on host machine with wireshark and that’s what I see…
enter image description here

I’m not pro with wireshark and ettercap and docker so, maybe I assumed wrong that I can consider docker0 as a normal router that can be fooled with arpsoofing attack.

When I disable ettercap, the network connection is back again.

Any hint what may be wrong will be helpful.

kernel – Airplane mode activates automatically and disables bluetooth, and wifi does not work

I’m using a HP laptop running the new Ubuntu 20.10 groovy gorilla

My kernel version is 5.8.0-29-generic

Everything was fine until today, when airplane mode started to turn on automatically and disable bluetooh, or if I turn the bluetooh on, the airplane mode turns of.

But the main problem is that the wifi doesn’t work, it doesn’t show on the configurations UI.

The output for rfkill list all is:

0: hci0: Bluetooth
    Soft blocked: yes
    Hard blocked: no

And for iwconfig is:

lo        no wireless extensions.

enx00a0c6000000  no wireless extensions.

And also for sudo lshw -C network is:

*-network UNCLAIMED       
       description: Network controller
       product: RTL8821CE 802.11ac PCIe Wireless Network Adapter
       vendor: Realtek Semiconductor Co., Ltd.
       physical id: 0
       bus info: pci@0000:01:00.0
       version: 00
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress cap_list
       configuration: latency=0
       resources: ioport:e000(size=256) memory:df100000-df10ffff
       description: Ethernet interface
       physical id: 2
       bus info: usb@1:2
       logical name: enx00a0c6000000
       serial: 00:a0:c6:00:00:00
       capabilities: ethernet physical
       configuration: broadcast=yes driver=cdc_ether driverversion=22-Aug-2005 firmware=ZTE CDC Ethernet Device ip= link=yes multicast=yes

Any help would be very welcome.

rpg maker – Using a custom map gui disables the ability to save

I’m quite confused at the moment. I’ve created a custom gui (a fuel display on map) that works nicely, but somehow whenever I try to save the game when this gui is active….clicking on the slot where I want to save the game does not work!

thus when I add the following code and let it be called via a trigger (a common event which has a switch as trigger calls this javascript code…event runs parallel with a wait (5)):

REITD.SpaceClass.prototype.showCargoAndFuelStatusUI = function (vehicleType, currentCargo, maxCargo, currentFuel, maxFuel) {
    if (!(SceneManager._scene instanceof Scene_Menu)) {
        if ($gameSystem._REITD_definedWindows("CargoAndFuel") !== undefined) {

        $gameSystem._REITD_definedWindows("CargoAndFuel") = new Window_Base(new Rectangle(1, 1, 211, 200));

        $gameSystem._REITD_shownStatusUIWindows("CargoAndFuel") = "shown";

        $gameSystem._REITD_definedWindows("CargoAndFuel").drawText("Vehicle Fuel", 1, 5, 190, "center");
        $gameSystem._REITD_definedWindows("CargoAndFuel").contents.fillRect(1, 40, 200, 25, _Colors.gray);
        $gameSystem._REITD_definedWindows("CargoAndFuel").contents.fillRect(1, 40, 2 * this.calcFuelPercent(vehicleType), 25,;  // 2 px per percent full.
            padLeft(this.getCurrentFuel(vehicleType), 6, "0") + " / " + padLeft(this.getMaxFuel(vehicleType), 6, "0"), 30, 35, 100, "left");

        $gameSystem._REITD_definedWindows("CargoAndFuel").drawText("Vehicle Cargo", 1, 75, 190, "center");
        $gameSystem._REITD_definedWindows("CargoAndFuel").contents.fillRect(1, 110, 200, 25, _Colors.gray);
        $gameSystem._REITD_definedWindows("CargoAndFuel").contents.fillRect(1, 110, 2 * this.calcCargoPercent(vehicleType), 25,;  // 2 px per percent full.
            padLeft(this.getCurrentCargo(vehicleType), 6, "0") + " / " + padLeft(this.getMaxCargo(vehicleType), 6, "0"), 30, 105, 100, "left");

I’m running into the problem.
Now my question is:
Why is that so and what can I do to correct this problem (or can I somehow deactivate this while a menu is open?)

Engine: RPGMaker MZ

networking – Wifi randomly disables itself on Dell laptops running 20.04 LTS

Here’s an odd one. I’ve got 20.04 LTS running on two Dell laptops, a Latitude 7480 and a Precision M6700. Both are completely up-to-date, including BIOS. However, once in a while, the wifi will just shut itself off. The network menu says it’s completely disabled, and the only way to re-enable it is to turn on Airplane Mode, then turn it back on again. This is immensely frustrating, especially when it happens in the middle of video calls and such. This behavior does not affect any other devices on my network; just the two Dell Ubuntu machines, and it seems to happen more often with the 7480. The 7480 has an Intel Corp. Wireless 8265/8275 chip, and the M6700 has a Dell Wireless 1540.

I’m at a loss here. Can anyone help?