XCode Swift GET Request and Parse

Angular

Delete/Modify all Jenkins CI jobs

Navigate to

http://jenkins-ci/script

then, to delete all jobs, run:

To filter and disable jobs, run:

The Jenkins API docs are here

Python Logging Annotation – Automatically create logger for methods

This is a pattern for creating an annotation that will “inject” a logger into a python method. This allows you to decorate a python method with @logged and you will have a variable named logger created with your method name.

This is nice because you do not have to have boilerplate code all over the place.  It also allows you to easily have a logger for each function instead of a global logger.  This makes reading logs much easier since you can tell exactly where your logging call was made.

Here is an outline of the process, the comments in the code explain where these steps happen:

  1. Get the global variables for the decorated function
  2. If there is an existing logger in the function, we save it
  3. Create a new logger with the function name as the logger name
  4. Set the new logger as a global variable for the function
  5. Call the function
  6. Restore the existing logger as a global

Now your methods will look like this:

Eclipse Luna ‘Build Automatically’ is checked but not working

Eclipse Luna – had “Build Automatically” checked when Eclipse stopped compiling my classes automatically. Finally figured out that the .project file was missing an entry for the javabuilder, so I opened it and added:

Then it worked.

DJango Web Servcie

For a web service that is going to be called from an external site, we need to add the CORS headers to make sure the browser will allow it:

Bootstrap Horizontal Form

PowerShell Write-Host versus Write-Output

Working with PowerShell, I had a program that was scheduled and was using Write-Host to print messages. This works great if you’re running it in the terminal, but it is not redirectable.

This means that if you schedule it and redirect the output (powershell.exe output-demo.ps1 >out.txt), you get nothing.

However, Write-Host for a comma separated list writes all of the list items on one line. Write-Output puts a newline in between. Take a look at this script:

Here is the output:

The first line is the Write-Host and the next 2 are from the Write-Output. I don’t know why this is and will update with more information.

C# Process.Start with hidden terminal window

Having issues getting the System.Disagnostics.Process.Start(…) method to run a process and hide the window. I tried all sorts of things including:

Finally came across this page on the msdn site that says:

If the UseShellExecute property is true or the UserName and Password properties are not Nothing, the CreateNoWindow property value is ignored and a new window is created.

I’m using the method:

Start(String command, String arguments)

However, there is another method that is:

Start(String command, String arguments, String user, SecureString password, String domain)

So, if we change the last line from:

p = Process.Start(proc, args);

to:

p = Process.Start(proc, args, null, null, null);

it works! Here is the complete code listing: