Posts

Setting Display Resolution Permanent on BunsenLabs Linux Lithium with xrandr

Image
I've been using BunsenLabs linux in my qemu/kvm for my tinkering because I like how BunsenLabs Linux is light-weight and easily customizable. It is based on Debian like Ubuntu. Other RPM based distro like Red Hat, Fedora, Rocky are great too. But I just love how simple and minimalist BunsenLabs is when working with desktop. Perhaps it answers the same like why I prefer Alpine Linux while working on docker. There is some issue after installing the BunsenLabs Lithium, I found that the display resolutions is too small for my monitor. I know I can resize it but when I shutdown or reboot later, I have to set it again. I think other users may have encounter this same issue. So, I post this notes here for those who look for how to setup BunsenLabs display. To set your display size, you can simply use ARandR from the BunsenLabs jgmenu by right clicking on your desktop or click on the BunsenLabs icon and navigate to: Preferences > Display > ARandR Screen Layout Editor The

Check which route for specific domain in Linux

Image
Working from home during pandemic, requires most of us to connect to office network through VPN. Some of us are getting used to having multiple VPNs to multiple site offices. When connected to VPN, most of the time that this VPN connection routed all of our traffic through their VPN connection which is not what we want because our home internet is much faster and is not restricted to certain office policies. Therefore, we may want to check which interface is our internet traffic routed to. As I'm using Linux, here is how to check it in ubuntu: $ ip route get $(dig google.com +short) As seen in screenshot above, the route is going through my local network interface device which is eno1 . So I can rest assured that my traffic to google.com is routed through my local internet. You may also love to read: Howto Backup and Restore SD card image with tar and dd Beginning C Programming in Linux Linux Shell Script to Compare PID How to create expandable post summaries in Bl

Bash Scripting - How to Concatenate Strings

Image
Somewhere around 1989, Brian Fox created Bash as a free software substitute for the Bourne shell for the GNU Project . It is a command processor, usually running in a text window, where the user can write commands that cause actions. Bash can also read and execute commands from shell script files . It supports filename globbing (wildcard matching), piping, here documents, command substitution, variables, and control structures for conditional testing and iteration, as do other Unix shells. Okay, now let's get straight to the point. Actually, I got question from friend of mine about bash concatenate strings . I believe I don't have to explain where this bash script should be run. Indeed you need linux or unix shell with bash to run this. The rest is actually really simple and easy. Here is my sample code: As you can see in my example above, there are various ways to concatenate string in bash. The simplest way as in the EXAMPLE1 is by placing them together side by side

Caching Youtube Using Squid Caching Proxy

Image
I'm doing quick post today as I'm quite busy right now. But I don't want to make my friend Piju disappointed as he request me (quite so long... sorry heheh) about my changes on his previous squid.conf to cache youtube which is not working anymore since youtube make some changes on their video URL. Here is my new /etc/squid/squid.conf acl all src all acl manager proto cache_object acl localhost src 127.0.0.1/32 acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 acl localnet src 10.0.0.0/8 # RFC1918 possible internal network acl localnet src 172.16.0.0/12  # RFC1918 possible internal network acl localnet src 192.168.0.0/16 # RFC1918 possible internal network acl SSL_ports port 443 acl Safe_ports port 80      # http acl Safe_ports port 21      # ftp acl Safe_ports port 443     # https acl Safe_ports port 70      # gopher acl Safe_ports port 210     # wais acl Safe_ports port 1025-65535  # unregistered ports acl Safe_ports port 280     # http-mgmt acl Safe_ports port 488     # 

Python Server Pages Example of GET POST Form Input

Image
Previously, I've talked about mod_python.publisher method of creating a simple website using Python . And this time, I will talk about mod_python.psp where PSP stands for Python Server Pages . What good about Python Server Pages for former PHP or JSP programmer is the way you can write your code where you can use the <% # your code here %> tag as you always do. But before that, you have to configure your server to enable mod_python.psp. Pre-requisite In order to run your site with PSP, you have to install and enable mod_python. Here is the steps if you are using Ubuntu: Install apache2 and libapache2-mod-python and enable mod-python $ sudo apt-get install apache2 $ sudo apt-get install libapache2-mod-python $ sudo a2enmod python Edit /etc/apache2/sites-enabled/000-default. Search for this lines: <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny all

Python Code to Get IP Address From Interface Name

Image
From my previous code on How To Print Active Network Interface List in Linux using Python , I got this question. Question from jimchris: Nice work, now how do we get ip address from ifacedata? My Answer: Here's how... Add this function to your python code : def  getifip ( ifn ):      import  socket ,  fcntl ,  struct      sck  =  socket . socket ( socket . AF_INET ,  socket . SOCK_DGRAM )      return  socket . inet_ntoa ( fcntl . ioctl ( sck . fileno (), 0x8915 , struct . pack ( '256s' ,  ifn [: 15 ]))[ 20 : 24 ]) Then use it in your previous code like this: print  getifip ( ifacedata [ 0 ]) Update: you can also download the python source code here Wish you luck and Happy Coding!

VBScript Get File Extension

Image
Before anything else, you may love to read this book too!... Actually, I got this question from the reader of my previous blog post about VBScript to Replace Underscores in Filename with Spaces for All Files in a Folder , and I decided to answer it here. Question from Justin: I tried something simular..but modified your VBS.. '======================================================== ' VBScript to replace underscore in file name with space ' for each files in a folder ' Written by ApOgEE of http://coderstalk.blogspot.com '======================================================== Dim sName Dim fso Dim fol ' create the filesystem object Set fso = WScript.CreateObject("Scripting.FileSystemObject") ' get current folder Set fol = fso.GetFolder(".") ' go thru each files in the folder For Each fil In fol.Files ' check if the file name contains underscore If InStr(1, fil.Name, "The ") <> 0 Then ' replace unders