• 7 Posts
  • 39 Comments
Joined 10 months ago
cake
Cake day: December 27th, 2023

help-circle


















  • Here’s a few of the micro-hacks that I’ve hacked up in the past.

    A 2-line script to chroot into Debian when logging in as a certain user on FreeBSD.
    #!/bin/sh  
    
    clear  
    doas chroot /linux /bin/login
    
    I didn't have an IDE, so I just made a script called ide which runs Vim, and then compiles the code and makes it executable.
    #!/bin/sh
    #Works only for C
    vim $1.c && cc -O3 -Wall -Werror -Wno-unused-result $1.c -o $1
    #MODE=`stat -f "%OLp" $1`
    if ("stat -f "%OLp" $1 | grep -e 6 -e 4 -e 2") then
    	chmod +x $1
    fi
    
    This thing, called demoronize, which does what it says in the comments
    #!/bin/sh
    
    #dos2unix -O -e -s $1 | sed 's/    /	/g' | sed 's/“/"/g' | sed 's/”/"/g'
    cat $1 | sed 's/    /	/g' | sed 's/“/"/g' | sed 's/”/"/g'
    #Convert DOS line endings to Unix ones and add a final newline if there isn't one,
    #replace sequence of 4 spaces with tab,
    #and replace "smart" quotes with normal ones
    

    I just keep those ones for historical value, but there’s one hack I use every day. My keyboard doesn’t have a function key (Fn), so I use the Super/Windows key instead.
    I have xdotool keyup Super_L keyup Super_R keyup F4 key XF86Sleep bound to a custom keyboard shortcut. It unpresses the keys used for the shortcut (Super + F4), then presses the sleep key.