Stripping non-numeric characters from a string in C#

Posted: May 13th, 2011 | Author: | Tags: , , , | No Comments »

 

string output = Regex.Replace("String 2 Parse 4 Non Numerics", "[^0-9]", string.Empty)

In this case the variable “output” will hold the value “24″


Backing up MySql Database

Posted: April 19th, 2011 | Author: | Tags: | No Comments »

Lest we forget that the tools we need for this are right under our nose…

mysqldump -u root --password=xxxxxxx! -h 127.0.0.1 -P 3306 -r c:\myTable.sql myTable

You can usually find mysqldump in the following path for most Windows installs…

C:\Program Files (x86)\MySQL\MySQL Workbench 5.2 CE\

Octalforty WizardBy for .net Data/Schema Migrations

Posted: April 18th, 2011 | Author: | No Comments »

I have been using octal-forty wizardby on some prejects recently with great success. Attached is a build I compiled that I like to use. Includes some fixes for the MSBuild targets.

[CLICK TO HERE DOWNLOAD THE BUILD]


What’s a guy gotta do to get a decent SqlServer DB Schema Print-out?

Posted: December 2nd, 2010 | Author: | No Comments »

Database diagrams are nice and all. But I went to print one out for a client and ended up with an 11 page by 11 page monstrosity of a PDF. All I really want is to let my client know what the tables are and what columns each table has.

After looking into my options I decided that a simple printout of a SQL Query would do the trick. Here’s my query for printing out a DB schema in SqlServer…

SELECT TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, DATA_TYPE, IS_NULLABLE, CHARACTER_MAXIMUM_LENGTH AS MAX_LENGTH
FROM INFORMATION_SCHEMA.COLUMNS
ORDER BY TABLE_SCHEMA, TABLE_NAME, ORDINAL_POSITION

UPDATE 10/26/2010

Thanks to Scott Reid for the following tip for saving a clean printable and viewable PNG of a Database Diagram in SQL Management Studio…

“The best method that I’ve found is to open the database diagram in SSMS and set the zoom to 100%. (Well, make sure that all of the tables that you want on the ERD are there, first.) Once the zoom is at 100%, scroll around the diagram and make sure that all of the tables are formatted so that all of the columns are visible and that the whole name is visible. Once you’re satisfied, right-click on the diagram and copy to clipboard. Open up Paint and paste. The resulting image will be too big to fit on your screen. But you can save it as a .png file, Then open the .png file in your favorite image viewer and zoom in and out nicely.”

Thanks Scott!


Fast & Efficient Development Environment + Remote Build Server on the Cheap

Posted: October 19th, 2010 | Author: | Tags: , , | No Comments »

I’ve recently started working on some mobile web development ideas and decided it would be easiest for testing to have a continuously integrated public development site which I can hit directly from my Android smartphone for testing without the hassle of an emulator. The chrome-to-phone browser/device extensions out there make switching back and forth between testing locally in full-scale chrome as well as on my device a breeze.

Plan established, the only real unsolved angle of this for me was finding a way to get a public copy of my source online that would be updated instantly when I commit to my repository. I have been using Dreamhost for some time because of their awesome rates and unlimited SVN hosting that comes with my web-hosting package. As I have now discovered, setting up post-commit scripts on Dreamhost’s servers to perform CI tasks is not very difficult and can really maximize productivity once established.

Installed on my local dev environemnt

  • OSX
  • MacVim
  • Chrome
    • use chrome-to-phone plugin for easy android based testing
    • or for iphone try http://tomlerendu.com/chrometoiphone/
  • SCPlugin
    • Pretty basic but free SVN client for mac
  • EasyFind
    • One shortfall of VIM is the lack of global project searches. This great little app takes care of that quite well.

Remote hosting, source control & build server

  • Dreamhost is the way to go
    • unlimited SVN hosting
    • unlimited domains and subdomains
    • SSH access

Setting up continuous integration w/ Dreamhost

  1. create your SVN repository from the http://panel.dreamhost.com admin site.
    • usually somthing like… svn.mydomain.com
  2. create a domain or subdomain on which to host the dev version of your web project
    • usually somthing like… dev.mydomain.com
  3. checkout the trunk of your svn repo locally on your mac using SCPlugin
  4. ssh into your dreamhost account via mac terminal
  5. checkout the trunk of your svn repository into you new dev project sub-domain
    cd /home/dreamhost_user/dev.mydomain.com
    svn co --username your_svn_user --password your_svn_pass http://svn.mydomain.com/trunk ./
  6. create a cgi-bin folder under your new CI dev domain
    mkdir /home/dreamhost_user/dev.mydomain.com/cgi-bin
  7. add the following .htaccess file to your new cgi-bin
    AuthName "Dialog prompt"
    AuthType Basic
    AuthUserFile /home/dreamhost_user/dev.mydomain.com/cgi-bin/.htpasswd
    Require valid-user
  8. create a htpasswd file
    cd /home/dreamhost_user/dev.mydomain.com/cgi-bin
    htpasswd -bc .htpasswd username password
  9. add the following file called “do_update.cgi” to your cgi-bin folder
    note: this is where all your other fun CI stuff can go. For example maybe you want to rake db:migrate if you are working in rails. In this example we’re simply doing an svn update.

    #!/bin/sh
    set -f
    echo "Content-type: text/plain; charset=iso-8859-1"
    echo
    svn update /home/dreamhost_user/dev.mydomain.com
  10. set permissions on your shiny new cgi-bin setup
    chmod 755 -R /home/dreamhost_user/dev.mydomain.com/cgi-bin
  11. create a file called “post-commit” at the location /home/dreamhost_user/svn/repo_id/hooks/post-commit
  12. add the folowing to the “post-commit” file
    note: you’ll be using the username and password you setup in step # 8

    #!/bin/sh
    wget --http-user=user --http-passwd=pass -qO - http://dev.mydomain.com/cgi-bin/do_update.cgi
  13. make post-commit file executable
    chmod 755 post-commit