Adding a character to the end of a field using MYSQL

SQL

I was recently looking for a quick way to add a comma to the end of a MYSQL field. My first thought was to loop it through a PHP script and update the string for each field. This seemed like a long way round and I always love a good 1 line SQL statement fix so here it is.

update table set field = concat(field,’character to update’);

Advertisements

Setting up Notepad++ to look like CodeAcademy

helloworld

I love a good looking IDE and recently came across a nice website called codeacademy.com. They have a beautiful colour scheme, so I tried to replicate it on my own notepad++ setup. Here’s how…

NotePad++ >> Settings >> Style Configurator >> Style >> Default Style

Now change the default style font (not the global override) to “Courier New”, and to size 12 (or size 14 if you use a 1080p screen). You should now see a nicely spaced font with quite big text.

Lastly we need to apply a new theme to Notepad++. The theme is called “tomorrow_night” and can be downloaded from here:

https://github.com/chriskempson/tomorrow-theme

Simply copy the notepad++ specific XML files into the file explorer url location:

%APPDATA%

/notepad++/themes

NOTE: This location will depend on your set-up, sometimes it can be in the program files/notepad++ location if you chose that option on install.

Since the theme is available for lots of editors, you can also do this for SublimeText 3.

Happy (beautiful) coding

Flipping “surname, firstname” to “fullname” with just MYSQL

SQL

I love a good quick data fix and recently found this one on stackoverflow.

Say you have a MYSQL field with this format:

Surname, Forename

and you want to get into a new field:

Forename Surname

You can do this from the SQL prompt:

# Add new column
alter table $TABLE add $newField varchar(40); # or something like that

# Populate new data
update $TABLE set $newField = CONCAT(
  SUBSTRING_INDEX(SUBSTRING_INDEX($oldField,',',2),',',-1),
  ' ',
  SUBSTRING_INDEX($oldField,',',1)
);

Great stuff and very quick too!

Source – http://stackoverflow.com/questions/2654716/how-do-i-flip-a-column-in-mysql-that-has-data-structured-last-name-first-name

Customizing Notepad++ to look like Sublime Text 3

I use notepad++ a lot in my work on php code and general text editing. I love the software’s features and how quickly it loads a text file. I’ve also been testing out Sublime text 3 but didn’t quite think it was as good as notepad++ but I loved the visual style they use.

If you want to make notepad++ use a darker theme and the same text colours as sublime text do the following:

Settings >> Style Configurator

1) Select Theme = Monokai
2) Style >> Default Style >> Font Name = Consolas
3) Font Size = 12

Now save and close the window. Restart Notepad++

Image1

EDIT: If you want an even more authentic font then you can install this custom TTF file which is a clone of the apple Menlo-Regular developer font.

https://github.com/andreberg/Meslo-Font

I personally prefer Consolas though as it works nicely even on remote desktop screens.

Moving the User profile folder to another drive

Ever run out of space on a PC due to large profile sizes? We use small SSD’s here so this is a common occurance on older PC’s with the small drives. An easy way to fix is to install a new small SSD to create a D: drive and move the userdata folder over to that. Its quite easy to do.

http://www.sevenforums.com/tutorials/87555-user-profile-change-default-location.html

Be warned though as microsoft advise against this as it can break upgrades and even windows update for some reason.

http://www.zdnet.com/article/dont-move-your-windows-user-profiles-folder-to-another-drive/

Grabbing the User Container string from Active Directory

Active-directory

Ever wondered how to get the exact User Container String for your user OU in active directory? A lot of software needs this for things like single sign and such. Here’s how to do it quickly:

dsquery ou domainroot > c:\string.txt

This should give you a text file in the root of the C: drive called string.txt. Open that text file and you will see all the strings to each container. Select the correct container and copy and paste the line. Its a nice quick way of getting it I’ve found to do it accurately instead of struggling to create the link manually. Original source