<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3.3" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>Sw33tCode</title>
	<link>http://www.sw33tcode.com</link>
	<description>Smart code for developers</description>
	<pubDate>Mon, 14 Apr 2008 02:47:17 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
	<language>en</language>
			<item>
		<title>Installing Ruby on Rails with Lovdbyless on a Windows machine</title>
		<link>http://www.sw33tcode.com/?p=5</link>
		<comments>http://www.sw33tcode.com/?p=5#comments</comments>
		<pubDate>Mon, 14 Apr 2008 02:46:12 +0000</pubDate>
		<dc:creator>Thomas Wheeler</dc:creator>
		
		<category><![CDATA[Mysql]]></category>

		<category><![CDATA[Ruby]]></category>

		<category><![CDATA[Ruby On Rails]]></category>

		<guid isPermaLink="false">http://www.sw33tcode.com/?p=5</guid>
		<description><![CDATA[I know a lot of people who use ruby are either doing their development on linux machines or macs, but for those people who are brave&#8230;.. here is a guide for you setting up LovdByLess with Ruby on Rails on Windows machine.  The machine I used is Windows XP.
LovdByLess is built with Ruby on [...]]]></description>
			<content:encoded><![CDATA[<p>I know a lot of people who use ruby are either doing their development on linux machines or macs, but for those people who are brave&#8230;.. here is a guide for you setting up LovdByLess with Ruby on Rails on Windows machine.  The machine I used is Windows XP.</p>
<p><a href="http://lovdbyless.com/" target="_blank">LovdByLess</a> is built with Ruby on Rails and is a social networking solution that has everything you need to build your community.<br />
The folowing installation of Ruby and Ruby on Rails was created with guidance from the <a href="http://rubyonrails.org/down" target="_blank">RubyOnRails.org</a> documentation which can be found here.</p>
<p><strong>Install Ruby compiler</strong><br />
For Windows I used the One-Click Installer - Windows found here: <a href="https://rubyforge.org/frs/?group_id=167&amp;release_id=17128" target="_blank">rubyforge.org</a>(Which for me at the time of this post was version ruby186-26)</p>
<p>I like to be able to run ruby from where ever I am in the command prompt so in order to do that just add this line (if not there already) to your Path variable in the System Variables:<br />
<code>c:\ruby\bin;</code></p>
<p><strong>Setup RubyGems and Rails on Ruby</strong><br />
Download from here <a href="http://rubyforge.org/frs/?group_id=126" target="_blank">rubyforge.org</a> the latest release of Ruby gems.  I used the zip version 1.1.0 for this installation.  Extract the zip file to where ever you want.   Open a console (cmd.exe) window and proceed to where you extracted the rubygems 1.1.0.  Run this command:<br />
<code>c:\[rubygems 1.1.0 Path]\ ruby setup.rb</code></p>
<p>Now we want to setup Rails.  Just type this in the command prompt:<br />
<code>gem install rails --include-dependencies</code></p>
<p>Download and extract the zip file from <a href="http://lovdbyless.com/download.html" title="LovdByLess" target="_blank">LOVDbyLESS</a>.</p>
<p>We have to install the following gems using the RubyGems program we just installed.  From the command prompt, run the following:<br />
<code>c:\gem install youtube-g<br />
c:\gem install rflickr<br />
c:\gem install uuidtools<br />
c:\gem install colored<br />
c:\gem install hpricot<br />
c:\gem install mocha<br />
c:\gem install redgreen<br />
c:\gem install RedCloth<br />
c:\gem install acts_as_ferret<br />
c:\gem install ferret<br />
c:\gem install win32console<br />
c:\gem install avatar<br />
c:\gem install tzinfo<br />
c:\gem install rails</code></p>
<p><em>****If you get asked during these gem installations to Install hoe, rubyforge, Rake, mime-types, xml-simple, etc just type Yes for these.****</em></p>
<p>Get rmagick gem <a href="http://www.ruby-forum.com/topic/139539#620258" title="ruby-forum.com">here</a>, download and extract.   Execute:<br />
<code>ImageMagick-6.3.7-8-Q8-windows-dll.exe</code><br />
In the console change directory to where you extracted the gem.<br />
<code>gem install rmagick-2.0.0-x86-mswin32</code><br />
This will require a reboot of your machine at some point before you try to use this gem.  (Trust me.  this took me a long time to figure out!)</p>
<p>We need to create a mysql user account to run the LovdByLess database with.  This assumes you have Mysql running on your machine.    From the command prompt type and hit enter:<br />
<code>mysql --user=root mysql -p</code><br />
Enter your password.  Create mysql user:<br />
<code>GRANT ALL PRIVILEGES ON *.* TO 'lovdbyless'@'%'<br />
IDENTIFIED BY 'my_password' WITH GRANT OPTION;</code><br />
Then exit mysql:<br />
<code>quit mysql</code></p>
<p>Go to the directory where you extracted LovdByLess and open the config folder.   Copy database.yml.tmp to database.yml.   Edit this file and replace the values for username and password with the mysql user you created above.</p>
<p>From the command prompt, proceed to your LovdByLess directory, run the following:<br />
<code>rake db:create:all<br />
rake db:migrate a=no<br />
rake</code></p>
<p>The last command should run all ruby tests for the project.   Now run this from your lovdbyless folder in the command console:<br />
<code>ruby script\server</code><br />
The rails server is now up and running.   Open up a web browser and go to this address:<br />
<code>http://localhost:3000/</code></p>
<p>Please let me know if you had any issues setting this up.  Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sw33tcode.com/?feed=rss2&amp;p=5</wfw:commentRss>
		</item>
		<item>
		<title>Building Mysql Database contents from batch script in Windows</title>
		<link>http://www.sw33tcode.com/?p=3</link>
		<comments>http://www.sw33tcode.com/?p=3#comments</comments>
		<pubDate>Sun, 06 Apr 2008 04:22:29 +0000</pubDate>
		<dc:creator>Thomas Wheeler</dc:creator>
		
		<category><![CDATA[Mysql]]></category>

		<category><![CDATA[Windows Batch Script]]></category>

		<category><![CDATA[.bat]]></category>

		<category><![CDATA[cmd]]></category>

		<guid isPermaLink="false">http://www.sw33tcode.com/?p=3</guid>
		<description><![CDATA[I needed a way to build my database quickly on a project I was working on and I was constantly making changes to the database that supplied content to my application.  So I came up with an easy batch script that would help facilitate the changes in my database environment.
Here is a mocked version [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal">I needed a way to build my database quickly on a project I was working on and I was constantly making changes to the database that supplied content to my application.<span>  </span>So I came up with an easy batch script that would help facilitate the changes in my database environment.</p>
<p class="MsoNormal">Here is a mocked version of the batch script that I wrote to build the database:</p>

<div class="wp_codebox"><table width="100%" ><tr id="35"><td class="code" id="3code5"><pre class="winbatch">@echo <span style="color: #0080FF; font-weight: bold;">off</span>
&nbsp;
REM<span style="color: #FF1010; font-weight: bold;">: Command File Created To Create MySQL Experiments Database</span>
REM<span style="color: #FF1010; font-weight: bold;">: Date Generated: 4/5/2008</span>
REM<span style="color: #FF1010; font-weight: bold;">: Usage: CommandFilename [Host] [Username] [Password]if '%1' == '' goto usage</span>
&nbsp;
<span style="color: #800080;">if</span> <span style="color: #ff0000;">'%2'</span> == <span style="color: #ff0000;">''</span> <span style="color: #800080;">goto</span> usage
<span style="color: #800080;">if</span> <span style="color: #ff0000;">'%3'</span> == <span style="color: #ff0000;">''</span> <span style="color: #800080;">goto</span> usage
<span style="color: #800080;">if</span> <span style="color: #ff0000;">'%1'</span> == <span style="color: #ff0000;">'/?'</span> <span style="color: #800080;">goto</span> usage
<span style="color: #800080;">if</span> <span style="color: #ff0000;">'%1'</span> == <span style="color: #ff0000;">'-?'</span> <span style="color: #800080;">goto</span> usage
<span style="color: #800080;">if</span> <span style="color: #ff0000;">'%1'</span> == <span style="color: #ff0000;">'?'</span> <span style="color: #800080;">goto</span> usage
<span style="color: #800080;">if</span> <span style="color: #ff0000;">'%1'</span> == <span style="color: #ff0000;">'/help'</span> <span style="color: #800080;">goto</span> usage
&nbsp;
echo experiments.build.database START
mysql -h %<span style="color: #cc66cc;">1</span> -u %<span style="color: #cc66cc;">2</span> -p%<span style="color: #cc66cc;">3</span> &amp;gt<span style="color: #008000; font-style: italic;">; &quot;experiments.build.database.sql&quot;</span>
<span style="color: #800080;">if</span> %ERRORLEVEL% NEQ <span style="color: #cc66cc;">0</span> <span style="color: #800080;">goto</span> errors
echo experiments.build.database <span style="color: #800080;">END</span>
&nbsp;
echo experiments.build.tables START
mysql -h %<span style="color: #cc66cc;">1</span> -u %<span style="color: #cc66cc;">2</span> -p%<span style="color: #cc66cc;">3</span> <span style="color: #ff0000;">&quot;experiments&quot;</span> &amp;gt<span style="color: #008000; font-style: italic;">; &quot;experiments.build.tables.sql&quot;</span>
<span style="color: #800080;">if</span> %ERRORLEVEL% NEQ <span style="color: #cc66cc;">0</span> <span style="color: #800080;">goto</span> errors
echo experiments.build.tables <span style="color: #800080;">END</span>
&nbsp;
echo building stored procedures START
mysql -h %<span style="color: #cc66cc;">1</span> -u %<span style="color: #cc66cc;">2</span> -p%<span style="color: #cc66cc;">3</span> <span style="color: #ff0000;">&quot;experiments&quot;</span> &amp;gt<span style="color: #008000; font-style: italic;">; &quot;sprocs\uspAddUser.sql&quot;</span>
<span style="color: #800080;">if</span> %ERRORLEVEL% NEQ <span style="color: #cc66cc;">0</span> <span style="color: #800080;">goto</span> errors
echo uspAddUser
echo building stored procedures <span style="color: #800080;">END</span>
&nbsp;
echo experiments.insertdata.messenger START
mysql -h %<span style="color: #cc66cc;">1</span> -u %<span style="color: #cc66cc;">2</span> -p%<span style="color: #cc66cc;">3</span> <span style="color: #ff0000;">&quot;experiments&quot;</span> &amp;gt<span style="color: #008000; font-style: italic;">; &quot;experiments.insertdata.sql&quot;</span>
<span style="color: #800080;">if</span> %ERRORLEVEL% NEQ <span style="color: #cc66cc;">0</span> <span style="color: #800080;">goto</span> errors
echo experiments.insertdata.messenger <span style="color: #800080;">END</span>
&nbsp;
echo Finished Building Database 
&nbsp;
<span style="color: #800080;">goto</span> finish
REM<span style="color: #FF1010; font-weight: bold;">: How to use screen</span>
&nbsp;
<span style="color: #FF1010; font-weight: bold;">:usage</span>
echo.
echo Usage<span style="color: #FF1010; font-weight: bold;">:    MyScript Server Database</span>
echo Host<span style="color: #FF1010; font-weight: bold;">:     MySQL Server</span>
echo Database<span style="color: #FF1010; font-weight: bold;">: the name of the target database</span>
echo Username<span style="color: #FF1010; font-weight: bold;">: username to be used on target database</span>
echo Password<span style="color: #FF1010; font-weight: bold;">: password to be used on target database</span>
echo.
echo Example<span style="color: #FF1010; font-weight: bold;">: BuildDatabase.cmd &quot;localhost&quot; &quot;root&quot; &quot;password&quot;</span>
echo.
echo.
<span style="color: #800080;">goto</span> done
&nbsp;
REM<span style="color: #FF1010; font-weight: bold;">: error handler</span>
<span style="color: #FF1010; font-weight: bold;">:errors</span>
echo.
echo WARNING! Error<span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">&#41;</span> were detected!
echo --------------------------------
echo Please evaluate the situation and, <span style="color: #800080;">if</span> needed,
echo restart this command file. You may need <span style="color: #800080;">to</span>
echo supply command parameters when executing
echo this command file.
echo.
<span style="color: #0000FF;">pause</span>
<span style="color: #800080;">goto</span> done
&nbsp;
REM<span style="color: #FF1010; font-weight: bold;">: finished execution</span>
<span style="color: #FF1010; font-weight: bold;">:finish</span>
echo.
echo Script execution is complete!
&nbsp;
<span style="color: #FF1010; font-weight: bold;">:done</span>
@echo <span style="color: #0080FF; font-weight: bold;">on</span></pre></td></tr></table></div>

<p class="MsoNormal">This script will call the sql files that contain the commands to build the database, tables, stored procedures, and even create some test data.  To call this command file all you have to do is supply the host, username, and password parameters.   Like this:</p>

<div class="wp_codebox"><table width="100%" ><tr id="36"><td class="code" id="3code6"><pre class="dos">c:\BuildDatabase.cmd &quot;localhost&quot; &quot;root&quot; &quot;password&quot;</pre></td></tr></table></div>

<p class="MsoNormal">This script example will call your database: experiments.  But if you wanted to dynamically name your database you can just add another parameter onto your batch script and replace all the mysql calls above with this code:</p>

<div class="wp_codebox"><table width="100%" ><tr id="37"><td class="code" id="3code7"><pre class="dos">mysql -h %<span style="color: #448888;"><span style="">1</span></span> -u %<span style="color: #448888;"><span style="">2</span></span> -p%<span style="color: #448888;"><span style="">3</span></span> %<span style="color: #448888;"><span style="">4</span></span>  &amp;gt; &quot;sql_code.sql&quot;</pre></td></tr></table></div>

<p class="MsoNormal">Then your call to the command file will be like this:</p>

<div class="wp_codebox"><table width="100%" ><tr id="38"><td class="code" id="3code8"><pre class="dos">c:\BuildDatabase.cmd &quot;localhost&quot; &quot;root&quot; &quot;password&quot; &quot;database_name&quot;</pre></td></tr></table></div>

<p class="MsoNormal">If you wish to try out the code in action please download the zip file below.  You will need MySql Version 5 or above to test this.   Please let me know if you have any questions.</p>
<p><a href="http://www.sw33tcode.com/wp-content/uploads/2008/04/experimentsmysqlbatchscript.zip" title="Sample Mysql Batch Script">Sample Mysql Batch Script</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sw33tcode.com/?feed=rss2&amp;p=3</wfw:commentRss>
		</item>
	</channel>
</rss>
