Posts

Debugging C++ Compilation and Linking

Going Verbose Using -v  in a g++  or gcc  command line will provide verbose output, however to get the linker that is called by  the compiler to give verbose output requires the appropriate flag to be passed on to the linker.  This is done using the -Wl, ___ mechanism.  To cause verbose linker output it is: -Wl,--verbose

Stop ssh Terminal Sessions Hanging

On some Linuxen, when you ssh to another server, after a timeout it drops the connection.  That terminal session is now frozen.  There are at least three solutions to this: When your terminal freezes, you can get out of it by typing, one by one: [Enter] then [ ~ ] then  [ . ] . This will bring you back to the terminal session where you executed the initial ssh . Create or open ~/.ssh/config .  For the host(s) your dealing with, in their sections, add a line ServerAliveInterval 240 indented by two spaces (or inline with the othe entries) something like: Host remotehost HostName remotehost.com ServerAliveInterval 240 or, if you wish this to apply to all hosts: Host * ServerAliveInterval 240 If it's not the default, make sure  ~/.ssh/config is readable by all by doing $ chmod a+r ~/.ssh/config Instead of trying to keep the connection alive you can use terminal multiplexors, like screen  (or  tmux ) that keep the session alive in the background e...

Making Linux Command-line Programs Graphically Startable

Many Linux applications are started from the command-line, and this is fine.  However, if frequently used, it can become slightly inconvenient, especially when the command name is not properly remembered.  It would be nice to have it available somewhere on the desktop to click and start. I now do this as a matter of course.  I use .desktop files.  There are many ways to put this together - I'll describe the system I use. I use, in my home directory, the .local subdirectory.  In .local I create (if not there) a share directory and beneath that applications and icons . cd mkdir -p .local/share cd .local/share mkdir applications icons Perhaps you want to get the program my_command that you put in .local/bin somewhere on your desktop.   You'll want an icon.  I suggest searching Google for some text describing the function of the application, choosing "Images" and downloading an appropriate small image, or, using a screen grabber like Gnome Screensho...

Jekyll After Ubuntu Upgrade

I recently had some issues running my Jekyll site after upgrading my OS ( Pop!_OS , an Ubuntu derivative). Ruby Jekyll is a static web-site development environment - very useful for blogs but also general purpose landing pages.  I use it for profitview.net  for example.  It is written in Ruby, a dynamically typed general purpose language, made popular in particular through Ruby-On-Rails website development system that became popular  in the mid 2000s. When updating Pop!_OS typically a new Ruby version will be installed - and the old one removed to avoid conflicts.  Ruby's bundler refers to a specific Ruby instance - which may no longer be there.  Therefore this must be updated.  The mechanism for doing this is as follows: gem uninstall bundler gem install bundler This simply causes it to use the current native Ruby.  Unless the changes in Ruby are substantial, this should cause no problem. Jekyll With the newly installed bund...

TEX on Linux

Image
This is not really a Web Dev tip, but I thought it worth quickly noting for those who have a need to produce properly formatted mathematical (and other) high quality textual output on Linux. T E X  is a typesetting system - it lets you format text at the quality of a formal publication like a book, magazine or journal, including complex text formats like equations.  It includes a ( Turing-complete ) language making it extremely powerful. Installing it to use on Linux, is not difficult, however installing MiKTeX with TexWorks  on Ubuntu/Pop!_OS 19.10 as I have requires some additional steps. MiKTeX MiKTeX is a system that brings together a large set of  T E X  related programs.  One system that comes bundled with it is TexWorks.  Using these two works well for normal mathematical formulae that I've tested. TexWorks TexWorks is a convenient  T E X  editor.  You can write your  T E X  and immediately create PDF output...

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> ...