fun4jimmy.blog

Hello airplanes? Yeah it's blimps, you win.

  • home
  • links
  • tags
  • 07/10/2016

    • git
    • mercurial
    • windows
    • linux

    Setting Source Control Text Editors

    This post will cover how to set the default text editor used by git or mercurial via the command line. The default text editor is used whenever the version control system requires us to enter a message, like a commit message.

    Although we will set the editor from the command line on Linux and Windows bear in mind that for Linux the best way to set the preferred text editor is using environment variables. Both version control systems will check the $(VISUAL) and $(EDITOR) Linux environment variables (in that order of precedence) if no editor has been set. As they control the default text editor for the OS it makes sense to stick to just using those but we will still cover how to set via the command line as an example.

    continue reading

  • 14/09/2016

    • windows
    • linux
    • c
    • c++
    • git
    • mercurial

    Windows 10 Linux Development

    This post covers the starting steps required to start developing c or c++ programs for Linux inside Windows 10 using Bash on Ubuntu on Windows.

    Since the Windows 10 Anniversary Update (build 10.0.14393, version 1607) there is an Ubuntu bash shell available from within Windows without the need for a virtual machine or dual booting. Unlike Cygwin or MinGW it runs real Linux binaries directly from within Windows. This allows us to edit, compile and run Linux applications from Windows without the need for switching computers or operating systems.

    continue reading

  • 31/10/2015

    • c++
    • msvc
    • windows

    Fixing Visual Studio 2015 C++ Comment Highlighting

    Incorrectly highlighted comment.
    Incorrectly highlighted comment.

    Due to a bug in the current build of Visual Studio 2015 C++ comments starting with three forward slashes are highlighted in a different colour to all other comments.

    The colour difference is most visible when using the Dark colour theme but is present in the Light and Blue colour themes as well and has been observed in both the Community Edition and Professional Edition.

    continue reading

  • 15/09/2015

    • python
    • logging
    • argparse
    • snippet

    Configuring Python's logging Module with argparse

    This post assumes you're familiar with and using Python's logging module to log info from your script. If you don't care about how it works skip to the end to see the code for the full solution.

    Goal

    Our goal is to control the log level via the command line using an additional argument --log_level that takes a one of the logging module's log levels.

    $> script.py --log_level DEBUG
    

    And it would be nice if the parsed variable returned by argparse.ArgumentParser.parse_args() could be used directly as an argument to logging.Logger.setLevel.

    parsed_args = parser.parse_args()
    
    root_logger = logging.getLogger()
    root_logger.setLevel(parsed_args.log_level)
    

    continue reading

  • 15/09/2015

    • windows
    • batchfile
    • snippet

    Batch File Tips and Tricks

    A collection of some useful snippets for batch files.

    Controlling batch file output

    To stop every line of the batch file being output to the command prompt put this at the top of the batch file, this makes for a less noisy output.

    @echo off
    

    Echo the output of a command, useful for logging what the batch file is actually doing.

    for /f %%i in ('dir') do echo %%i
    

    continue reading

  • 26/04/2014

    • bash
    • goserver
    • macosx
    • java

    Running ThoughtWorks Go Server as a Mac OS X Launch Daemon

    ThoughtWorks Go is a continuous delivery system that has recently become open source and free to use. This guide will talk you through the steps necessary to get the Go Server up and running as a Mac OS X Launch Daemon so there is no need to log in to start the server.

    So we don't tie our Go Server instance to an existing user account we should create another account just for running the server. This allows other users to help with server maintenance without us having to give out our credentials and it also prevents us from accidentally messing up our account if anything goes wrong. Let's create a new administrator account with the username build and log in.

    As Go Continuous Delivery is written in Java we should install the latest version of Java if it's not already installed.

    continue reading

  • 01/05/2013

    • python
    • clang
    • c++
    • c

    Finding all #includes in a file using libclang and Python

    For a good introduction in to using libclang and Python see here.

    Assuming that you can or have built libclang with the Python bindings, below is a script that loops through all the #include statements in a single C/C++ file printing out the files they reference.

    continue reading

  • 07/03/2013

    • msvc
    • windows

    Finding Visual Studio Command IDs and Guids

    If you close all open instances of Visual Studio 2012 add the following undocumented registry key to your registry:

    Windows Registry Editor Version 5.00
    [HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\General]
    "EnableVSIPLogging"=dword:00000001
    
    Visual Studio File.New VSDebug Message.
    Visual Studio File.New VSDebug Message.

    When you next start Visual Studio you can find the command ID for menu items by holding Ctrl+Shift and hovering over the menu item. After hovering you are presented with a modal dialog containing debug information as seen in the image to the right. This information can, for example, be useful in .vsct files when extending Visual Studio functionality.

    This will work for most menu items although Ctrl+Shift hovering over dynamic menu items like those found on DEBUG menu will for some reason not pop up the dialog.

    This information is shamelessly stolen from this MSDN blog post which also contains more in depth information about the topic.

    continue reading

  • 30/12/2012

    • c++
    • dlls
    • windows

    Exporting C++ from dlls

    This post will cover how to export functions from a windows dynamic-link library starting with the basics and then covering some more advanced examples. The first part of this explanation is very similar to this msdn article, so if you already know that you may want to skip ahead to the [Advanced Exporting]({{ page.url | prepend: site.baseurl }}#advanced-exporting) section.

    Basic Exporting

    So let's start with the basics, to export a function from a dll you need to inform the compiler which functions and classes you want to be accessible from the library. This can be done in multiple ways but the simplest is to use __declspec(dllexport) to markup the functions or classes when declaring and __declspec(dllimport) when using them.

    // function declaration in library header
    //
    __declspec(dllexport) void function();
    
    // function declaration in executable source
    //
    __declspec(dllimport) void function();
    

    continue reading

  • 17/12/2012

    • c++
    • templates
    • snippet

    C++ template syntax

    This post will cover some less common syntax that is useful when dealing with templates. The class used to demonstrate the syntax is only as an example, it is not supposed to be a good example of a working smart pointer class.

    Let's start with a simple SmartPointer class and how to write template function definitions outside of the class definition:

    // define the class
    //
    template<typename PointerType>
    class SmartPointer
    {
    public:
      SmartPointer(PointerType *pointer);
      ~SmartPointer();
    
    private:
      PointerType *m_pointer;
    };
    
    // define the member functions
    //
    template<typename PointerType>
    inline SmartPointer<PointerType>::SmartPointer(PointerType *pointer)
    : m_pointer(pointer)
    {
      // do some stuff
    }
    
    template<typename PointerType>
    inline SmartPointer<PointerType>::~SmartPointer(PointerType *pointer)
    {
      // do some stuff
    }
    

    continue reading

  • fun4jimmy.blog
  • fun4jimmy
  • fun4jimmy