Skip to main content

Posts

One more tool to convert MS Word text into clean HTML

Windows Live Writer is one of the best tools out there to convert MS Office Word formatted text into simple and clean HTML. To use it, just copy from a Word document and paste into Writer. Writer will covert the text to HTML without the obscure tags, FONTs and CSS styles that you would get if you were saving as HTML from Word. You can download it for free at http://download.live.com/writer .

Ruby and C# code to upload a file to a server that uses FrontPage extensions

I ran into a challenge last week. I had to write a script or program that creates an RSS file and upload it to a IIS server. The program would be be scheduled to run every so often. The IIS server did not supported DAV, but it supported Front Page Extensions 2002. I looked everywhere in the web for sample code on how to upload files to such servers. I found out that MS Internet Publishing is the technology used by Front Page Extensions. I also found out that there was an OLE provider for it and that I could connect to it using classic ADO 2.5. I tried the example provided in Microsoft site, but the code crashed when the ADODB.Stream object opened the stream from the record. The error said something about “Interface not supported” and “InvalidCast”. My old ASP 3.0 book has a sample of writing directly to the ADODB.Stream, so I tried that and it worked but it kept prompting a dialog asking for the username and password even though I had passed those in the Stream’s open method. To ...

FTP not working in a Linux virtual machine hosted in Windows

I have a Linux virtual machine that serves as an FTP server. My problem was that the computers in the network were able to connect to its FTP service only if the computer was part of the Windows Domain. I could not figure out what was going on, since those machines could PING but not FTP the Linux server. After some troubleshooting, I found out that I had enabled the Windows Firewall for the VMware connections and therefore firewalling the traffic to the Virtual Machines hosted in the Windows computer. To solve the problem I cleared the check boxes for the firewall for the VM connections like this:

How to add a MS SQL server 2005 database connection in Netbeans

In Netbeans IDE, I was trying to add a Database connection to a MS SQL server 2005 database. After entering the correct parameters and locating the right jdbc driver (sqljdbc.jar), I was able to connect; however none of the tables showed up. After reading this , I decided to set the value of the schema property to dbo and it worked! To change the value of the schema property in your Netbeans's database connection, do the following: Right click on the connection Click on Disconnect Right click again on the connection Click properties Change the value of the Schema property

How to fix "incompatible schema version" error when deploying ASP.net application into a shared webhost

I was having the following error in my MS MVC application hosted in Mocha webhost : The 'System.Web.Security.SqlMembershipProvider' requires a database schema compatible with schema version '1'. However, the current database schema is not compatible with this version. You may need to either install a compatible schema with aspnet_regsql.exe (available in the framework installation directory), or upgrade the provider to a newer version. My Problem was that even tho I already had created the database that contains the schema generated by aspnet_regsql.exe and I already edited my web.config to point the provider string to that database, the data was not there in the new database. To fix the problem I copied and pasted (using Management Studio) the data from the following tables from my working SQL Express 2008 development database to my production database at Mocha: SchemaVersions (the most important one to fix the "wrong schema" version) Applications Us...

Rails-like Unit Testing in MS MVC

While following the Professional ASP.NET MVC 1.0 sample chapter's section about Unit Testing, I decided to use NUnit because I do not have Visual Studio Professional. Because there is no wizard to create a Unit Test project in Visual Developer Express, I downloaded a NUnit MVC testing template and use it as my base project to complete the tutorial. The following are some different approaches I had to make in order to follow the tutorial: Instead of using [TestMethod] I used [Test], which what NUnit uses to mark test methods. I used the NUnit's GUI to perform the unit tests instead of using Visual Studio's since the Express version does not come with support for testing. The tutorial in the chapter shows you how to create a fake repository so that your unit tests do not use the database. Because I come from a Rails background where you actually have (or supposed to have) a separated database for testing, I decided to just copy the database and use the new copy for testing...

DrySQL for the Microsoft MVC .NET framework

The sample Chapter 1 from Professional ASP.NET MVC 1.0 ( http://aspnetmvcbook.s3.amazonaws.com/aspnetmvc-nerdinner_v1.pdf ) is a great tutorial that guides you through the features of Microsoft's MVC framework . If you have used Rails before, when you read the tutorial you keep telling to yourself "wow, this is like rails but compiled and with excellent Intellisense and a nice and fast database backend". That's right, SQL Server is tightly coupled to the Linq to SQL framework that you can use as the ORM for the MS MVC (please note that the use of Linq to SQL is optional; and you could use other ORM frameworks). Just because is tightly coupled does not mean that is a bad idea; it actually integrates really well with the visual tools from Visual Studio. Here is a screen shot showing a basic overview of the database ORM mapping tool in MS Vistual Web Developer Express (which is free, like all the technologies described here, including the SQL server 2008 Express editio...

Method for communication between drivers on the road

Have you ever wanted to warn somebody in front of you that there is a cop behind or that one of their tires is flat? Sometimes I see car that are smoking from behind and I want to warn the people inside the car; but how do I do that? do I just honk like crazy until they hear me? I would like to propose simple method for driver-to-driver communication using the high lights of your car: One dot (.) means flash your lights for a short time, about a second. A dash (-) means flashing them for about 4 seconds. ... : use it to alert the car in front of you that a high priority vehicle like a police car or an ambulance is behind trying to move around the traffic. -.- : use it to alert the car in front of you that something is wrong with their car (like a flat tire) and they should stop to check it. --. : use it to alert the car in front that one of the doors is open. I want also to mention that learning Morse code is good idea so that can you can communicate with your eye lids i...

How to solve Named Pipes error 40 when connecting to local MS SQL Server instances

I was getting the following error when trying to add my local MS SQL server 2008 Express database to the data connections in Visual Web Developer 2008 Express : Named Pipes Provider, error: 40 - Could not open a connection to SQL Server The problem was that I was using just (local) in the server name field. To solve the problem, I had to add the instance name (sqlexpress) like this: (local)\sqlexpress When I entered that into the server name field, everything worked perfectly.

How to make a very inexpensive, dynamic website

Some of my customers in my freelance jobs require me to create for them a an easy-to-maintain website with some dynamic content. Normally I would help them set up a CMS like Joomla or Drupal, but some of the customers have a cheap, shared, web hosted accounts which do not run those CMS at optimal speed. For those customers, I usually implement the following to give them a website running at fast speed: Most of their website is statically generated by a custom offline CMS that I created. The offline CMS is an easy to use rails app that runs on my computer and uses webgen to generate clean HTML and then uploads the generated HTML to the shared account. That way is easy for me or for my customers to make changes to the website. For storing data from the visitors and other small dynamic services, I use the free Google App Engine . By using Google App Engine, my customers have access to Google's vast resources without paying a penny. Furthermore, I know for sure that those custome...

The system cannot find the path specified when executing jruby

If you get "The system cannot find the path specified" when trying to run jruby in Windows, you need to add JRUBY_HOME and JAVA_HOME to your environment variables. JRUBY_HOME and JAVA_HOME both need to point to the root folder of jruby and Java JDK, e.g.: C:\jruby-1.1.6\ and C:\Program Files\Java\jdk1.6.0_11. You need to also add %JAVA_HOME%\bin and %JRUBY_HOME% \bin to your PATH variable. You can manage your environment variables by doing the following under Windows XP: Right click on My Computer Click Properties Click the Advance tab Click on Environment Variables

Rails migration for acts_as_authenticated plugin

The following shows a typical Rails migration for creating the users, roles and role_users table for the acts_as_authenticated plugin. Note that an initial admin user with a default password is added: class CreateRolesAndUsers true do |t| t.column :login, :string t.column :email, :string t.column :crypted_password, :string, :limit => 40 t.column :salt, :string, :limit => 40 t.column :created_at, :datetime t.column :updated_at, :datetime t.column :remember_token, :string t.column :remember_token_expires_at, :datetime end create_table :roles, :force => true do |t| t.column :name, :string, :limit => 40 t.column :authorizable_type, :string, :limit => 30 #t.column :authorizable_id, :integer t.column :created_at, :datetime t.column :updated_at, :datetime en...

Systems Management: A time saver

Systems Management in Rails is a rails application for keeping track of computer inventory and also allows the user to execute remote ssh commands, wake on LAN, vnc and remote desktop on them. I developed it to help distribute software to all the machines at my work in a easy way. It uses the OpenAudit database (populated of course by the OpenAudit scripts) with some added changes such a new column in the systems table for type of password and a new table to keep the ssh commands history. Software distribution is done this way: User specify which file to send to which machines and the command to be run when the upload is successful The file is uploaded using sftp The command is executed using SSH. Systems Management also allows the user to access a computer via VNC or RDP by just clicking on a link. You can download it from http://rubyforge.org/projects/managesystems/

Script to generate an RSS feed from RenWeb's announcements

The following ruby (jruby) and sql code will get the Announcements from RenWeb and create an RSS feed file from them. The scripts needs the JDBC ActiveRecord gem. If you have any questions on how to run this script, please write a comment below. Both files are released under the MIT license . main.rb: require 'rss/maker' require 'cgi' require 'rubygems' gem 'activerecord-jdbc-adapter' require 'jdbc_adapter' class AnnouncementsDistrict :jdbc, :username => "YOUR ODBC USERNAME", :password => "YOUR ODBC PASSWORD", :driver => "com.microsoft.sqlserver.jdbc.SQLServerDriver", :url => "jdbc:sqlserver://THE URL TO CONNECT;DatabaseName=YOUR DATABASE NAME") set_table_name("AnnouncementsDistrict") #Gets an sql query from a file def self.get_sql_query_from_file(filename, params_hash_for_sql_query = nil) fi = File.open(filename) sql_query = fi.read if pa...

How to create a yahoo datatable in rails

To create a Yahoo Ajax Datatable (with local datasource) from a rails view, I had to do the following. First I had to add this helper method to the Application controller: module ApplicationHelper #Outputs the javascript code necesary to create a yahoo datable # from a plain datasource # column_array: and array of 2-item arrays in the form: # ["name_wihout_spaces", "Text to show in the column header"] # data_rows: an array or rows. Each row is an array that has the values in the # order specified in the column_array. def to_yahoo_array_data_source(column_array, data_rows, custom_div_id = "myContainer", custom_col_var_name = "data_cols", custom_datasource_var_name = "data_source") column_items = [] column_array.each do |column| column_items Next I added the required javascript libraries to the application layout: <html> <head> <title>Email De...

Strange behavior with the up,left,space bar key combo

I was checking if the up and left arrow and the space bar was pressed in my game code to allow the player to move and turn and shoot at the same time. Turns out that in GameMaker 7, if the user holds up+left+space bar keys at the same time, either the up or the left arrow key event will be ignored. I had to change the shoot key to the key to go around this weird behavior.

Math game for Areas and Volumes

I just uploaded an educational game to YoYoGames called Math Areas and Volumes . The game was made using GameMaker and the original purpose for it was to help my eight grade student to improve their skills of finding the area and volume of objects. If you have ever taught children about areas and volumes, you probably will notice that some of them confused the two concepts. The game uses plain graphics to help students distinguish the difference between the area and volume concepts. A 2D square with little squares filling it, represent a square unit. A 3D cube with little cubes on it represents the cubic units. You would need to play it to completely get the idea of what I was trying to do to help the students. Something else worth noting is that I used some of the excellent graphics that came with my Multimedia Fusion. I already asked in the forum, and the official response was that I could use the graphics as long as distributed the game only as an “.exe”. Thank you Clickteam!

Warbler uses gem files from cache folder instead of gems folder

I was having the following error when running warbler war on my rails application folder: Cannot load gem at [/home/juanito/jruby-1.1.4/lib/ruby/gems/1.8/cache/activerecord-jdbc-adapter-0.8.2.gem] in /home/juanito/bulletonrails/svn_copy/bullet_gui /home/juanito/jruby-1.1.4/lib/ruby/site_ruby/1.8/rubygems/format.rb:41:in `from_file_by_path' I looked around the gems/1.8/cache folder and sure enough, the gem file for activerecord-jdbc-adapter was missing. I had deleted that file and other gem files from that folder a while ago because I thought I would not need them and they was taking space. Well, it turns out that Warbler uses the gem files from the rubygem's cache folder to unpack the gems into the WEB-INF folder. As a consequence, by basically using the original gem files, it bypasses any modification you make to your local gems. So if your newly deployed jruby WAR application is missing custom behavior that you added to your local gems, you may want to convert the gem...