Sunday, March 22, 2020

Installing linux-perf on Raspbian



apt install linux-tools
apt install linux-perf-4.18

Edit /usr/bin/perf
Add
version=4.18
Note the version should match the version of linux-perf that you've installed.

Now you can run
perf stat ls

Remove Configuration Files Left Over From "apt remove"

The following command will list the packages with leftover configuration files.
dpkg -l | grep ^rc

Hence, send the output to apt purge to remove all such packages.
apt purge `dpkg -l | grep ^rc |awk '{print $2}'|xargs`

In the future, to avoid having the configuration files leftover after removing a package, use
apt purge <PACKAGE>

Set Environment Variable for LXDE Session

Create .xsessionrc if it doesn't already exist.

Then add,
export XXX=YYY

Run a Script Upon Login to LDXE Session


Launch LXSession configuration
% lxsession-default-apps

Select Autostart tab

In the Manual autostarted applications, type in the path to the script and click Add.

Exit by closing the application.

Change Default Window Manager in Raspbian

% update-alternatives --config x-session-manager

Thursday, October 03, 2019

Fast Scrolling in Emacs

I work with some files that have some complex fontification rules. There is a significant lag when scrolling quickly through these files. Although I am using jit-lock-mode as my font-lock-support-mode, the lag is unbearable. One solution to this is to use fast-scroll. https://github.com/ahungry/fast-scroll. fast-scroll temporarily disables font-lock when scrolling. This has worked out nicely for me.

FreshTomato Firmware for Belkin Share Max N300

FreshTomato is a new firmware project forked off from Tomato by Shibby. I have gotten this working on the Belkin N300 (F7D7301/F7D8301) routers.

FreshTomato
https://exotic.se/freshtomato/

The firmware downloads are here.
https://exotic.se/freshtomato-mips/

You can navigate to the release of your choice. Inside, you will want to go the K26 folder and look for the filenames beginning with freshtomato-K26USB_RT-MIPSR2-*. From the information I can gather from the web, the keyword RT is critical and the keyword MIPSR2 is critical for the F7D7301/F7D8301 series.

The next choice you will need to make is what features you want in the firmware build. See below for a reference guide. You will need to make sure that the file size of the firmware is under 8MB as this is what can be supported by the N300 router. Keep in mind that the files at the distribution link are zipped. You will need to unzip the files to see its actual size.

I was successful in flashing the file named freshtomato-K26USB_RT-MIPSR2-2019.3.330-beta-Big-VPN.trx onto the F7D8301.

References

Note this reference guide was taken from another Tomato firmware project. But you can use it as a reference when choosing features.

Saturday, September 28, 2019

Pi-hole and DD-WRT

Pi-hole is a useful server that can filters ads for your local network.You can read more about it here. One of the required steps for configuring Pi-hole is to point the DNS entry in your router to Pi-hole's IP address. If you have DD-WRT, this is accomplished through the following instructions.

Once you have Pi-hole set up, log into your DD-WRT control panel.
Go to Setup->Basic Setup
Under Network Setup->Local DNS, enter the Pi-hole's IP address.

Sunday, April 21, 2019

Variable arguments for assert

The following is a code snippet that shows how to support allowing variable arguments to be passed to assert.

#include <stdio.h>

#define __ASSERT_INT(COND, format, ...)             \
    do {                                            \
        if (!COND) {                                \
            printf(""#COND);                        \
            printf(" ");                            \
            printf(format "%s", __VA_ARGS__);       \
        }                                           \
    } while (0)
#define ASSERT(COND, ...) __ASSERT_INT(COND, __VA_ARGS__, "\n")

int
main() {
    ASSERT(0==1);
    ASSERT(0==1, "here");
    ASSERT(0==1, "and here %d", 2);
    return 0;
}

Monday, June 05, 2017

Launch Emacs for Windows with Batch File using Emacs Configuration from Cygwin

I maintain a shared Emacs configuration under Linux and Cygwin. In Windows, I wanted to easily launch Emacs from the Desktop with the following goals.

  • Create a shortcut in the taskbar that launches Emacs for Windows
  • Have Emacs for Windows obey the Emacs configuration from Cygwin
  • Avoid opening extra console windows

Some prerequisites,


I created a file called c:\cygwin64\emacs.bat with the following contents.
c:\cygwin64\bin\run bash.exe -c ~/dotfiles/bin/emacs.sh

The file ~/dotfiles/bin/emacs.sh is a shell script that sits in my Cygwin directory. It is a wrapper script that calls Emacs for Windows if I'm running Cygwin.

It is assumed that the default Emacs configuration sits in the ~/.emacs file under Cygwin.

Pin the c:\cygwin64\emacs.bat script to your task bar. See below if you do not know how to do this. Clicking on it will open Emacs for Windows without any intervening console windows.

References

Monday, May 29, 2017

Restore Nexus 5X Stuck in Boot Loop

If your Nexus 5X gets stuck in a boot loop after upgrading to Android O, you can try to restore the previous Andriod version. You will to download the following

  • Android Debug Bridge https://developer.android.com/studio/command-line/adb.html
  • Full OTA image for your device https://developers.google.com/android/ota

Boot to the recovery console and select install from ADB.

Open a command prompt and go into the platform-tools folder of the Android Debug Bridge.

Run
adb sideload <PATH TO OTA ZIP FILE>

Reboot the device upon completion.

Notes
You do not need to install any USB drivers.

References
https://mail.google.com/mail/ca/u/0/#inbox/15c52fab33730727

Monday, April 03, 2017

Configure MI424WR as a LAN MoCA Bridge

http://support.actiontec.com/doc_files/Configure_MI424WR_as_a_LAN_MoCA_Bridge.pdf