Skip to content
hakk
  • Home
  • Blog
  • Docs
  • DSA
  • Snippets
  • How to Run PowerShell Code Only During Certain Times

    2026-09-07

    When you have a PowerShell command running inside a loop, you may not want it to execute continuously. For example, you might want a script to run only during business hours, between scheduled maintenance windows, or during a specific overnight period.

    PowerShell makes this straightforward by comparing the current time with a start and end time.

    Checking Whether the Current Time Is Within a Range

    The current time can be retrieved with:

  • How to Update a File's Creation Time in PowerShell

    2026-09-07

    PowerShell makes it easy to update the creation time for files in a directory:

    Get-ChildItem -File | ForEach-Object {
        $_.CreationTime = Get-Date
    }
    

    This command finds every file in the current directory and sets its creation time to the current date and time.

    But what if you only want to update a single file?

    Update One File

    Use Get-Item to reference the file directly:

    (Get-Item ".\example.txt").CreationTime = Get-Date
    

    Replace example.txt with the name of your file. You can also provide the full path:

  • PeopleSoft App Server Freeze Troubleshooting Checklist

    2026-05-25

    1. Identify stuck processes

    ps -ef | grep PSAPPSRV
    

    Better:

    ps -eo pid,ppid,state,wchan,etime,cmd | grep PSAPPSRV
    

    Important things:

    • STATE

      • D = uninterruptible I/O wait
      • S = sleeping
      • R = running
    • WCHAN

      • shows kernel wait point

    Examples:

    • futex_wait
    • io_schedule
    • pipe_wait
    • do_poll

    2. Check overall system pressure

    CPU / load

    top -H
    

    Look for:

    • high load average with low CPU usage
    • blocked threads

    VM / blocked tasks

    vmstat 1
    

    Important columns:

    • b

      • blocked processes
    • wa

    • Build Vim With Python3 Support

      2025-12-29

      I’m on an older version of a Debian based os that only has vim 8.2 available. But I wanted to use YouCompleteMe so I built vim from source. Here are the brief steps I followed.

      Install Packages

      Note: This assumes that build essential is installed.

      sudo apt install libncurses-dev python3-dev
      

      Follow the Build directions on the vim site

      git clone https://github.com/vim/vim.git
      cd vim
      

      Configure to enable python3 support

      ./configure --with-features=huge \
                  --enable-multibyte \
                  --enable-python3interp \
                  --prefix=/usr/local
      

      Build

      cd src
      make
      

      Verify

      ./vim --version
      ...
      +python3
      ...
      

      Install

      sudo make install
      

      Update Alternatives

      sudo update-alternatives --install /usr/bin/editor editor /usr/local/bin/vim 1
      sudo update-alternatives --set editor /usr/local/bin/vim
      sudo update-alternatives --install /usr/bin/vi vi /usr/local/bin/vim 1
      sudo update-alternatives --set vi /usr/local/bin/vim
      

    • Understanding the ss Command: A Modern Alternative to netstat

      2025-11-01

      The ss command (short for socket statistics) is a fast, feature-rich replacement for the older netstat utility. It allows administrators to inspect and manage network sockets on a system — whether they’re TCP, UDP, RAW, or UNIX domain sockets. Compared to netstat, ss runs faster and provides more filtering options, making it invaluable for network diagnostics and system monitoring.

      Show All TCP, UDP, RAW, and UNIX Sockets

      ss -a -t -u -w -x
      

      Motivation: Network administrators often need a complete snapshot of all active sockets — to check which services are listening, what connections are established, or to detect unusual activity.

    • Understanding HTTP from Scratch with Python Sockets

      2025-11-01

      Most Python developers reach for requests when working with HTTP — and for good reason. It’s convenient, safe, and hides all the messy details of networking. But hiding those details also hides how the web actually works.

      Under the surface, every HTTP transaction is just plain text sent over a TCP socket. Understanding what happens at that level gives you insight into how browsers, APIs, and servers communicate. It also helps you debug connection issues, craft custom clients, or even build HTTP servers yourself.

    • When Environment Variables Mysteriously Reset...

      2025-07-08

      Ran into a frustrating issue recently where a custom environment variable kept resetting itself every time a system rebooted. I wasn’t sure what was causing this I was notified that the team had changed all necassary items to correct this but it kept occurring. After some digging it turns out it was being overwritten by a GPO startup script.

      How did I find it? PowerShell, of course:

      Get-ChildItem -Path "\\domain.name\SYSVOL\domain.name\Scripts" -Recurse -File | Select-String -Pattern "MY_ENV_VAR"
      

      I searched the SYSVOL scripts directory on the domain controller, and sure enough, one of the logon scripts was setting the variable back to a default value.

    • How to Generate a 32-byte Key for AES Encryption

      2025-01-21

      Generating a 32-byte key for AES encryption from a password using only built-in Python modules. To do this we’ll use the hashlib library. For this approach we’ll use the PBKDF2 (Password-Based Key Derivation Function 2) via hashlib.pbkdf2_hmac. This ensures that the key is securely derived from the password.

      Here’s some example code:

      import os
      import hashlib
      
      def generate_aes_key(password: str, salt: bytes = None, iterations: int = 100_000) -> bytes:
          """
          Generate a 32-byte AES key from a password using PBKDF2-HMAC-SHA256.
      
          :param password: The password to derive the key from.
          :param salt: A unique salt (16 bytes recommended). If None, a random salt will be generated.
          :param iterations: The number of iterations for the key derivation function.
          :return: A tuple containing the derived key and the salt used.
          """
          if salt is None:
              salt = os.urandom(16)  # Generate a random 16-byte salt if not provided
      
          # Use PBKDF2 with HMAC-SHA256 to derive the key
          key = hashlib.pbkdf2_hmac('sha256', password.encode(), salt, iterations, dklen=32)
          return key, salt
      
      # Example usage
      password = "securepassword"
      key, salt = generate_aes_key(password)
      
      print("Derived Key (hex):", key.hex())
      print("Salt (hex):", salt.hex())
      

      I preferred to use this approach to avoid any external dependencies.

    • Streamlining Deployment: Installing Docker, Gitea, Gitea Act Runner, and Nginx on Ubuntu

      2024-06-11

      Learn how to setup a robust source control system with CI/CD to deploy your applications on Ubuntu. This post will guide you through the process of installing Docker, Gitea, Gitea Act Runner, and Nginx on Ubuntu, empowering you to streamline your deployment workflow and enhance your server capabilities.

      Installing Docker on Ubuntu

      Docker provides a powerful platform for containerizing applications and simplifying deployment across different environments. To install Docker on Ubuntu, follow these steps:

    • How to Filter HTML Table By Multiple Columns

      2024-06-07

      TL;DR: The full code is available at the bottom of this post.

      Let’s walk through building the whole page starting with the HTML.

      HTML Structure:

      First we’ll create a text input field that will be used to accept input to search on. We’ll also give it an id attribute set to "myInput", which is used to identify it in JavaScript later on.

      <input type="text" id="myInput">
      

      Next let’s add a table and add an id attribute set to "myTable", which will also be used to identify it in JavaScript later.

    • ««
    • «
    • 1
    • 2
    • 3
    • 4
    • 5
    • »
    • »»
Recent posts
  • How to Update a File's Creation Time in PowerShell
  • How to Run PowerShell Code Only During Certain Times
  • PeopleSoft App Server Freeze Troubleshooting Checklist
  • Build Vim With Python3 Support
  • Understanding the ss Command: A Modern Alternative to netstat
© 2026 hakk
  • Home
  • Blog
  • Docs
  • DSA
  • Snippets