Category: Tools

  • Using SSH to host a local git repository (simplest way)

    I shift laptops and devices a lot, and mounting storage is not ideal between devices. For my use case I decided I liked a git repo the best for document storage (markdown files)

    To be able to access that repo I wanted it to be accessible on my server, from my home via SSH. (Remotely I use VPN to my home network to sync)

    When searching for remote Git repositories I mostly see paid alternatives or fullblown Git servers being advertised. That is too much functionality for me, and not necessary.

    Solution

    1. Create repo on server
    2. Clone repo on client(s) via ssh

    These are all that’s necessary, and it’s so much simpler than using Git servers.

    1. Create repo (on server)

    # connect to your server
    ssh yourserver
    # change directory to your project
    cd /git
    # create a git repo
    git init --bare notesmygoats.git

    2. Clone repo on client(s)

    # cd into the directory which will contain your git repo
    cd /home/notetaker/documents
    #git clone the remote repo
    git clone yourserver:/git/notesmegoats.git
    Cloning into 'notemegoats'...
    remote: Enumerating objects: 3, done.
    remote: Counting objects: 100% (3/3), done.
    remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
    Receiving objects: 100% (3/3), done.
    
    

    Tips

    Use links to create structure

    The directory /git/ is a link to a folder in my storage. I like to use links to create logical structure, that’s completely personal though.
    If you can SSH into a server, you can use any directory for the git repo, just make sure you replace the clone command with the directory you’re actually using:

    git clone yourserver:/home/youruser/mygitrepo

    Bare repository

    Copied from https://www.atlassian.com/git/tutorials/setting-up-a-repository/git-init

    The –bare flag creates a repository that doesn’t have a working directory, making it impossible to edit files and commit changes in that repository. You would create a bare repository to git push and git pull from, but never directly commit to it. Central repositories should always be created as bare repositories because pushing branches to a non-bare repository has the potential to overwrite changes. Think of --bare as a way to mark a repository as a storage facility, as opposed to a development environment. This means that for virtually all Git workflows, the central repository is bare, and developers local repositories are non-bare.

  • Create fixed width thumbnails with correct orientation from EXIF data for use in NanoGallery2

    First off; This is totally a bookmark for myself. But I’d be amazed if it actually helps you, the reader!

    I started using a static self-hosted NanoGallery2 for holiday photos, and the thumbnails look better when they are all the same width.

    Execute this in the directory where your JPGs reside, all thumbnails have “thumb-” prefixed to their bigger picture counterpart.

     for i in *.JPG; do convert -auto-orient -thumbnail '200x>' $i thumb-$i; done;
    
  • Linux command line task management with jobs, BG, FG and nohup – multitasking

    Often I see people waiting while their command is executing, impatiently tapping their desk until a file copy or command has finished.

    They are often amazed when I show them that the Linux command line has a way of sending pending commands to the background, so you can continue on another task.

    Below is a gif screencast which shows:

    (more…)

  • Log as well as see error and standard output in Linux Terminal

    Quick snippet, as I was searching for this one today.

    You can output both standard and error output to both screen and log file with the below command:

    my_command.sh 2>&1 | tee my_command.log

    Explanation:

    • my_command.sh
      • replace with your command (possibly including arguments)
    • 2>&1
      • redirects standard error to standard output, otherwise only standard output is written to file
    • | tee
      • my_command.log pipes the output to tee, which writes both to screen and file
  • (Web-safe) Fonts blurry/bad/jagged/vague in Chrome

    Chrome based browsers (Edge/Vivaldi/etc) and Chrome itself are great. But the font smoothing on my Linux laptop (Pop!_Os / Ubuntu) is not great. This comes into play when you’re visiting pages with web or web-safe fonts.

    Web(-safe) fonts allow Web designers to use fonts that are not installed on the viewer’s computer.

    The edges of the fonts look a bit jagged and the edges are vague. This is quite annoying, since the fonts are rendered perfectly in all other applications.

    After a whole lot of searching I finally found the solution (for me). YMMV (Your miles may vary)

    Solution: Disable Hardware acceleration in settings

    Go to settings by clicking the three dots and then select settings.

    In the settings, search for hardware

    (You can click this link to go there directly: chrome://settings/?search=hardware)
    (If you use chrome, click here to go there directly: chrome://settings/?search=hardware)

    Flip the switch next to Use hardware acceleration when available and click Relaunch

    Wonderful! Click Relaunch to view beatifully rendered web fonts

    After the relaunch my fonts were rendered perfect.

    Examples:

    Hardware acceleration disabled, bask in the glory of clean fonts!
    Hardware acceleration enabled, fonts edges are vague !
  • Update HP Proliant Microserver BIOS without Windows

    I wanted to update my MicroServer Gen8 bios to the latest version but the download site on HPE only showed .EXE files. Since I’m only running Linux on my machines it was not possible to execute that file.

    You can however update the BIOS via ILO (Integrated Lights Out) if you extract the BIOS file from the executable.

    First download the .EXE from the HPE site: https://support.hpe.com/hpsc/swd/public/detail?swItemId=MTX_e9bfdf20809a426cb16ef9cd81

    (Currently the latest version is SP99427.exe. If you want to be sure you’re using the latest BIOS then click the tab “Revision History” to see if there are newer BIOS files available)

    Extract the contents of the executable. Have a look at the directory structure below and extract the file marked "CPQJ06xx.xxx"(where “x” might change depending on versions)

    .
    ├── How to Use.txt
    ├── logo.gif
    ├── README.1ST
    ├── rev_hist.txt
    ├── ROMPaq Flat Files
    │   ├── CPQJ0613.684
    │   ├── CPQSRVR2.CPU
    │   ├── README.1ST
    │   ├── Readme.txt
    │   └── ROMPAQ.EXE
    ├── ROMPaq USB Key
    │   ├── CPQJ0613.684
    │   ├── CPQSRVR2.CPU
    │   ├── HPEUSB.exe
    │   ├── Readme.txt
    │   └── ROMPAQ.EXE
    ├── Start_files
    │   ├── colorschememapping.xml
    │   ├── filelist.xml
    │   └── themedata.thmx
    └── Start.htm
    3 directories, 18 files

    Then log in to ILO and navigate to the page “Firmware” via the Menu Option “Administrator”

    At the bottom of the page select “Browse” to select the CPQJ06 file and then click Upload.

    Let the upload complete and reboot your Microserver. When you start the microserver it displays the BIOS version and date in the first line.

    You can also see the version in the ILO overview page.

  • Citrix Receiver on Linux: SSL Error 61 ("You have not chosen to trust")

    Important:
    If you don’t know or understand certificates / root and intermediate certificate authorities, get someone who understands to follow below instructions.

    I tried connecting to the company’s citrix server, but kept hitting the same error when I tried to open the connection:

    Contact your help desk with the following information:
    You have not chosen to trust "INSERT YOUR CA HERE",
    the issuer of the server's security certificate (SSL Error 61)

    It seems that Citrix has an alternate directory where it stores it’s trusted cert’s / certificate authorities. Even though you can see that the server’s certificate is trusted (by root CA’s) via a web browser, we need to copy those to the correct directory.
    In short: Copy the root and intermediate CA’s to this directory: /opt/Citrix/ICAClient/keystore/cacerts
    (more…)

  • Using SSH to forward the same local port to multiple external hosts

    Okay, this is kinda awesome :-), I got my geek on 🙂
    My application is connecting to a cluster of external servers but my application can configure hostname but can’t configure port.
    So I wanted to connect to a remote cluster using SSH tunneling, but I was unable to forward everything because the port binding to localhost (127.0.0.1) can only be used once.
    Then I saw that you can use multiple loopback addresses! See this page: https://en.wikipedia.org/wiki/Loopback
    Basically you can bind the portforward to 127.0.0.2, 127.0.0.3 till 127.255.255.254, that should provide enough addresses, right!? 🙂
    So I can use multiple port forwards from my localhost(s) to the six remote hosts like this:

    ssh somedomain.com \
    -L 127.0.0.1:9042:external-node1.somedomain.com:9042 \
    -L 127.0.0.2:9042:external-node2.somedomain.com:9042 \
    -L 127.0.0.3:9042:external-node3.somedomain.com:9042 \
    -L 127.0.0.4:9042:external-node4.somedomain.com:9042 \
    -L 127.0.0.5:9042:external-node5.somedomain.com:9042 \
    -L 127.0.0.6:9042:external-node6.somedomain.com:9042
  • Vagrant proxy through CNTLM on Windows using CYGWIN

    Wow, talk about a crappy post title, but I just got this working on my corporate network and was quite happy about it.
    Reason for this post; Every time I start a new assignment at a (rather big) corporation, I need to follow these steps to be able to access the internet from my vm’s.
    (and I keep forgetting the steps, I’m getting old..)
    What we’ll use to get this working:

    • Cygwin : https://www.cygwin.com/
    • Vagrant : https://www.vagrantup.com/
    • Virtualbox : https://www.virtualbox.org/
    • Cntlm : http://cntlm.sourceforge.net/

    I’m running CentOS vm’s inside Vagrant with Virtualbox provisioning on Cygwin on Windows 7. I’m running Cntlm to create a local proxy for all stuff what I’m doing through cygwin, because I don’t like putting clear text passwords in bashrc or in Win / Bash variables.

    Steps:

    1. Get your corporate proxy URL (Via Google Chrome)
    2. Configure Cntlm
    3. Configure Cygwin
    4. Configure Vagrant
    5. Use teh interwebs from your VM, practicing ninja turtle coding skillz and be instantly awesome!!1!

    (more…)

  • Puppet provisioning on Vagrant Error: –manifestdir

    This post is a distilled version of the discussion here: https://github.com/mitchellh/vagrant/issues/3740

    Problem:

    When I started using the latest Puppetlabs boxes, I encountered the error “Error: Could not parse application options: invalid option: –manifestdir” when my puppet manifest was about to be executed. (more…)