CodeAnywhere 1.0.0.17

January 21st, 2010 by Andrew Vos

Version 1.0.0.17

  • Now compiles to .NET 3.5 instead of 2.0
  • Added support for updating from the context menu
  • You can now return an object instead of a string, and CodeAnywhere will do a ToString on it before writing it back

Sorry – haven’t been around in a while. Thought I’d stop by and release an awesome piece of software, CodeAnywhere.

Let’s say you have this:

CodeAnywhere1

And then you press CAPS LOCK:

CodeAnywhere2

CodeDOM compiled the code and executed it. (It’s C# code, by the way)

BAM.

I wrote this on the train travelling to work everyday.

Install it here

Things to note:

  • It uses UI Automation to grab the text, so some apps won’t work. Notepad and Wordpad definitely do though.
  • It’s meant to set CAPS LOCK state to off when it starts. Some people have reported that it doesn’t though. Comment below if this is you (state your OS please)

Popularity: 1% [?]

Posted in C#, Code Projects, Coding, Download, Downloads, Software having no comments »

No templates after installing ASP.NET MVC 1.0? Here’s a workaround

August 18th, 2009 by Andrew Vos

If you encounter this problem and you used the Web Platform Installer here’s an easy workaround:

  • Download the Asp.net MVC installer here.
  • Run the setup file and Remove Asp.Net MVC.
  • Reinstall.

Popularity: 1% [?]

Posted in ASP.NET MVC having no comments »

A SQLite port to C#!

August 14th, 2009 by Andrew Vos

The popular SQLite library has been ported to C#!

Currently “2 errors out of 30054 tests” are reported in the version history. I’m going to wait for a future release, because it seems the code hasn’t been optimized properly for C# yet according to the benchmarks.

csharp-sqlite - Windows C# port of the SQLite library

Popularity: 1% [?]

Posted in .NET Framework, C#, News having no comments »

CopyPasteTool

May 21st, 2009 by Andrew Vos

Download it now.

http://www.copypastetool.com/

From the site:

This small tool allows to save several values of text in clipboard and paste them. Use standard keys for copying (CTRL+C) and pasting (CTRL+V) as usual, but if you want to paste previous text in clipboard then simply press V again and don’t release CTRL. It’s free.

Popularity: 6% [?]

Posted in Software, Tools having 1 comment »

Derek

May 12th, 2009 by Andrew Vos

Did this last night with a friend of mine.

Our first attempt at stop motion.

Popularity: 6% [?]

Posted in Animation, Comedy, Video having no comments »

Snatch Wars

April 22nd, 2009 by Andrew Vos

Popularity: 6% [?]

Posted in Comedy, Video, YouTube having no comments »

Hitler Videos!

January 27th, 2009 by Andrew Vos

I’ve been relatively quiet for a while, so I thought I’d pop in quick and add a couple funny Hitler videos.

(Try watch them when you’re drunk, or else they might not be funny)

Adolf Hitler - Vista Problems!

http://www.youtube.com/watch?v=ExeyrNZwzwQ

Hitler Hates Valve

http://www.wegame.com/watch/Hitler_Hates_Valve_4/

Hitler- I want to break free

http://www.youtube.com/watch?v=6ax4jvLM9WI&feature=related

Adolf Hitler rap

http://www.youtube.com/watch?v=5k736WZfB6U

Hitler Finds Out He’s A Joke On YouTube

http://www.youtube.com/watch?v=w9mjEF_lEDE

Popularity: 8% [?]

Posted in Alcohol, Comedy, Video having no comments »

HtmlBuilder 0.1.33

January 15th, 2009 by Andrew Vos

HtmlBuilder is simple web design software, and this is it’s first release.

HtmlBuilder uses a simple template system, and includes some example templates under Help/Example Projects.

The HtmlBuilder Main Window

On the left we have the Site browser, which lists all files in the site.

HtmlBuilder Main Window

The Color Chooser Window

Favorite colors can be stored on the right hand side.

HtmlBuilder Color Chooser

Requirements

.NET Framework 3.5

Downloads

Version 0.1.33

Changes

Version 0.1.33 (January 15th 2009)

Added some DTD’s to the Insert/DTD Menu.

Version 0.1.3 (January 14th 2009)

First Release.

Popularity: 9% [?]

Posted in .NET Framework, C#, Code Projects, Coding, Download, Downloads, HtmlBuilder, News, Software, Web Design having no comments »

Getting music from iTunes to your G1

January 9th, 2009 by Andrew Vos

I wanted to export all my music from iTunes to my G1, but I wanted to maintain the folder structure like this:

Artist\Album\TrackName.mp3

Couldn’t find anything on Google so here’s some C# code to get it done. Remember to add a reference to iTunesLib (Add Reference / COM).

   1: private static class ITunesExporter{
   2:   public static void Export(string playlistName, string path) {
   3:     iTunesAppClass iTunes = new iTunesAppClass();
   4:  
   5:     foreach (IITPlaylist playlist in iTunes.LibrarySource.Playlists) {
   6:       if (playlist.Name == playlistName) {
   7:         foreach (IITTrack track in playlist.Tracks) {
   8:           if (track.Kind == ITTrackKind.ITTrackKindFile) {
   9:             IITFileOrCDTrack file = (IITFileOrCDTrack)track;
  10:             string extension = Path.GetExtension(file.Location);
  11:             string newPath = ITunesExporter.createValidFileName(path, file.Artist, file.Album, file.Name, extension);
  12:             string newDirectoryName = Path.GetDirectoryName(newPath);
  13:             Directory.CreateDirectory(newDirectoryName);
  14:             
  15:             if (File.Exists(newPath) == false) {
  16:               File.Copy(file.Location, newPath);
  17:             }
  18:           }
  19:         }
  20:       }
  21:     }
  22:   }
  23:   private static string createValidFileName(string exportPath, string artist, string album, string track, string extension) {
  24:     artist = ITunesExporter.removeInvalidFileNameCharacters(artist);
  25:     album = ITunesExporter.removeInvalidFileNameCharacters(album);
  26:     track = ITunesExporter.removeInvalidFileNameCharacters(track);
  27:  
  28:     string filePath = exportPath;
  29:     filePath = Path.Combine(filePath, artist);
  30:     filePath = Path.Combine(filePath, album);
  31:     filePath = Path.Combine(filePath, track);
  32:     filePath = Path.ChangeExtension(filePath, extension);
  33:     return filePath;
  34:   }
  35:   private static string removeInvalidFileNameCharacters(string str) {
  36:     char[] chars = Path.GetInvalidFileNameChars();
  37:     foreach (char c in chars) {
  38:       str = str.Replace(c.ToString(), null);
  39:     }
  40:     return str;
  41:   }
  42: }

You can use the code like this:

   1: ITunesExporter.Export("Phone", @"D:\Music");

”Phone” is the playlist name and “D:\Music” is the path that the files will be exported to.

If anyone want’s to recode it to use the iTunes XML file please post the code! (I am to lazy).

Popularity: 9% [?]

Posted in .NET Framework, C#, Code Projects, Coding, Mobile, Music, iTunes having no comments »

object.Format Extension

January 7th, 2009 by Andrew Vos

EDIT: I’ve added the string extension found here

I was reading an article on haacked today, called Fun With Named Formats, String Parsing, and Edge Cases and I started thinking what if I made a format extension method for an object which used reflection to get the properties.

The following example:

private static void test() {
  CultureInfo southAfrican = CultureInfo.CreateSpecificCulture("en-ZA");

  var human = new {
    FirstName = "Andrew",
    LastName = "Vos",
    BirthDate = new DateTime(1983, 10, 23),
    MoneyInPocket = 123.34
  };

  string formatted = human.Format(southAfrican,
    "Hello my name is {FirstName}, and my last name is {LastName}.\n" +
    "My birth date is {BirthDate:D}\n" +
    "I have {{MoneyInPocket:C}} in my pocket right now.\n" +
    "Here are some random chars... { { } }{ {} {}{} }{ {} " +
    "\nThis last value fails because there's no corresponding property: {TheLastValue}."
    );
  Console.WriteLine(formatted);
}

 

Would result in the following output:

Hello my name is Andrew, and my last name is Vos.
My birth date is 23 October 1983
I have {R 123.34} in my pocket right now.
Here are some random chars... { { } }{ {} {}{} }{ {}
This last value fails because there's no corresponding property: {TheLastValue}.

 

Here’s the code:

internal static class ObjectFormatter {
  /// <summary>Formats the string by replacing format items with the objects properties.</summary>
  /// <param name="obj">The <see cref="T:System.Object"></see> to format.</param>
  /// <param name="format">A <see cref="T:System.String"></see> containing the format items.</param>
  /// <returns>A copy of format where the format items have been replace by the corresponding properties.</returns>
  /// <exception cref="T:System.ArgumentNullException">format or obj is null.</exception>
  internal static string Format(this object obj, string format) {
    return ObjectFormatter.Format(obj, null, format);
  }

  /// <summary>Formats the string by replacing format items with the objects properties.</summary>
  /// <param name="obj">The <see cref="T:System.Object"></see> to format.</param>
  /// <param name="provider">An <see cref="T:System.IFormatProvider"></see> that supplies culture-specific formatting information.</param>
  /// <param name="format">A <see cref="T:System.String"></see> containing the format items.</param>
  /// <returns>A copy of format where the format items have been replace by the corresponding properties.</returns>
  /// <exception cref="T:System.ArgumentNullException">format or obj is null.</exception>
  internal static string Format(this object obj, IFormatProvider provider, string format) {
    if (format == null) throw new ArgumentNullException("format");
    if (obj == null) throw new ArgumentNullException("obj");

    const string propertyPattern = @"\{(?<PropertyName>[a-z,0-9,_]+)\:?(?<PropertyFormat>[^}]+)?\}";
    MatchCollection matches = Regex.Matches(format, propertyPattern,
      RegexOptions.Compiled |
      RegexOptions.CultureInvariant |
      RegexOptions.IgnoreCase);

    foreach (Match match in matches) {
      string propertyName = match.Groups["PropertyName"].Value;
      string propertyFormat = match.Groups["PropertyFormat"].Value;
      PropertyInfo propertyInfo = obj.GetType().GetProperty(propertyName);

      if (propertyInfo != null) {
        object propertyValue = propertyInfo.GetValue(obj, null);
        string propertyString = null;

        if (propertyValue != null) {
          propertyString = string.Format(provider, "{0:" + propertyFormat + "}", propertyValue);
        }
        format = format.Replace(match.Value, propertyString);
      }
    }

    return format;
  }
}
internal static class StringObjectInjector {
  /// <summary>Formats the string by replacing format items with the objects properties.</summary>
  /// <param name="format">A <see cref="T:System.String"></see> containing the format items.</param>
  /// <param name="obj">The <see cref="T:System.Object"></see> to format.</param>
  /// <returns>A copy of format where the format items have been replace by the corresponding properties.</returns>
  /// <exception cref="T:System.ArgumentNullException">format or obj is null.</exception>
  internal static string Inject(this string format, object obj) {
    return obj.Format(format);
  }

  /// <summary>Formats the string by replacing format items with the objects properties.</summary>
  /// <param name="format">A <see cref="T:System.String"></see> containing the format items.</param>
  /// <param name="provider">An <see cref="T:System.IFormatProvider"></see> that supplies culture-specific formatting information.</param>
  /// <param name="obj">The <see cref="T:System.Object"></see> to format.</param>
  /// <returns>A copy of format where the format items have been replace by the corresponding properties.</returns>
  /// <exception cref="T:System.ArgumentNullException">format or obj is null.</exception>
  internal static string Inject(this string format, IFormatProvider provider, object obj) {
    return obj.Format(provider, format);
  }
}

Popularity: 10% [?]

Posted in .NET Framework, C#, Code Projects, Coding having 2 comments »