SQL to CSV tool – Export properly formatted CSV from an SQL query

SQLtoCSV produces well formatted CSV documents from SQL queries, even where the data results contain line breaks, speech marks, quotes and commas.

Latest Release: https://github.com/deeja/SQLtoCSV/releases/latest

SQLtoCSV-screenshot

The reason this thing exists: SSMS’s export doesn’t work.

SMSS = Microsoft’s SQLServer Management Studio

If we have basic data (no line breaks or commas), then we can use MSSQL Management Studio to export basic data to CSV:

export as csv

There is also the option of the copy/paste functionality to copy data into Microsoft Excel or another spreadsheet application.

copypaste

These both work alright and most of the time you can get away with them without issue.

The problem is when the data starts to get tricky. If you have line breaks, it starts to mess with the output, and the CSV ends up broken.

Kind of how this seeming innocent data:

datatable

Produces this catastrophe using the “Save As [CSV]” built into MSSQL:

csv broken

Whereas, if you use the SQLtoCSV tool above, it produces:

datatable

Now go use it!

https://github.com/deeja/SQLtoCSV/releases/latest

Thanks to Josh Close for maintaining CsvHelper and for effortlessly handling all the awful CSV I have to deal with regularly.

Olympus PEN E-PL3 – Changing battery loses settings workaround

The Olympus PEN series seems to be afflicted with a malfunctioning (or incorrectly set up) capacitor. This capacitor holds enough power in the system to keep the settings, such as date and time, while the battery is being changed. Except that it isn’t working for me.

For me, upon taking out the battery out of my E-PL3, the date resets. Googling this issue I found this comment on Flicker:

EnzoLopardoPictures says:

Hi ransome2012 – just had the same problem and I solved it accidentally!
Try to remove the SD-card first and then change the battery. With my camera this saved date & time.

Greeting from Switzerland, Enzo

So the workaround is: Remove the SD Card before changing the battery! 

With the SD card removed, the settings are persisted greater than 10mins.

My simple theory here is that the SD card (or a system that monitors the SD card) is being powered when the camera is off. That seems odd to me, but no doubt there is a reason. The result is too much power being used for the capacitor to handle. Perhaps, while being designed, the camera went through settings persistence testing with no SD card in place.

Still, the issue is ridiculous really.

New Zealander going to the Netherlands on a Working Holiday Scheme (NL WHS)

If you want anymore info on this, send me an email.

  1. You will need the current prerequisites. 
  2. Get the visa. I am not sure if you need current residency in the country you are in, which is the usual situation for visas. Apply before you leave and you will save yourself so much stress. You can apply in London, which I did. It took about a week. You DON’T need an appointment for the visa IN London (I know it says you do, but you don’t), but you do have to turn up at a certain time; before 9.30 when I did it. Call them. Yes it is a pain in the ass.
  3. When you get there, register at a police station. Well, you can try and infact you should be able to, but it seems impossible as noone at the police station knows about this type of visa. I ended up going to the foreigners police (Vreemdelingenpolitie) and registering there. They will say you don’t have to go there and you can do it at any police station, but good luck with that. It will take about 1-2 hours depending on the number of people.
  4. Get an address to send mail. Somewhere, anywhere in the Netherlands. You need it to do anything with the authorities. Find a long lost Dutch friend or anyone you know (you must know someone Dutch) and get an address. Write it down. Carry it in your wallet.
  5. Get a mobile phone number. Memorise it.
  6. Make an appointment with the IND. Take the Visa fee in CASH. If you can, go to the centre in Hoofdorp. It is almost immediately outside the station. Look for the IND sign. You go up some stairs. It takes about an hour and you get your passport back immediately. No waiting for it in the mail. Now you have another sticker in there.
    You will need all your evidence of money, travel insurance, and flights!
  7. Ignore people that say you need a work permit. You don’t. It is in the visa.
  8. Make an appointment with the Tax Department directly and apply for a SOFI (a kind of temporary, but somehow lifelong, tax number) The longer term number which you get if you register with a city is called a BSN number, which is the same thing really.
    When you get there, they might say you need a work permit. Tell them it is included. Show them the letters you received or got when you applied. Point to somewhere in the middle of your new visa from the IND and say “it says here I don’t need one” even though you clearly have no idea. It does say it there somewhere. Don’t worry, they will probably lose your booking and you will have to wait 2 hours there giving you enough time to sort it out. Don’t make phone calls  in the waiting area. They don’t like it.
  9. Don’t worry about registering with the city / town hall. This is a difficult thing to do unless you are paying rent where you have a rental agreement and are likely to stay more than 4 months. As you basically have a free pass with the WHS to wander around, you won’t be staying in the same place. If you don’t “register”, you also don’t need to “de-register” as you never technically were in a city. Makes things easier when you leave.
  10. Get a bank account. You need a SOFI or BSN for this, so you will need to have gone through the hoops to get here. You won’t get paid in the Netherlands without a bank account. Most places will not take credit cards. Almost all will take cash except for some annoyingly poncy places like the fancy supermarket “Marqt”.
  11. Remember you are there, by the terms of the visa, to explore the culture of the Dutch. Take some lessons in basic pronunciation. It will help you significantly getting about.

There are somethings to note.
Dutch customer service is questionable at best. I am not against the Dutch, it’s just that many shops or government departments appear to see you as a hindrance rather than a customer / client.  This doesn’t always apply. Many of the local pubs and restaurants have the most “keen to impress” owners. I had a Roti restaurant owner go out and buy some meat from the supermarket because they had run out of the one I wanted.

In regards to the requirements of the visa, they say you need a birth certificate. I never actually used mine, even though I have it. It cost $70 (Certificate + Dutch Authentication/Translation done in Wellington). Supposedly you use it when you register in a city. I never did, so never used it. I think you should probably get one. Just in case. Can be useful if you lose your passport too.

If you have any questions, just ask in a comment, or email me at dann@this sites address.

Home button doesn’t work on your Motorola Xoom running Android CyanogenMod?

So I rooted my Motorola Xoom MZ601 with UTMS (Everest) and installed the latest Cyanogen build (10.1 at the time I did it).

I start playing around with my new desktop, when I hit the home button to return to, well… home,  and nothing happens. It indicatively flashed at me, but nothing else; no action.

The fix is in the device_provisioned setting that is not turned on for some weird reason. This apparently kills other functionality as well, such as lock screen and other things.Read More »

Using Git with XpDev

I have an account over at www.xp-dev.com for my “self projects”.  Recently I was trying to get Git to work. This cost me more hair being pulled out than I was expecting.

Leave any good/bad comments at the bottom, and click the cookies please. They help me out in knowing I helped you. Cheers.

1. Generate a key using PuttyGen

image

2. Save the private and public keys somewhere safe.

3. Open up the public key file and cut the “Key” out.

image

4. On the XPDev website:  “Account” –> “Profile”  and find the “Add a new Public Key”. Paste it in there without any of the Comments or BEGIN/END stuff. Save it.

image

If you get this message then you have added something you shouldn’t have:

Unexpected Error
An error has just occured. It has been logged and will be dealt with shortly.
If it is urgent, please contact our administrators.

5. Add a remote repository to your local repository using the GitExtensions UI or

NOTE:  Your Git repository URL is:

ssh://USERNAME@git.xp-dev.com/YOUR-REPO-NAME

 

GitExtensions UI:

image

Command Line:
git remote add –mirror==PUSH  xpdev ssh://USERNAME@git.xp-dev.com/YOUR-REPO-NAME

6. Load the SSH key (or add it directly using PAgent), entering a password if you have one, then test the connection. It should say Shell logins are disabled. This is another way of saying you have authenticated, but you are not allowed to do anything via the Shell.

image

7. Push – Push it up. This should be the last time you use this specific local repo as you will clone one down in a second to replace it and doing so test the end result.

8. Clone – Clone the remote repo and use this new clone as your working repo.

Troubleshooting

1. Unable to open connection: host does not exist

http://serverfault.com/questions/212825/plink-without-any-parameters-says-unable-to-open-connection

2. Cloning into ‘X’…
error: cannot spawn C:Program Files (x86)Git ExtentionsPuTTYplink.exe: No such file or directory
fatal: unable to fork

I think the answer to this is the Program Files (x86) part. I think the shell script doesn’t handle this very well. I have no issues through GitExtensions UI so I won’t look for an answer.

IIS Websockets (for SignalR) do not work on Windows 7 (Even with IISExpress 8)

As Windows 7 is a “Down Level” OS for the IISExpress 8 webserver, there are three things that are not supported. One of them happens to be WebSockets:

There are a few features which require architecture that is specific to Windows Server 2012 and Windows 8 Client that will not work down-level when you install IIS 8.0 Express on earlier operating systems:

  • Server Name Indication (SNI)
  • Central Certificate Store
  • WebSocket Functionality

Using TortoiseGit with GitHub– A checklist rather than tutorial

UPDATE: Forget everything in this article -> Just go get Git for Windows v1

    1. Install msysGit  http://code.google.com/p/msysgit/
    2. Create a SSH key using Bash (id_rsa and id_rsa.pub)
    3. Install TortoiseSVN
        1. Use plink

 

    1. Use puttyGEN, which comes with TortoiseGit, to create a Putty private key from id_rsa like so:
      puttyGen –>
      Conversions –>
      Import Key –>
      Open %userprofile%.sshid_rsa –>
      Save Private Key
      as private.ppk (or whatever you want)
    2. Register your Public Key (id_rsa.pub) with GitHub i.e. Copy/paste the text inside the file into your Github account SSH Key (https://github.com/account –> SSH Public Keys)

 

  • Set your details from the Git Bash command line. The token is available from your Github Account Settings.

    git config –global user.name “Your Name”
    git config –global user.email “your@email.com”
    git config –global github.user your-github-name
    git conf
    ig –global github.token your-github-token
  • Get the Repository’s Read + Write SSH URL
    image
  • Clone the repository to a folder using TortoiseGit

 

  1. Load the putty key %userprofile%.sshprivate.ppk  if that is where you saved it.

Disclaimer

This is a rough summary of what to do, and more of a reminder to my future self. If you have any suggestions, let me know.

Asp.Net MVC3 Razor and RESX Localisations/Localizations

I was just applying for a small two week contract that was based on Localisation. This is the work I did to give myself a quick refresh. It reminded me on how well Asp.Net MVC3 works with RESX localisations.

imageAs a start, you will need someway to change your Local Language quickly. My preferred choice is using the Quick Locale Switcher for Firefox which is in the image.

I have (over the last few hours) built up a fully translated version of the default MVC3 project which is viewable at http://resxstuff.adventureswith.net and is viewable as 2 languages available English (Which is default) and French (which is terribly translated BTW).

Turn On The World – Enable Globalisation

To enable globalisation, you will need to add this line to your web.config  in the <system.web></system.web> section:

<globalization uiCulture="auto" culture="auto"/>

Add the RESX files; and let the class be seen

If you are coming from Web Forms, note that for MVC you DO NOT HAVE TO (and perhaps should not) add your RESX to App_GlobalResourses or even App_LocalResources.

Just add them wherever you want and they can still be used, but only if you do the following:

MSI Executable–Extract to a folder

Today I had the unfortunate situation of installing sample code files. This means downloading a MSI and then running it so it can place the sample code somewhere on your computer. I don’t think any developer can appreciate this. Where is the zip file?

Well, it kind of is a zip file. In a sense. You can run a command to output that pesky MSI to a folder. How?

Running as admin:

msiexec /a yourmsi.msi /qb TARGETDIR=c:output_to_here

Credit to neoice for answering this in StackOverflow

Using Common.Logging with Glimpse and ASP.Net MVC

Glimpse is an amazing tool (that comes available with Nuget in Visual Studio 2010 [included in the Tools Update]) that can hook into the System.Diagnostic.Trace (ewww) to display error messages on your client side browser. Like so:

image

I don’t want to use System.Diagnostics as my Logging system. I could use it on the side, but not as the core. This would be awful and much too rigid. The good thing is, I typically use Common.Logging in all my projects because of it’s way to tie ANY LOGGING SYSTEM into a single point then ship those events off to any other receiving system. The receiving system in this case, is  of course, System.Diagnostics.Trace using the TraceLoggerFactoryAdapter

So to get to the point above this is what I did:

  1. Using Create a new MVC project in VS2010
  2. Nuget
    1. Install-Package Glimpse
    2. Install-Package Common.Logging
  3. Add Common.Logging  to the web config
    <!--...config sections... --> <sectionGroup name="common"> <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" /> </sectionGroup> <!--...configuration... --> <common> <logging> <factoryAdapter type="Common.Logging.Simple.TraceLoggerFactoryAdapter, Common.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=af08829b84f0328e"> <arg key="level" value="ALL" /> <arg key="showLogName" value="true" /> <arg key="showDataTime" value="true" /> <arg key="dateTimeFormat" value="yyyy/MM/dd HH:mm:ss:fff" /> </factoryAdapter> </logging> </common>

  4. Add some “problems”image
  5. Run the project and go to http://%5Byour project url]/Gimpse/Configthen click “Turn Glimpse On”. Don’t be surprised that nothing happens.

    image

  6. Go to your main page http://%5Byour project url]/ – See the icon in the right hand corner? Click that.
    image
  7. Look at those errors!

image

Conclusion?

Amazing! The guys who made Glimpse deserve some sort of medal!