Skip to main content

Posts

Git: reset the stage after a bad merge

 When working in teams that use branches in git, eventually you're going to get a merge conflict. Most of the time this isn't to much of a problem you just work through the conflicts and commit the changes.  From time to time I mess up the merge and I want to just restart resolving the merge conflict again. Thankfully git make it easy if you haven't committed the changes. Just run the command git checkout -m <file name> That's it, you can now try and do the merge again as if you haven't resolved the latest conflict.

How to Pretty Print JSON and XML from the Command Line

As developers we often need to take minified JSON and XML and pretty print it so it is human readable. A multitude of websites provide a free service where you can enter minified JSON or XML and it will format it the data so it is human readable. The problem is this can lead to leaking data causing security incidents. The solution is to write a couple of bash scripts to pretty print. A big thanks to Campovski 's answer on stackoverflow for the JSON and Ben Noland 's answer on stackoverflow and Anton I. Sipos ' comment for the XML I took these answers a little further and created a bash script that accepts arguments so you can pretty print A file The result returned form an API A string Data piped in Both scripts have the same usage Format a file with the -f flag JSON ./pretty_json.sh -f <name_of_file> XML ./pretty_xml.sh -f <name_of_file> Format the return value of an API with the -u flag JSON ./pretty_json.sh -u www.api.com XML ./pretty_xml.sh -u ...

Creating Multiple Files for Testing

I recently needed to create a number of files to test uploading. Copying and pasting multiple times seemed like to much work, so I wrote the following script to do the hard work for me. create a file called create_files.sh and make is executable $ touch create_files.sh $ chmod 774 create_files.sh Then open create_files.sh and paste the following script for i in $(eval echo { $1 .. $2 }) do echo "Test file $i " &gt; file $i .txt done The script takes two arguments, the number to start at, and the number to finish. This is useful for cases when you create files then discover you want more. Example $ ./create_files.sh 5 9 $ ls -la drwxrwxr-x  ./ drwxrwxr-x ../ -rwxrwxr-- create_files.sh* -rw-rw-r-- file5.txt -rw-rw-r-- file6.txt -rw-rw-r-- file7.txt -rw-rw-r-- file8.txt -rw-rw-r-- file9.txt I also created a script to copy files, as I also wanted to test uploading images and other file types create a file called copy_files.sh and make is exe...

Run MochaJS Tests Recursively

I've been doing a lot of NodeJS lately and one thing I always forget is how to run Mocha recursively. To run all test recursively update your package.json to include the following { "scripts" : { "test" : "mocha --recursive './{,!(web|node_modules)/**/}*.spec.js'" }, } to run the tests, run the following command from where package.json is stored npm test or yarn test The test entry in the package.json file will run MochaJS recursively on all directories except web and node_modules directories, and run the tests in any file that ends with the extension .spec.js Excluding the node_modules directory is a good idea because you don't need to run the tests of your installed packages and when you have a lot of packages installed it can slow down your test suite. If you're using windows you might need to use double quotes instead of single quotes. For example "test" : "mocha --recursive \" ./{,!(web...

git log, Make It Beatiful

Another developer I work with just showed me a much nicer git log command experience. It gives pretty colours, the commit id, the author and much more. The idea comes from Filipe Kiss' blog  however the solution I use was submitted in the comments of the blog post by LordMonkey The following command creates an alias lg for the git log command. git config  -- global   alias . lg  "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative" git lg will then result in something similar to I have blurred text to protect privacy

Turning Off SSLv3 in Apache and IIS8, AKA Putting Down the Poodle That Bites

Poodle is a security vulnerability that has been found in SSLv3. Since SSL is over ten years old, and the only browsers that support it as the strongest version of encryption are IE6 and older, in my humble opinion it is safe to turn it off.  Let's start with the easy one, Linux, in particular CentOS. NB you will most likely need to be root or be part of the sudo group to make the following changes 1)     Open the ssl.config file with your favourite text editor. In Red Hat based distributions like CentOS you should find it in /etc/httpd/mods-available/ssl.conf 2)     Find the line starting with  SSLProtocol 3)     Change it to  SSLProtocol all -SSLv2 -SSLv3 This will allow all ciphers expect SSLv2 and SSLv3 4)     Save ssl.conf and exit your text editor 5)     Restart Apache by running the command service httpd restart 6) ...

Change the Colour of Emacs Shell Prompt and Font Highlighting

The project I'm currently working on is Linux based, and I just can’t get my head around vi no matter how hard I try. Fortunately I have root privileges, so Emacs to the rescue :) We are using CentOS so installing is as easy as sudo yum install emacs   One of the many reasons I really like Emacs is you can run a shell inside Emacs. Press Alt – x Type shell Press enter NB the Alt key in Emacs is often called the Meta key and the key combination above would be shortened to M – x This allows me to split the Emacs window and have the shell in the bottom half and what I working on in the top half, see the image below. To switch between the shell and what I’m working on I press M – O (that’s Alt and the letter O and not the number zero, Alt zero will unsplit the screen) If like me you’re running Emacs inside Putty the first thing you might notice is the shell prompt is in dark blue on a black background. Not only is this very difficult to read but it c...

Turn off Windows Default Sounds and Stop Driving Your Co-Workers Crazy!

Another year goes by and despite my best intentions I haven’t posted anything on my blog. Since it has been over a year since my last post I thought I would post something, if nothing else at least I'm consistent. If like me you work in an open office environment you might find all the unnecessary sounds alerts of Windows irritating. This is especially true for developers as something we need to test something over and over. A popup or message box with a loud “DING!” gets old pretty fast. It’s even faster if you are a co-worker listening to the repeated “DING!” over and over. While one solution is to just mute the speakers that means other, and what I actually consider useful, sound alerts are muted, like incoming email sound alerts and Skype messages. My solution is to disable the sounds I don’t want to hear. I’m sure everyone know how to do this but just in case. In Windows 7 Click on “Control Panel” Click on “Start” Click on “Sound” Click on the “Sounds” Tab ...

At Long Last a Side Project

It’s official, I have an active side project. What is it? A Visual Studio Plug-in to allow developer to deploy an ASP.Net website directly from SVN to a website server. Why? Deploying ASP.Net applications/websites to multiple server and setups is error prone because to many manual steps exist. Deploy ASP.Net from SVN aims to solve this issue by automating as many steps as possible and deploying a website in just a few clicks. Project Description Deploy ASP.Net from SVN is a Visual Studio Add In to allow developers to deploy as ASP.Net website from source control (initally only SVN but others may be added in the future) to a web server or web farm easily. Project Goals To make it easy to deploy an exact version of an ASP.Net website directly from source control. Features will include Deploy particular revision.  Read deployment settings from a selected file to make deploying to development, test, stage and live servers the same process.  Build a web.config file f...

Visual Studio 2010 "No Visual studio template information found. See application log in Event viewer for more detail" solution

Thanks to Sathya Narayanan Srinivasan for his blog post on solving this issue. The solution is: 1. Close Visual Studio 2. Open Visual Studio Command Prompt. (Start Menu --> Microsoft Visual Studio 2010 --> Visual Studio Tools. Right-click on the Visual Studio Command Prompt shortcut, select Run as Administrator.) 3. run the command "devenv /installvstemplates"

I've missed you, you don't write anymore!

It’s been sometime since my last blog post, you might have thought this blog was dead, but it isn’t. Since my last post I have moved to London. I decided it was time to live in the northern hemisphere for a while and explore this part of the world. As you can imagine moving to the other side of the world does take a little bit of time. It also explains why my side project hasn’t progressed any further. I’m now a happy job hunter in merry old England. I am also trying to find a good C# community group, but sadly I’m having trouble finding even one that meets on a regular basis. So if you know of one let me know about it. Once things settle down a little bit I will start to post more and work on the project will commence.

Google Wave Gadget

I think I have come up with an idea for an open source project using ASP.Net. We now have an almost infinite number of ways to communicate using the internet, with more coming online every day. The problem is that if you want to create an event you need to use at least the following servers 1. Facebook (must have) 2. Twitter (must have) 3. Google Calendar (nice to have) 4. Flickr (maybe have) 5. Blog (maybe have) 6. Google Wave (must have in the future) In fact this may work best as a Google Wave Gadget, now to discuss the idea with the person I have teamed up with to see if he likes the idea too.

Abandoned Project, and I hadn't even started it yet

I was thinking about creating an open source product using C# ASP.Net that allows people using a web browser or mobile device (with a web browser) to connect to the iPROsoft/LEVESYS software package. After discussing this with a work colleague, I found the project would infringe on the intellectual property rights of iPROsoft/LEVESYS, so unfortunately I will have to abandon the idea. The search for a C# ASP.Net project continues.