Tuesday, December 16, 2025

Monday, December 15, 2025

updating fonts in ubuntu

To bulk install fonts in Ubuntu, copy font files (.ttf, .otf) to ~/.local/share/fonts/ (for your user) or /usr/share/fonts/ (system-wide), then run fc-cache -fv in the terminal to update the font cache, or use the graphical Font Manager by dragging and dropping them in. 

Thursday, December 11, 2025

non-blocking network calls when using asyncio in python

To avoid blocking your Event Look in Python when using asyncio, do not use `requests` but use `aiohttp`

Here is some example code. `aiohttp` gives us a session that works well on the asyncio Event Loop.

import aiohttp
import asyncio

async def fetch_real_url(session, url):
    async with session.get(url) as response:
        return await response.text()

async def main():
    async with aiohttp.ClientSession() as session:
        urls = ['http://python.org', 'http://google.com', 'http://example.com']
        
        # Create a list of tasks
        tasks = [fetch_real_url(session, url) for url in urls]
        
        # Run them all at once
        responses = await asyncio.gather(*tasks)
        
        print(f"Downloaded {len(responses)} pages concurrently.")

if __name__ == "__main__":
    asyncio.run(main())

Other useful things...

  • `async` returns a coroutine object that can be scheduled.
  • Calling this function returns a `future` — a placeholder for a result that hasn't happened yet. It tracks the state (Pending, Finished, Cancelled).
  • The Event Loop is single-threaded. The Event Loop serves as a scheduler of these tasks.

Saturday, July 1, 2023

Using python 3 on mac

 Read more here https://opensource.com/article/19/5/python-3-default-mac

Tuesday, June 27, 2023

SSH returns: no matching host key type found. Their offer: ssh-dss

 Fix is

ssh -oHostKeyAlgorithms=+ssh-dss root@192.168.8.109
Read more here https://askubuntu.com/questions/836048/ssh-returns-no-matching-host-key-type-found-their-offer-ssh-dss 

Wednesday, June 21, 2023

Wednesday, May 12, 2021

Free up space in ubuntu server

 Clean old kernels

  • Check for kernet is use : uname –r
  • Check for old kernels : dpkg --get-selections | grep linux-image
  • Remove unused kernels : dpkg --get-selections | grep linux-image
Clean APT (Pulled from https://askubuntu.com/questions/5980/how-do-i-free-up-disk-space)
  • To delete downloaded packages (.deb) already installed (and no longer needed)
    • sudo apt-get clean
  • To remove all stored archives in your cache for packages that can not be downloaded anymore (thus packages that are no longer in the repository or that have a newer version in the repository).
    • sudo apt-get autoclean
  • To remove unnecessary packages (After uninstalling an app there could be packages you don't need anymore)
    • sudo apt-get autoremove
Finally, Check Disk Space
  • df -h /

Thursday, August 6, 2020

view largest installed debian packages on unix

More details on this link https://www.commandlinefu.com/commands/view/3842/list-your-largest-installed-packages-on-debianubuntu

dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 10

Tuesday, March 24, 2020

pull multiple files from android via adb

Got answer from https://stackoverflow.com/questions/11074671/adb-pull-multiple-files

adb shell 'ls /sdcard/DCIM/Camera/20200327*.mp4' | tr -d '\r' | xargs -n1 adb pull

Monday, November 20, 2017

get the size of folder contents

du -sh 

Output

15M big_folder
0 dead.letter
4.0K some_file
4.0K some_other_file

Wednesday, November 15, 2017

challenges with grails unique: true

Grails does not evaluate a unique constraint at GORM level but at the database level

    static constraints = {
        property unique: true
    }

This means that you would not get a grails.validation.ValidationException but a org.springframework.dao.DataIntegrityViolationException.

This means that

domainInstance.validate()

would not capture a duplicate "property"

Wednesday, August 16, 2017

Sometimes cron runs twice

I suspected cron was running twice. I confirmed by checking the system logs

grep CRON /var/log/syslog

Then I killed cron and restarted it

sudo /etc/init.d/cron stop
sudo /etc/init.d/cron start

Wednesday, September 28, 2016

Sending mail in unix with attachment

You would need to install sharutils

sudo apt-get install sharutils

Then run this

uuencode <path_to_file> <name_to_give_attachment> | mail -s "Subject" foo@example.com

Also see http://soamweird.blogspot.com/2016/03/sending-mail-in-unix.html

Sunday, April 17, 2016

Sorting by type first then alphabetically

The script below ensures that items are sorted by type first then by alphabetical order.

The spaceship operator

Just ran into this and I thought it was really cool.

So the spaceship operator (<=>) delegates to the compareTo method:

assert (1 <=> 1) == 0
assert (1 <=> 2) == -1
assert (2 <=> 1) == 1
assert ('a' <=> 'z') == -1

For more checkout http://groovy-lang.org/operators.html

Thursday, March 3, 2016

Sending mail in unix

When sending an email from unix do the following

echo "Mail Message" | mail -s "Subject" person@home.com

In order to avoid getting your email marked as spam, ensure that the sending email is something realistic, probably a domain you own i.e. awesome@homelypeople.com

Reset local git branch to match remote

Setting your branch to exactly match the remote branch can be done in two steps:

git fetch origin
git reset --hard origin/master


Deleting git tags

Delete tag locally

git tag -d tagName

Delete tag on remote

git push --delete origin tagName