Posts

Showing posts from April, 2020

Visually Distinguish Remote ssh Sessions

Image
When administering resources it's often convenient to use the command-line.  For security it's necessary to use an encrypted mechanism - almost always ssh .  However, since once connected, one terminal window looks much like another, there's a significant risk that a command intended to be run on one server gets run on the wrong one!  How can you protect against this and still work efficiently? One way is to have each ssh session clearly, probably visually  different from each other.  This can be automated in Unix based systems. Use xtermcontrol There are various ways to control aspects of your terminal session.  Simply printing to the terminal various escape codes can change many aspects of the terminal - including color, but also title and so on.  However, to conveniently and specifically make fine-grained changes, xtermcontrol is very effective and available across many platforms.  It is preferable to setterm  because it gives m...

Creating GIFs From Videos

While it is easy to embed videos in web-sites, sometimes you want the immediacy that you get an image. GIFs are the obvious answer to this "a video in an image file".  Creating them is not always obvious though. There are many pieces of software that can be used.  On Linux, one is gifcurry  which is not bad and interestingly is written in Haskell , a sophisticated type-safe functional language.  Gifcurry does suffer from a few limitations such as for long videos however. ffmpeg After some experimentation, the most reliable mechanism I've found is old faithful command-line utility ffmpeg .  Once you know the correct arguments to pass, it is reliable and fast. You do it in two steps.  First you extract a colour palette from the video, then you create the GIF using that palette: ffmpeg -i <Video File> . <extension>   -filter_complex "[0:v] palettegen" <palette file> .png ffmpeg -i <Video File> . <extension> ...

Video Editing Individual Frames

When using video editing software like FlowBlade or OpenShot , there are occasions when a single frame needs to be extracted, either to observe, to use as an image or to adjusted and re-inserted. While packages have means to change content even on a single frame level, sometimes bespoke actions are needed.  One way to do this is with ffmpeg . What is ffmpeg ?  ffmpeg is a command line  tool - i.e. you use it by typing ffmpeg followed by various options on the command line .  ffmpeg in fact sits on top of a number of libraries.  It uses these libraries to do manipulation of video files.  It supports, basically, all video formats . For the purposes of this blog, we're interested a small aspect of ffmpeg 's functionality, namely that pertaining to individual video frames . Finding the Frame In order to extract (for whatever purpose) a single frame from a video, first that frame must be located.  With FlowBlade and OpenShot, sequencing of...

Video of a Software Development Terminal Session

To record a software development terminal session it is helpful to have more than one screen: one screen to operate the recording software - say OBS Studio - and another to run the software being recorded.  It is assumed henceforth that the user has at least two screens and is using OBS Studio. Steps to Prepare to Record a Terminal Session Choose the screen (different from the one running OBS Studio) for the terminal session. Add in the Sources window of OBS Studio a new Screen Capture source by clicking the + button and choosing that source from the list. If recording audio, add the appropriate audio source Correct the prompt and the terminal title . Remove unnecessary output, such as Python warnings . Change background image to something neutral Recording the Session Prior to recording you should have a script - or at least a sequence of prompts.  Using a script that you read could sound mechanical and forced whereas without one, you may find yourself making...

Set Up For Recording Software Development Under Linux

Software development under Linux typically involves: programming languages: one or more, such as Python or C++ IDE s - one or more The installation of packages via the command-line using apt , snap , pip (for Python), npm (for Node.js ), gem (for Ruby ) and many others. An execution environment: this depends on how and where the software is to be deployed.  Typically it is on a Cloud server. Test mechanisms.  These will normally simulate execution to some degree In order to demonstrate software as it is developed and how it is developed via video (i.e. Youtube or other systems) it is necessary to capture the above systems "in action" (or to simulate such capture).  This post gives some details of one set up to do this. Preparing for Screen Capture Since, typically, software development videos are for a general audience, it is worth preparing the recording environment well - removing personal details for example.  For instance by default for many d...

Removing Python Warnings

In order for Python  scripts, when run from the Terminal , not to show warnings, the PYTHONWARNINGS shell variable can be used. To stop any warnings occurring, do export PYTHONWARNINGS=ignore There are various reasons you might want to do this, for instance, when showing others some sequence of Python commands during a talk, webinar or video screen recording.

Change Unix terminal Title

Changing the Terminal Window Title Text To change Linux (and perhaps other systems) Terminal windows' titles, you must use escape codes as follows: printf "\e]2;YOUR TITLE GOES HERE\a" If you execute this in a terminal session, it will change the title of the terminal to “YOUR TITLE GOES HERE” If you omit a title string (i.e. use printf "\e]2;\a" ), the title will default to “Terminal”. Correcting PS1 From Resetting The Title There is one situation in which the above may seem not to work: when the screen title is set within the Unix prompt construction. How The Unix Terminal Prompt is Set The in a Shell , the PS1   environment variable controls what texts is shown at the prompt. Every time a shell command completes and the prompt is shown, PS1 is evaluated. Since it is a shell variable, anything that can be done in the context of shell variables is possible with the PS1 prompt - in fact arbitrary shell code is possible to be run dur...

Check Details of X Process

Image
Using a Unix with a GUI (therefore X Windows ), to find out information about a particular running GUI application, use xprop . Running it will change the mouse cursor (normally to a cross) prompting the user to select an application on the GUI. Once selected it displays many lines of information. For example, the X Window for a Terminal Window might show: This is particularly useful if a GUI application has hung. Running xprop and choosing the application then noting the process id at _NET_WM_PID , allows you to kill that process ( kill -9 <PID>)

Freeze Changing HTML Element in Chrome Developer Tools

Some websites have elements attached to code that changes them dynamically, so that it is not effectively possible to view its source - e.g. notion.so . To freeze the elements in the Developer Tools windows: Open the Developer Tools windows from the top-right “3 vertical dot” menu → More tools → Developer tools, or Ctrl+Shift+i (Window/Linux) or Option+⌘+J (Mac) Select the Sources tab in Developer Tools In the browser, hover over the element concerned (don’t click) Press F8 (Windows/Linux) or FN+F8 (Mac) Go to the Elements tab in Developer Tools The elements will be paused. It will be possible to expand the elements and see the frozen source. (From stackoverflow )

Github as git Repo From the Command-line

In order to use github.com as a git repo from the command line, first set up the ssh URL (rather than the https URL). Then you must provide github.com with your public key . After that git can be used in the normal way from the command line.