Skip to main content

Posts

Showing posts from 2009

How to enter multiple users into ActiveDirectory 2008 from a CSV

To create multiple users into ActiveDirectory 2008 Server from one single CSV file containing the users login information, you can use the following wsf file: 1: <job id= "main" > 2:   3: <script language= "VBScript" > 4: dim text_out 5: text_out = "" 6: Dim oContainer 'Parent container of new user 7: Dim oUser 'Created user 8: 'Get parentcontainer 9: Set oContainer=GetObject( "LDAP://OU=yourouname, DC=your,DC=domain,DC=local" ) 10: 'Read the file with user information 11: Const ForReading = 1 12: Set objFSO = CreateObject( "Scripting.FileSystemObject" ) 13: Set objTextFile = objFSO.OpenTextFile _ 14: ( "users.txt" , ForReading) 15: D...

How to do control breaks in Excel

One of the problems I find when exporting from RenWeb is that the names of the staff are repeated in every row when exporting to Excel. To make control breaks on the staff name (i.e. show the name only once) in excel you can use the following formula: =IF(B1=B2,"",B2) Change the B to the column that contains the names. The formula will set the cell blank if the contents of the current row in the B column is the same as the one in the previous row.

Windows.Forms’ DialogResult does not have OK as a member

I found this code to show up a “file browse” dialog from C#: OpenFileDialog ofd = new OpenFileDialog(); DialogResult b = ofd.ShowDialog(); if (b == DialogResult.OK) { CopySourceFiles.Text = ofd.FileName; } The problem was that it was giving an error saying that DialogResult did not have a member named OK . So I had to fully qualify DialogResult as the following snippet shows: OpenFileDialog ofd = new OpenFileDialog(); System.Windows.Forms.DialogResult b = ofd.ShowDialog(); if (b == System.Windows.Forms.DialogResult.OK) { CopySourceFiles.Text = ofd.FileName; }

How to make Batch files run in Windows 2008 scheduled tasks

I was getting a 0x1 error every time Windows Server 2008 ran my task. I had programmed the task to run a bat file that would run a jruby script. The messages in the log did not help me at all, so I took a look at my script’s log. The log showed that the script was not being run at all. To fix this problem I had to make sure to enter the folder that contains the script in the start in field when configuring the scheduled task. So even it says it’s optional, make sure you enter a correct value in that field or else, the task will run with windows\system32 as the current working directory.

Problems changing the SSL port number on Tomcat in Windows

I tried changing the SSL port number on my Tomcat server in my Windows Server 2008 machine and I kept getting the following error when going to the https version of my webapp: Socket bind failed: [730048] Only one usage of each socket address (protocol/network address/port) is normally permitted. To solve the problem I did the following: Re-installed apache using the Windows service installer and specifying the JDK’s JRE as the JRE to use. Set the keystoreFile attribute in the SSL connector tag in the server.xml file to a relative path. The path is based in Tomcat’s installation folder, so if you intalled it in c:\apache and specify ./mykey.bin in the  keystoreFile attribute, Tomcat will try to find the c:\apache\mykey.bin file.

How to split a full name in Excel

RenWeb exports the formal name in the form "Smith, John". Sometimes I need to split the formal name field into first name (including middle name) and last name. To get the formula to split the name I found this link from Pearson Software Consulting, LLC . Their formula to get the last name works great for me, but they were splitting the middle name from the first name, so for the first name I changed their formula to the following: =TRIM(IF(ISERROR(FIND(",",A2,1)),A2,MID(A2,FIND(",",A2,1)+1,LEN(A2))))   To use the formula simply have the formal name in cell A2 and copy and paste the formula to another adjacent cell, such as B2. To get the first names of the rest of the people in the list simply use the auto fill values command from Excel.

How to split a full name in Excel

RenWeb exports the formal name in the form "Smith, John". Sometimes I need to split the formal name field into first name (including middle name) and last name. To get the formula to split the name I found this link from Pearson Software Consulting, LLC . Their formula to get the last name works great for me, but they were splitting the middle name from the first name, so for the first name I changed their formula to the following: =TRIM(IF(ISERROR(FIND(",",A2,1)),A2,MID(A2,FIND(",",A2,1)+1,LEN(A2))))   To use the formula simply have the formal name in cell A2 and copy and paste the formula to another adjacent cell, such as B2. To get the first names of the rest of the people in the list simply use the auto fill values command from Excel.

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/