Interesting programming ideas, solutions, and logic that I have used to solve problems or have come across throughout my career.
About Me
- William Andrus
- Northglenn, Colorado, United States
- I'm primarily a BI Developer on the Microsoft stack. I do sometimes touch upon other Microsoft stacks ( web development, application development, and sql server development).
Tuesday, December 12, 2006
BizTalk Query: Find what schemas are deployed.
select msgtype, body_xpath, clr_namespace, clr_typename, clr_assemblyname, schema_root_name,
docspec_name
from bt_DocumentSpec
order by msgtype --(which is the schema-name)
--order by date_modified desc -- (probably the date deployed?)
BizTalk Assessment Question: Recoverable Interchange
You are a Microsoft(R) BizTalk(R) Server 2006 technology specialist for your company. You need to enable and configure the new recoverable interchange feature in BizTalk Server 2006.
Where can you enable and configure this feature? (Each correct answer presents a complete solution. Choose two.)
- In Microsoft Visual Studio(R) 2005 while you are defining an orchestration
- In the Tracking Profile Editor
- In the BizTalk Server Administration Console
- In the Business Activity Monitoring (BAM) portal
- In Microsoft Visual Studio(R) 2005 while you are defining a custom pipeline
There are two ways of setting up the recoverable interchange in BizTalk 2006 either through the pipeline's XMLDisassembler component or through the Admin Console
BizTalk Assessment Question: MQSeries adapter
What should you do?
- Download and install a community-supported MQSeries adapter.
- Use the built-in MQSeries adapter.
- Use the MQSeries application programming interface (API) to write your own MQSeries adapter.
- Download and install the Microsoft-supported MQSeries adapter.
Well this one is kinda obvious, Use the built-in MQSeries adapter.
"For BizTalk Server 2004 the MQSeries adapter was available as a Web
download. In BizTalk Server 2006, the MQSeries support comes built-in. With the
MQSeries adapter, organizations can use XML-enabled MQSeries investments, making it possible to more securely and reliably integrate disparate applications."
BizTalk Assessment Question: Zoom feature
- Mapper tool
- Schema Designer
- Pipeline Designer
- Orchestration Designer
"Orchestration zooming. In BizTalk 2004, working with
complex orchestrations in the Orchestration Designer sometimes requires a lot of
scrolling on the design surface to view different parts of the orchestration. In
BizTalk Server 2006, the designer has been enhanced to provide the ability to
zoom in and out on an orchestration, allowing a developer to view only those
parts of an orchestration of current interest. "
Monday, December 11, 2006
BizTalk Assessment Question: Make a schema from a postionial flat file
You are a Microsoft(R) BizTalk(R) Server 2006 application developer. You want to create a schema that is based on a positional document.
What should you do?
- Purchase a third-party tool that converts positional documents to XML documents.
- Count and record the starting position of each field.
- Count and record the length of each field.
- Count and record the ending position of each field.
- Run the Flat File Wizard.
There are basically 3 types of flat files:
- Delimited flat file.
- Positional flat file.
- A flat file with combination of Delimited and Positional records.
BizTalk Assessment Question: Allow business users to view BAM alerts and aggregations.
aggregations.
What new feature of BizTalk Server 2006 should you use?
- BAM Web service
- Tracking Profile Editor
- BizTalk Server Administration Console
- BAM portal
The best answer here would be the BAM portal, where business users can set up queries and alerts on a single interface.
BizTalk Assessment Question: Send notification to business users.
You are a Microsoft(R) BizTalk(R) Server 2006 technology specialist for your company. You need to provide notification in real time to business users about changes to their
business processes.
What feature of BizTalk Server 2006 meets this need?
- Business Activity Monitoring (BAM) activity
- Business Activity Monitoring (BAM) alerts
- Business rules
- Orchestrations
In my opinion, BAM alerts would be the best answer here, since you can set it up to send notification when a certain parameter has been reached. BAM activity are just like queries which can be used in the alerts. Business rules and orchestration are more internal but still possible to send out notifications with the use of both of these, but not necessary if you have BAM setup.
BizTalk Assessment Question: What are the two BAM web services?
What two categories can you find in Business Activity Monitoring (BAM) Web services in Microsoft(R) BizTalk(R) Server 2006? (Each correct answer presents part of the
solution. Choose two.)
- Human Workflow Services (HWS) service
- BAM portal BizTalk artifacts
- BAM query service
- BAM management service
Answer: BAM query service and BAM management service
1. BAM Query Service – The service is used
by the BAM Portal to retrieve BAM instance data. The service supports the
infrastructure and is not intended to be used directly from your code. The
service is not supported and is not documented. To retrieve instance, use the
supported techniques described at http://msdn.microsoft.com/library/en-us/BTS06BizProcessMgmnt/html/ae4a8854-d5c2-4b36-a0ef-3f74e138306e.asp?frame=true.
2. BamManagementService – The following service provides, consumers the ability to manage subscriptions and alerts among other management operations
BizTalk Assessment Question: Best way for deploying
What type of file is used in Microsoft(R) BizTalk(R) Server 2006 to make application deployment and management easier by using the new application concept?
- Batch files
- .msi files
- XML files
- Microsoft Windows(R) Management Instrumentation (WMI) files
- Flat files
MSI makes the most sense here. It allows for minipulation to allow for a set of smaller MSI files instead of one large MSI file, and you can manipulate the MSI file with pre and post processing scripts.
BizTalk Assessment Question: What is needed for complete installation?
three.)
- Microsoft .NET Framework 2.0
- Microsoft Internet Explorer 7
- Microsoft Commerce Server 2006
- Microsoft Office Excel(R) 2003 with Service Pack 2
- SQLXML 3.0 with Service Pack 3
- Microsoft Office OneNote(R) 2003 with Service Pack 1
Answer found: SQLXML 3.0 with Service Pack 3, Microsoft Office Excel(R) 2003 with Service Pack 2, and Microsoft .Net Framework 2.0
BizTalk Assessment Question: BizTalk 2006 supports what SQL Servers
- Microsoft SQL Server 6.5
- Microsoft SQL Server 2000
- Microsoft SQL Server 2000 with Service Pack 4
- Microsoft SQL Server 2005
- Microsoft SQL Server 7.0
Answer found: Microsoft SQL Server 2005 or Microsoft SQL Server 2000 with Service Pack 4
BizTalk Assessment Question: Bypass pre-reqs
You are performing a silent installation of Microsoft(R) BizTalk(R) Server 2006.
You want to bypass checks for downloadable prerequisites.
What new command line parameter should you use?
- /IGNOREDEPENDENCIES
- /ADDLOCAL ALL
- /PASSIVE
- /COMPANYNAME
2) Installs all features.
3) Performs a passive installation. The setup program only displays the progress bar.
4) Sets the company name.
Monday, November 27, 2006
A useful BizTalk Sql Query
select
'RcvPort' PortType,
r.nvcName Port,
item.name MapName,
assem.nvcName Assembly,
nSequence, indoc_docspec_name, outdoc_docspec_name
from bts_receiveport_transform rt
inner join bts_receiveport r
on rt.nReceivePortID = r.nID
inner join bt_mapspec ms
on ms.id = rt.uidTransformGUID
inner join bts_assembly assem
on ms.assemblyid = assem.nID
inner join bts_item item
on ms.itemid = item.id
--order by Port, nSequence
union
select
'SendPort' PortType,
r.nvcName Port,
item.name MapName,
assem.nvcName Assembly,
nSequence, indoc_docspec_name, outdoc_docspec_name
from bts_sendport_transform rt
inner join bts_sendport r
on rt.nSendPortID = r.nID
inner join bt_mapspec ms
on ms.id = rt.uidTransformGUID
inner join bts_assembly assem
on ms.assemblyid = assem.nID
inner join bts_item item
on ms.itemid = item.id
order by PortType, Port, nSequence
Saturday, November 18, 2006
SQL Server Adapters for BizTalk
Ok, so in my recent project I have multiple calls to make to a sql server's database. I ran into a problem calling the same database, but to get around that you simply add a unique ID to the end of the URI. It then would look something like: SQL://localhost/database_name/uniqueID
I got that information from the MSDN website.
Some FYI and Tips:
1) Have SQL Server do most of the work, with stored procedures when it comes to a large amount of updating.
2) Use some kind of status update when grabing data from a table to prevent multiple pickups with BizTalk. Use something like a date field or some type of varchar naming.
3) Use "select top 1" to make the document only have one root element.
4) SQL Adapters are limited to 60 messages a minute, unless you poll while data is found.
5) Try to keep the message size to under 1MB.
6) Save Tran and Rollback Tran will cause an error in the SQL Adapter
7) The generated root element is made in the adapter, not the store procedure.
Some tips on BizTalk 2004 to remember.
BizTalk 2004 application.
1) I was having some trouble in developing maps for 2 of them. I then decided to use an external XSLT instead. I started getting un inforormative errors like unexpected ":" and missing ";" in the btm mapping on line 8 and 9. These errors of course made no sense, since there were no line 8 or 9. I knew the problem had to be in the XSLT. The probelm ended up being that I had to get rid of the Version = 1.0 attribute and a var declaration that I had in the xml:stylesheet declaration. This is what the line should of been:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:userCSharp="urn:userCSharp"
exclude-result-prefixes="msxsl userCSharp">
<xsl:output method="xml"
omit-xml-declaration="yes" /> <xsl:template match="/">
2) When writing scripts that use that same functions over and over again, then make a external assemblies. I also made the assembly version hard coded, so that when I change the scripts I don't have to worry about resetting the maps.
Saturday, October 28, 2006
Past week...
The concurrency problem had an interesting solution. We used the timestamp in the database to check for a change before conmitting the updates. My other bugs where as always easy and stupd mistakes.
The biztalk conversion wizard for converting BTS2002 to BTS2004 didn't want to work for me, but it did give me the information that I needed. So I have the old maps and schemas, of course they are not sane mappings. The schemas use lots of attributes and multiple nodes in the destination schemas, which made me convert alot of visual basic into C# inline code, and use xslt in complex mappings.
Thursday, October 05, 2006
BTS 2002 to BTS 2004 Migration: Error about a user('null')
Tuesday, October 03, 2006
Java Question:
Posted by: Dominik Reichl
Integer i = 1;
Integer j = 1;
Integer n = 1000;
Integer m = 1000;
boolean b1 = (i == j);
boolean b2 = (n == m);
Now, what are b1 and b2?
Surprisingly b1 is true, b2 is false.
Why?
Posted by: Dominik Reichl
Ok, so here's the solution why it works this way
First of all, we are using Integer wrapper classes instead of the primitive int type. When compiling, the integral values 1 and 1000 are implicitely converted to Integer objects (called auto-boxing, from int to Integer).
So, we got 4 different Integer instances, right? No!
The Java VM automatically packs "small" primitive values into identical objects (1 is small, 1000 isn't small). You can easily verify this by pasting the code above into a small testing project and fire up the debugger: i and j reference the same object, while n and m reference different objects. The == operator is comparing references, therefore b1 is true (same references) and b2 is false (different references).
Currently "small" means any integer between -128 and 127. But according to Sun this can change to [-32768, +32767] in the future. This packing trick has been introduced to solve performance problems when doing arithmetic with wrapper classes.
Wednesday, September 27, 2006
BizTalk Questions: Migrating BTS 2002 to BTS 2004
What is a promoted property?
Property promotion enables you to flag schema nodes at design time for promotion to the MessageBox at run time. In addition to any custom metadata you explicitly define by promoting properties, BizTalk Server 2004 has several pre-existing properties that it tracks by default. These pre-existing properties are not defined by instance schemas.
What is a binding file?
Binding files are shortcuts so that you can bind once using the BizTalk Explorer, export that binding, and then import it when you need to assign the binding subsequent times. For example, if you install and deploy your development environment and save a binding file, when it is time to go into production, you can script the Deployment Wizard and specify the binding file to use to create the bindings for the ports. For messaging migration, the Migration Wizard only generates one binding file for the send or receive locations in a solution.
Can I have multiple schemas with the same root node?
No. The messaging engine relies on the root node to resolve an XML instance to a schema at run time. (This is possible in BizTalk Server 2002.)
Can I add an orchestration within my migration project?
Yes, it is possible, but not recommended because you have to manually create a send/receive port to/from an orchestration, thereby complicating the migration of your messaging solution.
Is it possible to create an orchestration that receives a non-XML message (a binary large object (BLOB) for instance) through a pipeline with a custom disassembler and promote properties in the blob?
You can pass type-less [aka: un-type] messages through orchestrations by declaring them as an XmlDocument. If you want to retrieve their data, you need to pass them to a .NET object as XLANGPart/XLANGMessage and call part.RetrieveAs(typeof(Stream) ); by using part.LoadFrom( myStream ), you can also construct non-XML messages in an orchestration.
How do I create a dynamic send port?
You can create a dynamic send port either using BizTalk Explorer or within an orchestration:
BizTalk Explorer – Create the port using BizTalk Explorer, and then assign values to the transport properties in BizTalk Editor using the global property schema. You can then select the appropriate schema from references. By default, BizTalk Server 2004 references Microsoft.BizTalk GlobalPropertySchema. Values to the transport properties come from your document. You need to promote elements from your schema using the global property schema.
Orchestration – You can create dynamic ports in an orchestration, and, after you deploy it, the port is accessible from BizTalk Explorer. In the orchestration, you need to assign the address (transport) using an Expression shape.
Will the Migration Wizard migrate custom script functoids?
No. Any maps that are migrated that contain custom script functoids need to be opened and functoids re-coded.
Will the Migration Wizard migrate my queue receive functions?
Yes. BizTalk Server supports all types of receive functions including BizTalk message queuing (MSMQ) file receive. BizTalk Server supports the conventional HTTP receive function, but not the HTTP file receive function because it has no meaningful use in the product.
Will the Migration Wizard migrate my pre-processor?
No. You must update your project by manually migrating any components such as pre-processors not migrated by the Migration Wizard.
Will the Migration Wizard migrate my channel routing and filter configurations?
No, with one exception. BizTalk Server 2004 automatically migrates routing and filtering configurations for channels that use dynamic routing or filtering. Custom routing done in a channel requires that you promote the properties and create the filters.
Will the Migration Wizard migrate orchestrations?
No. The Migration Wizard only migrates the following items.
- BTS 2002 document definitions to BTS 2004 schemas
- BTS 2002 maps to BTS 2004 maps
- BTS 2002 receive functions to BTS 2004 receive locations
- BTS 2002 ports and channels to BTS 2004 ports and pipelines
- BTS 2002 port groups (distribution lists) to BTS 2004 send port groups
The content in this section is provided by Ben Goeltz, Brandon Gross, and Stephen Roger of Equarius, Inc. For more information about Equarius, Inc., see http://go.microsoft.com/fwlink/?LinkId=26941, published in September 2004.
Monday, September 25, 2006
MS ASP.Net Assessment Question: Comparing DataSet Tables
You need to create a relationship between the two tables. Every value in the Product table's VendorID column must have a corresponding value in the Vendor table's VendorID column.
What should you do?
A)Drag a Relation object onto the designer. Set the parent table to Products. Set the child table to Vendors. Select VendorID as the column for both tables. Click Both Relation and Foreign Key Constraint.
B)Right-click the VendorID column on the Vendors table. Click Set Primary Key.
C)Drag a Relation object onto the designer. Set the parent table to Vendors. Set the child table to Products. Select VendorID as the column for both tables. Click Foreign Key Constraint Only.
D)Drag a Relation object onto the designer. Set the parent table to Products. Set the child table to Vendors. Select VendorID as the column for both tables. Click Foreign Key Constraint Only.
E)Drag a Relation object onto the designer. Set the parent table to Vendors. Set the child table to Products. Select VendorID as the column for both tables. Click Relation Only.
A) Product shouldn't be the parent table.
B) Won't solve the relationship problem.
C) Best answer, by setting the restraints, this could be used to enforced the relationship rules, so that it enforces rules about how updates and deletes to related tables are propagated.
D) Products shouldn't be the parent table.
E) There is no relation only contraint.
MS ASP.Net Assessment Question: Validate Email Address
You need to validate that users type e-mail addresses on the Web Form and that the e-mail addresses exist in a database.
What should you do?
A) Configure a RequiredFieldValidator control, a RegularExpressionValidator control, and a CustomValidator control.
B) Configure a RegularExpressionValidator control.
C) Configure a CompareValidator control.
D) Configure a RequiredFieldValidator control and a RegularExpressionValidator control.
A)Best Answer, by having the controls use for checking for populating textboxes and valid email address, then you will have to use the custom validator to check if both textboxes are also similar.
B)Wrong, since the regular expression validator doesn't check unless data has been entered into the textbox.
C)Wrong, only compares two textboxes, won't check if they are correct.
D) Wrong, would check for populate field and correct format for email, but not if two textboxes are similar.
MS ASP.Net Assessment Question: Web and Mobile pages.
You need to implement the Web application by using the minimum amount of custom code.
What should you do?
A) Create all Web pages from the System.Web.UI.Page base class. Create custom device adapters for ASP.NET server controls.
B) Create all Web pages from the System.Web.UI.MobileControls.MobilePage base class. Add controls from the Mobile namespace.
C) Create all Web pages from the System.Web.UI.Page base class and use a master page.
D) Create a set of pages from the System.Web.UI.Page class. Then create a set of pages from the System.Web.UI.MobileControls.MobilePage base class.
A) To much work, and don't know if it would work.
B) Easiest, would generate HTML if web pages and WML/HTML for mobile devices.
C) Wrong, most mobile devices can not display HTML, only WML.
D) Would work, but it might be take to much work compared to B.
MS ASP.Net Assessment Question: Giving permissions
You need to configure the Web application so that it always runs in the context of the AppUser account.
Which code segment should you use?
A)<identity
impersonate="true"
userName="CONTOSO\AppUser"
password="pwd"/>
B)<appSettings>
<add key="userName" value="CONTOSO\AppUser"/>
<add key="password" value="pwd"/>
</appSettings>
C)<identity
impersonate="false"
userName="registry:HKLM\Software\AspNetProcess,Pwd"
password="registry:HKLM\Software\AspNetProcess,Name"/>
D)<identity
impersonate="false"
userName="registry:HKLM\Software\AspNetProcess,Name"
password="registry:HKLM\Software\AspNetProcess,Pwd"/>
A) This would give the user the appropriate permissions on the account.
B) This is more like a global variable that can be used throughout the asp.net pages. For example, setting the database connection information in the web.config.
C & D) Well to impersonate you will need it to be true, and these lines actually save the information to the registry. This is good for storing the user's name and password for the site.
Saturday, September 23, 2006
MS ASP.Net Assessment Question: Constant deployment of a web page.
After performance testing, you decide to precompile the Web application to improve page-loading speed. Currently, the source files are deployed with the Web application for ease of maintenance.
You need to precompile the Web application by using the minimum amount of administrative effort.
What should you do?
A) Create a Web Setup project.
B) Create a batch file that uses MSBuild.exe.
C) Use the Copy Web tool.
D) Load the following URL into a Web browser.
http://localhost/mywebsitename/precompile.axd
A: The web setup project is a great solution when you want to import and deploy to a server, but there are alot of step and seems to be other simpiler, quicker ways.
B: MSBuild.exe will build the project. This would work as long as the IIS and VS.Net are on the same server.
C: The copy web tool copys a website to another location on a different server, for example. This of course doesn't precompile, and would be ok as long as there is nothing complicated in the design. However, if you think your website is going too slow, then this would not be the answer.
D: This will precompile the website and give a message if successful. This seems to be the best answer. This might not always be the best solution: http://dotnetgeek.blogspot.com/2004/10/pre-compilation-in-aspnet-v11.html
Friday, September 22, 2006
SQL Interview Questions: Definitions
1) What is a SARGABLE predicate?
2) What is DAS? What is NAS? What is a SAN? Name the two main types of SAN networks. What is the common name for the device used to interface to a SAN?
3) What is a LUN? How is it used with a SAN?
4) What is a RAID? What RAID format is the recommended best practice for SQL Server, and why?
5) What is an INSTEAD-OF trigger used for?
6) What is a LOB?
Answers?:
1) Predicates that do searching, like Year > 2000.
2) Direct Attached Storage, Network Attached Storage, Storage Area Network, Fibre Channel and iSCSI, Host Bus Adapter.
3) Logical Unit Number , Each device(or LUN) on the storage area network (SAN) is "owned" by a single computer (or initiator)
4) RAID (Redundant Array of Independent Disks). A collection of disk drives that offers increased performance and fault tolerance. There are a number of different RAID levels. The three most commonly used are 0, 1, and 5. Microsoft recommends a RAID that would provide the best write performance. For each write request a RAID0 would write once, RAID1 or RAID10 would write twice, and RAID5 would write 4 times. RAID 0 is never recommended, so this leaves RAID10 as the recommended.
Here are the RAIDs:
Level 0: striping without parity (spreading out blocks of each file across multiple disks).
Level 1: disk mirroring or duplexing.
Level 2: bit-level striping with parity
Level 3: byte-level striping with dedicated parity. Same as Level 0, but also reserves one dedicated disk for error correction data. It provides good performance and some level of fault tolerance.
Level 4: block-level striping with dedicated parity
Level 5: block-level striping with distributed parity
Level 6: block-level striping with two sets of distributed parity for extra fault tolerance
Level 7: Asynchronous, cached striping with dedicated parity
5) There are 3 types of triggers: BEFORE, AFTER and INSTEAD OF. BEFORE is used to affect the row before the trigger event executes. AFTER is used to trigger actions are activiated for the affected rows. INSTEAD OF is used to triggers its action for each row in the affected row instead of using the trigger event.
6) Locator OBject.
SQL Interview Questions:
1) What is the name of the SQL Server query language?
2) What is the difference between DML and DDL?
3) Name the four main types of DML Query operations.
4) Name three reasons to use a stored procedure.
5) What is the difference between a stored procedure and an extended stored procedure? Where is an extended stored procedure stored?
6) What is the difference between "Truncate" and "Delete From"?
7) What is a SQL Server Page, and how is it used? How big is a page? How much data space is available on each SQL Server Page?
Answers:
1) Transact-SQL (used by Microsoft and Sybase)
2)
DDL is Data Definition Language statements. Some examples:
CREATE - to create objects in the database
ALTER - alters the structure of the database
DROP - delete objects from the database
TRUNCATE - remove all records from a table, including all spaces allocated for the records are removed
COMMENT - add comments to the data dictionary
GRANT - gives user's access privileges to database
REVOKE - withdraw access privileges given with the GRANT command
DML is Data Manipulation Language statements. Some examples:
SELECT - retrieve data from the/a database
INSERT - insert data into a table
UPDATE - updates existing data within a table
DELETE - deletes all records from a table, the space for the records remain
CALL - call a PL/SQL or Java subprogram
EXPLAIN PLAN - explain access path to data
LOCK TABLE - control concurrency
3) From above most popular are Select, Insert, Update and Delete.
4)
Encapsulation - changing the inner implementation as often you like.
Security - secured at a database level, and help prevent SQL Injection attacks.
Performance - Improving network traffic, etc..
5)Extended store procedure is accessed as though it was a compiled SQL program. They are not written in Transact-SQL, they reside in DLLs.
6)
Truncate is DDL and drops all rows no ROLLBACK possible, no WHERE clauses possible. Truncate drops blocks created for the table without erasing the definition of the table, delete just the content of those blocks. Aditional to this, clustered tables cannot be truncated. DELETE is DML and uses various memory structures allowing ROLLBACK and WHERE clauses.
DELETE from table_name where... ;
TRUNCATE table table_name;
7) Pages exist to store records. A database page is an 8192-byte (8KB) chunk of a database data file. They are aligned on 8KB boundaries within the data files, starting at byte-offset 0 in the file. Pages are the basic unit of IO that SQL server uses. 8060-bytes are used for storing data.
MS ASP.Net assessment Question: Verify XML from Schema
You need to validate the changes that you made to the XML document against a schema. You do not want to create a new instance of the Document Object Model (DOM).
What should you do?
A) Create an XmlNodeReader by using the XML document. Set the validation settings on the XmlReaderSettings object. Create a validating reader that wraps the XmlNodeReader object.
B) Save the contents of the XML document to the file system. Create a new instance of the XmlDocument class. Call the Load method, and pass in the file path of the recently modified XML document.
C) Create an XmlNodeReader by using the elements of the XML document that changed. Set the validation settings on the XmlReaderSettings object. Create a validating reader that wraps the XmlNodeReader object.
D) Save the contents of the XML document to a string. Create a new instance of the XmlDocument class. Call the LoadXml method, and pass in the string representation of the recently modified XML document.
A- seems to be correct, the XmlReaderSettings allows for setting the schema to be used and you can then just use a XmlReader that would use that. I am assuming that the XmlNodeReader could do the same.
B- would work, but seems excessive amount of time to accomplish.
C- Same as A, but only looks at the newly created nodes, this seems to be the quickest. The XmlNodeReader is suppose to keep track of where in the schema the current not would be referencing.
D- inefficient, holding xml in string is probably not the best choice.
A good way of doing this was found on MSDN: http://support.microsoft.com/kb/318504/
MS ASP.Net Assessment Question: Using RequiredFieldValidator
You need to use the RequiredFieldValidator control to ensure that the text box contains a value before it is submitted to the server.
What should you do?
A) Set the RequiredFieldValidator control's ControlToValidate property to txtName.
B) Set the RequiredFieldValidator control's InitialValue property to txtName.Text.
C) Set the RequiredFieldValidator control's EnableClientScript property to False. Add code to the form's btnSave_Click event that checks whether the text box contains a value. If it does not, set the RequiredFieldValidator's IsValid property to False.
D) Set the text box's CausesValidation property to True. Set its ValidationGroup to the ID of the RequiredFieldValidator control.
A - obvious answer, the ControlToValidate tells what control it will be checking to see if a value exist.
B - Wrong, sets the inital value to what is in the textbox.
C - kinda wrong, since you are setting the EnableClientScript to false, it would only check during the postback event that is thrown from the button. It might show you that the field is required or not only during postback though.
D - kinda wrong, this is better used on webcontrols that are not easily validated like a set of radio buttons.
Thursday, September 21, 2006
MS ASP.Net Assessment Question: Specify for browser type.
When mobile browsers view the page, the Label must render "Name" instead of "Enter Your First Name."
You need to ensure that the Label renders correctly.
What should you do?
A) Add the following XML segment to Ie.browser. <capability name="mobile" value="true" />
B) Use device filters to specify alternate text in the Label definition.
C) Create a new file named All.browser, and add it to the browser's directory. Specify browser capabilities in All.browser.
D)Add the following attribute to the Label. EnableTheming="True"
A - Just states that IE can handle mobile, but don't know if capability is an actual tag.
B - I would think a device filter would be easy, by just checking for WML
C - Creating a All.browser will allow for the page to specify how it is render based on the browser used by the user, but don't think it would allow small cosmetic changes.
D - EnableTheming would just use the theme for that page.
Found this on a 2004 MSDN article which would be nice to use instead:
<asp:label runat="server" text="some browser" IE:text="any IE browser"
IE5:text="the IE 5 browser" PIE:text="the Pocket PC browser" />
Wednesday, September 20, 2006
MS ASP.Net Assessment Question: Cancelling a logon event.
You need to write code in one of Login1's event handlers to cancel the logon process.
What should you do?
A)Write code in the Login1_Load event handler.
B)Write code in the Login1_LoginError event handler.
C)Write code in the Login1_LoggedIn event handler.
D)Write code in the Login1_LoggingIn event handler.
E)Write code in the Login1_Authenticate event handler.
A is wrong since there is no Load event for the Login Control.
B is wrong since this only occurs when the login event throws an error.
C is wrong since the user is logged into the site and is authenticated.
D is probably the best answer since the process of logging on is still taking place and authentication has not occured yet.
E is wrong because the user would have already been authenicated by then.
MS ASP.Net Assessment Question: Store custom events in a database.
You need to implement an event tracking process that enables custom events to be stored in a database.
What should you do?
A) Log a message into a MessageQueue.
B) Implement ICallbackEventHandler.
C) Derive a class from WebBaseEvent.
D) Derive a class from EventInstance.
A, the MSMQ allows for communication over networks and allows server-side applications running within ASP.NET to use MSMQ. Storing messages into a database can be done with MSMQ.
B is wrong because ICallbackEventHandler is used for calling codebehind from a javascript function.
C the WebBaseEvent allows the monitoring of performance of an app, diagnose failing apps and/or systems and appraising significant events during the lifecycle of a the given app. Using SqlWebEventProvider as your event provider and inherit from the WebBaseEvent to customize them if you wanted.
D) is wrong. EventInstance is for 3.0, not 2.0. Allows for writing messages based on the localized language on the machine and writes the entry to the event log.
So it could be A or C (IMO), but I would take the guest of C in this case.
MS ASP.Net Assessment Question: Extract data from XML Node.
<bookstore>
<books>
<book genre="'reference'" id="'23'">
<title>World Atlas</title>
<author status="bestseller">
<first-name>Joe</first-name>
<last-name>Worden</last-name>
</author>
<price>8.99</price>
</book>
</books>
</bookstore>
You advance the XmlReader to the author XmlNode.
You need to extract the values of the author XmlNode and all of its children as a string.
What should you do?
A) Use the ReadInnerXml method of the XmlReader.
B) Use the ReadOuterXml method of the XmlReader.
C) Use the ReadString method of the XmlReader.
D) Use the Value property of the XmlReader
A would be wrong since it would only get the children information.
B is correct since it would give the children tags and the current start tag.
C would return a string, but only the data up to the first end tag.
D this would only return the attribute of the author in this case.
MS ASP.Net Assessment Questions: Setting cursor inside textbox on page loading.
You need to set the cursor inside the given name text box when the Web Form is first displayed.
What should you do?
A) Call the SetFocus method of the Page inside the text box control's Init event.
B) Set the text box control's TabIndex property to 0.
C) Call the Focus method of the text box control inside the page load event.
D) Set the text box control's Enabled attribute to True inside the form's source view.
My answer would be C, since it just makes sense to set focus to the control during the page_load event.
A is wrong (IMO): because SetFocus is not a defined method and the Page_Init only initializes the page when it is first called. The Page_Load event is then called once the request has been processed, and all of the controls are updated.
B is wrong because the TabIndex only tells what order of the controls on the page are sequentially access when the tab button is pressed.
D is wrong because setting a control to enabled only allows the user to enter information into that control.
Sunday, September 10, 2006
Kerberos
http://www.hitmill.com/computers/kerberos.html
http://www.microsoft.com/technet/prodtechnol/windows2000serv/deploy/confeat/kerberos.mspx
http://support.microsoft.com/?id=319723
Friday, September 08, 2006
An Interview Question: Whats the difference between an EXE and DLL?
The distinction between EXE and DLL files is entirely one of semantics. They both use the exact same PE [Portable Executable] format. The only difference is a single bit that indicates if the file should be treated as an EXE or as a DLL. Even the DLL file extension is artificial. You can have DLLs with entirely different extensions—for instance .OCX controls and Control Panel applets (.CPL files) are DLLs.-- Matt Pietrek
Thursday, September 07, 2006
VI Search Engine
http://www.visearch.com/
Lunch started out innocently enough for Snap.com colleagues Brad Haugaard, Joe Chen, Ken Yeh. While discussing Snap's very visually oriented search engine, they collectively wondered, "What about people who don't really care about pictures?"-- from http://www.linuxplanet.com/linuxplanet/reviews/6306/1/
Somebody said, "How about 'visearch'? We could combine a vi editor with a search engine."
The three mused that you could move up and down with the "j" and "k" keys. You might also delete bad listings with "dd" or insert comments into the listing with an "i".
With suggestions from Haugaard and Yeh, Chen programmed a working system over the next few weeks. Chen and Yeh are both software engineers, while Haugaard is a customer service manager.
Thursday, August 31, 2006
Set Day of the Month
private System.DateTime SetDayOfMonth(System.Int32 nth, System.DayOfWeek weekday, System.Int32 month, System.Int32 year)
{
System.DateTime dath = new DateTime(year, month, 1); //set to first day of the month
//get to the first weekday looking for
while(dath.DayOfWeek != weekday)
{
dath = dath.AddDays(1);
}
if(nth > 1)
{
dath = dath.AddDays((nth - 1) * 7);
}
else
{
dath = dath.AddMonths(1);
dath = dath.Substract(TimeSpan.FromDays(1); //last day of the month
while(dath.DayOfWeek != weekday)
{
dath = dath.Subtract(TimeSpan.FromDays(1)); //cycle backwards to last
}
dath = dath.Subtract(TimeSpan.FromDays(((nth * -1) - 1) * 7));
}
return dath;
}
Thursday, July 20, 2006
Grid View Problem
I take the data set I was using and make a copy of it, remove the column I didn't want, and then add the selectable column.
Tuesday, July 11, 2006
String.Format
This is a cool and very useful feature in C#. If you need to convert something like a date value from a sql database and display it into a textbox, then this is what you were looking for, before, it would always put the time 12:00 AM in after the date.
Example:
DateOnly = new DateTime();
DateOnly = (DateTime)dr["DATE_APPROVED"];
this.TextBoxDate.Text = String.Format("{0:d}", DateOnly);
Here are some of it's formats and conversions
Formating Strings:
example | output |
---|---|
String.Format("--{1,10}--", "test"); | -- test-- |
String.Format("--{1,-10}--", "test"); | --test -- |
Formating Numbers:
specifier | type | format | output (double 1.2345) | output (int -12345) |
---|---|---|---|---|
c | currency | {0:c} | £1.23 | -£12,345.00 |
d | decimal (whole number) | {0:d} | System.FormatException | -12345 |
e | exponent / scientific | {0:e} | 1.234500e+000 | -1.234500e+004 |
f | fixed point | {0:f} | 1.23 | -12345.00 |
g | general | {0:g} | 1.2345 | -12345 |
n | number | {0:n} | 1.23 | -12,345.00 |
r | round trippable | {0:r} | 1.23 | System.FormatException |
x | hexadecimal | {0:x4} | System.FormatException | ffffcfc7 |
Custom Formatting
specifier | type | format | output (double 1234.56) |
---|---|---|---|
0 | zero placeholder | {0:00.000} | 1234.560 |
# | digit placeholder | {0:#.##} | 1234.56 |
. | decimal point placeholder | {0:0.0} | 1234.6 |
, | thousand separator | {0:0,0} | 1,235 |
% | percentage | {0:0%} | 123456% |
Date-Time
specifier | type | format | output (double 1234.56) |
---|---|---|---|
0 | zero placeholder | {0:00.000} | 1234.560 |
# | digit placeholder | {0:#.##} | 1234.56 |
. | decimal point placeholder | {0:0.0} | 1234.6 |
, | thousand separator | {0:0,0} | 1,235 |
% | percentage | {0:0%} | 123456% |
specifier | type | output (June 8, 1970 12:30:59) |
---|---|---|
d | Short Date | 08/06/1970 |
D | Long Date | 08 June 1970 |
t | Short Time | 12:30 |
T | Long Time | 12:30:59 |
f | Full date and time | 08 June 1970 12:30 |
F | Full date and time (long) | 08 June 1970 12:30:59 |
g | Default date and time | 08/06/1970 12:30 |
G | Default date and time (long) | 08/06/1970 12:30:59 |
M | Day / Month | 8 June |
r | RFC1123 date string | Mon, 08 Jun 1970 12:30:59 GMT |
s | Sortable date/time | 1970-06-08T12:30:59 |
u | Universal time, local timezone | 1970-06-08 12:30:59Z |
Y | Month / Year | June 1970 |
specifier | type | output (June 8, 1970 12:30:59) |
---|---|---|
dd | Day | 08 |
ddd | Short Day Name | Mon |
dddd | Full Day Name | Monday |
hh | 2 digit hour | 12 |
HH | 2 digit hour (24 hour) | 12 |
mm | 2 digit minute | 30 |
MM | Month | 06 |
MMM | Short Month name | Jun |
MMMM | Month name | June |
ss | seconds | 59 |
tt | AM/PM | PM |
yy | 2 digit year | 70 |
yyyy | 4 digit year | 1970 |
: | seperator, e.g. {0:hh:mm:ss} | 12:30:59 |
/ | seperator, e.g. {0:dd/mm/yyyy} | 08/06/1970 |
Monday, July 10, 2006
Convergence theory for nonconvex stochastic programming with an application to mixed logit
Abstract Monte Carlo methods have extensively been used and studied in the area of stochastic programming. Their convergence properties typically consider global minimizers or first-order critical points of the sample average approximation (SAA) problems and minimizers of the true problem, and show that the former converge to the latter for increasing sample size. However, the assumption of global minimization essentially restricts the scope of these results to convex problems. We review and extend these results in two directions: we allow for local SAA minimizers of possibly nonconvex problems and prove, under suitable conditions, almost sure convergence of local second-order solutions of the SAA problem to second-order critical points of the true problem. We also apply this new theory to the estimation of mixed logit models for discrete choice analysis. New useful convergence properties are derived in this context, both for the constrained and unconstrained cases, and associated estimates of the simulation bias and variance are proposed.
Wednesday, July 05, 2006
On change event in ASP.Net
<script language="javascript" type="text/javascript">
window.onbeforeunload = saveChanges;
function saveChanges()
{
var changes = document.getElementById("<%=this.ButtonSubmit.ClientID%>").disabled;
if(!changes)
{
event.returnValue = 'Changes were not saved. Click Cancel to go back and submit changes, or click OK to continue.';
}
}
function enableSubmit()
{
document.getElementById("<%=this.ButtonSubmit.ClientID%>").disabled = false;
}
</script>
The first function: saveChanges() is called when ever the user tries to change the current page or close the browser. It just asks if they user wants to leave without saving.
The second function is called when ever a textbox, or other asp/html control has changed. This basically just enables the submit button.
So, within the page we might have a ASP.Net control like this:
<asp:textbox id="TextBox1" runat="server" onchange="enableSubmit()" width="49px"><asp:textbox>
Now, you would end up getting a warning in ASP.Net since it doesn't recognize the onchange event, since this is actually a javascript event. The trick here is when the page is render this is how it would look in the html:
<input id="ctl00_ContentPlaceHolder1_TextBox1" style="WIDTH: 49px" onchange="enableSubmit()" name="ctl00$ContentPlaceHolder1$TextBoxNotes">
Monday, June 26, 2006
Riddle: CRIMINAL CUPBEARERS
An evil king has 1000 bottles of wine. A neighboring queen plots to kill the bad king, and sends a servant to poison the wine. The king's guards catch the servant after he has only poisoned one bottle. The guards don't know which bottle was poisoned, but they do know that the poison is so potent that even if it was diluted 1,000,000 times, it would still be fatal. Furthermore, the effects of the poison take one month to surface. The king decides he will get some of his prisoners in his vast dungeons to drink the wine. Rather than using 1000 prisoners each assigned to a particular bottle, this king knows that he needs to murder no more than 10 prisoners to figure out what bottle is poisoned, and will still be able to drink the rest of the wine in 5 weeks time. How does he pull this off?
First thing I noticed was that 2^10 is approx 1000 and saw that this dealt with some sort of binary solution. I then broke the question down into a smaller one. Dealing with 8 bottles of wine and 3 prisioners, assuming that the 2^10 has something to do with the solution.
So, I came up with this basic solution:
Bottle 1: Prisoner 1 drinks
Bottle 2: Prisoner 2 drinks
Bottle 3: Prisoner 3 drinks
Bottle 4: Prisoner 1 & 2 drinks
Bottle 5: Prisoner 1 & 3 drinks
Bottle 6: Prisoner 2 & 3 drinks
Bottle 7: Prisoner 1 & 2 & 3 drinks
Bottle 8: No one drinks.
So for example if prisoner 1 & 3 dies, then you know it must be bottle 5 that was poisoned.
I guess this could be looked at as some type of Venn diagram, and/or combinatorics. I don't know if this solution would work for 1000 bottles and 10 prisoners.
Wednesday, June 21, 2006
How to redirect a page, the right way.
http://www.stevenhargrove.com/redirect-web-pages/
Since, I'm developing mostly in ASP.Net, here is his sample code on how to use it.
<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","http://www.new-url.com/");
}
</script>
Algorithms
I could probably add a couple, but I haven't look through the whole thing. I believe he is making this a book, but I believe their is already an algorithm book out there. Anyway, check it out, looks like a good find.
Friday, June 09, 2006
Way to execute a file through an ASP.Net page.
System.Diagnostics.Process.Start(LocationOfString);
Friday, June 02, 2006
Multiple Control Validator
private bool TxtBox1 = false;
private bool TxtBox2 = false;
I then have my two custom validator functions, which are similar, except for the name of the second validator and it's TxtBox2:
protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
{
if (args.Value == "")
{
TxtBox1 = false;
}
else
{
TxtBox1 = true;
}
args.IsValid = getValidation();
}
So, I just check if there was a value entered and set my private variables.
I then call a function to assign the validation.
private bool getValidation()
{
if (TxtBox1 TxtBox2)
{
return true;
}
else
{
return false;
}
}
Now to deal with the textboxes being both empt
protected void ButtonSubmit_Click(object sender, EventArgs e)
{
this.Page.Validate();
if (TxtBox1 == false && TxtBox2 == false)
{
this.CustomValidator1.IsValid = false;
this.CustomValidator2.IsValid = false;
}
}
First validate the other controls, then validate our custom controls to see if both were left blank.
If so, then set both validators to false.
This is what I came up with so far, I might find a way to improve the summary, so that it would only give one line as the error instead of 2.
Sunday, May 21, 2006
We want no postbacks
P.S. I have a complaint about about browsers and W3C, to center a page you have to use the attribute "style" with the left and right width to auto. The thing is that this doesn't work in the browsers (IE and Firefox). So while in VS 2005 I made a div tag with the attribute 'align' sent to center, but this of course gives a warning that this technique is out dated. WTF?!?!?!?!?!?!?!?!?!
Saturday, May 13, 2006
Web Controls and Pop Up Windows with ASP.Net 2.0
Well, to have a pop up window, we developed a image button, which can be used and is more user friendly. We also wanted to make it more possible to change the size of the pop up window.
private System.Web.UI.WebControls.ImageButton _imageBtn; //Button with image used to call pop-up page
private System.String _popUpLoc; //Location of the popup page
private System.Web.UI.WebControls.Unit _popUpPageWidth; //Width of the pop up page
private System.Web.UI.WebControls.Unit _popUpPageHeight; //Height of the pop up page
Next are the properties so we can change values during the design view. Most of which are obvious, so here is an example of one:
[Bindable(true)]//used for binding
[Category("Pop Up Window")] //in properties section "Pop Up Window"
[Description("The URL of the pop-up webpage")]//description of PagePopUp
[DefaultValue("")]//default value
[Localizable(true)]//allow multi-language
public virtual System.String PopUpURL
{
get
{
return this._popUpLoc; //returns a string representing the location of the image
}
set
{
this._popUpLoc = value; //set the string value for the location of the image button
}
}
etc... for the other properties you might want to set. Use EnsureChildControls(); for controls that are used on the page.
Next override the CreateChildControls:
protected override void CreateChildControls()
{
Controls.Clear(); //clear the controls before adding them
this._imageBtn = new System.Web.UI.WebControls.ImageButton();//declare image button with image on it
this._imageBtn.ID = "CalendarBtn";//set the id of the image button
Controls.Add(this._imageBtn);//add the image button to the child control collection
}
In the render control is where we add an attribute to the image button.
protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
AddAttributesToRender(writer); //add HTML that needs to be render
/*
* Calls javascript to open a new window and send in the text box id
*
* this.PopUpURL is the page to pop open
* this.Page.Form.ClientID represents the page's form id eg:
* this.ClientID represents the web controls's ID eg:
* the height and width variables are used to set the dimensions of the browser
* the status= no, resizable= no, scrollbars=no, toolbar=no,location=no,menubar=no are used to remove usless items and fixate the window size
*
* Note: since during the page initialization the controls are developed before the page
* we had to place the _imageBtn.Attributes.Add(...) into the render method
* to prevent NullException error.
*
*/
_imageBtn.Attributes.Add("onclick", "window.open('" + this._popUpLoc
+ "?field=" + this.Page.Form.ClientID + "." + this.ClientID
+ "',null,'height=" + this._popUpPageHeight + ", width="
+ this._popUpPageWidth + ",status= no, resizable= no, scrollbars=no, toolbar=no, location=no, menubar=no ');");
this._imageBtn.RenderControl(writer);//render the image button
}
Tuesday, May 09, 2006
How To: Run Web Control next to an application during development
Create a new website for testing. Eg. WebControlTester.
within the Solution Explorer place your web control into a new folder App_Code
then add a web.config file to the Solution Explorer.
Within the web.config file add:
<pages>
<controls>
<add namespace="Your.Namespace.In.WebControl" tagprefix="SomeTagPrefix">
</controls>
</pages>
Now you can edit your web control, build it and then switch to the web site and run it.
<^_^>
Friday, April 14, 2006
Krugle
Well, the first thing I tried was C# to see if there was any, unfortunately there wasn't any.
So the next search I did, was on "reinforcment learning", and there were some code. I am pleased about this. I selected a source code called: test_agents.c
I am able to see the source code, the comments, etc. It is very nice to see how other programmers would do things.
I also took a look at a java class called RLPolicy.java, it was cool to see they implemented some of the exact same things I did.
They allow you to view the whole project, in which they catagorized the files to where they belong.
I'll probably look at some of the code, and if I find something I like, I'll probably rewrite it in C#, not to hard coming from code like C,C++, or Java.
Tuesday, April 11, 2006
Old, but new to me: C# will this compile?
using System;
using System.Threading;
public class Class1
{
public static void Main ()
{
new Thread(delegate
{
Console.WriteLine("On another thread");
}).Start();
}
}
I couldn't see why it could ever worked, but then looking at his solutions http://blogs.msdn.com/brada/archive/2004/12/27/332863.aspx
I see why I didn't like it. I would have used the first version of his solution:
new Thread(
delegate ()
{
Console.WriteLine("On another thread");
}
).Start();
since it looks like the way a delegate would be initialized and a function that a thread would call.
Monday, April 10, 2006
How To: Build a RPG in a week
Nice to see that an 80's RPG can easily be made with free tools. He did his programming with python, which is interesting to see that python has come a long way.
Friday, April 07, 2006
How to pull an all nighter... (Shout out to Cornell)
Good basic tips:
Drink caffene, but not too much.
Eat food
Take a shower
Loud Music (doesn't work for me, makes me tired)
Walk around (any good exercise, like 20 pushups or something)
Don't lie down
Don't eat fatty food, I would also add sugary foods since they make you drowsy after 15 minutes
Don't turn the lights out (hope you don't have a room mate)
I never did an all nighter, but I also never procastinated. I knew the sooner I got my shit done, the more time I had to play Counter Strike. :)
Friday, March 24, 2006
Updated: AIM Plugin: SignOff
http://williamandrus.tripod.com/AIMPlugin.html
Here is some of the code used to play WAV files in C#, in which I think I stole from some other website, a while back.
Well you will need this:
using System.Runtime.InteropServices;
Import a dll to play the WAV sound
[DllImport("winmm.dll")]
private static extern bool PlaySound(string lpszName, int hModule, int dwFlags);
Here is the enumeration of the SND
public enum SND
{
SND_SYNC = 0x0000 ,/* play synchronously (default) */
SND_ASYNC = 0x0001 , /* play asynchronously */
SND_NODEFAULT = 0x0002 , /* silence (!default) if sound not found */
SND_MEMORY = 0x0004 , /* pszSound points to a memory file */
SND_LOOP = 0x0008 , /* loop the sound until next sndPlaySound */
SND_NOSTOP = 0x0010 , /* don't stop any currently playing sound */
SND_NOWAIT = 0x00002000, /* don't wait if the driver is busy */
SND_ALIAS = 0x00010000 ,/* name is a registry alias */
SND_ALIAS_ID = 0x00110000, /* alias is a pre d ID */
SND_FILENAME = 0x00020000, /* name is file name */
SND_RESOURCE = 0x00040004, /* name is resource name or atom */
SND_PURGE = 0x0040, /* purge non-static events for task */
SND_APPLICATION = 0x0080 /* look for application specific association */
}
Use this to play the WAV file:
PlaySound(fileName,0,1);
Thursday, March 23, 2006
AIM Plugin: Sign Off Timer
It basically allows the user to set how many minutes he/she would like to stay online. When this time is reached, a pop-up box is displayed and you are signed off. I remember when I was a college student, and I would be almost late for class because I was on AIM losing track of time.
Here is the website where you can download it: http://williamandrus.tripod.com/AIMPlugin.html
I set it up so that the timer would run on it's own thread, that way it won't interfere with the AIM's thread. So in the Exec function I have this little sniplet:
if(command == kCommandId)
{
Thread t = new Thread((new
ThreadStart(StartTimer)));
t.Start();
}
this then calls my function called StartTimer:
public void StartTimer()
{
TimeSelect timer = new TimeSelect(m_session);
timer.ShowDialog();
}
this then starts up another file which I used to make the form. Here is a sniplet from that program:
private void buttonOK_Click(object sender, System.EventArgs e)
{
CountDown = Convert.ToInt32(this.numericUpDownMinutes.Value);
this.Visible = false;
while(CountDown != 0)
{
Application.DoEvents();
}
MessageBox.Show("You haved been signed off
by the timer.","Sign Off Timer");
this.session.SignOff();
}
private void timeKeeper_Tick(object sender, EventArgs e)
{
if(sender == this.timeKeeper)
{
this.CountDown--;
}
}
Monday, March 20, 2006
AIM SDK
Once I have become more confortable with this, I might develop a simple program and build up from there. I would like to see if I could somehow use Google Map's API with AIM's API and see what I could put together in the future.
Tuesday, March 14, 2006
Google Life
Well, I added a little map of places I have worked, lived and went to school using google's map API. I would like to do something more complicated, but I would need to get a better website where I would be able to use ASP.Net and maybe a database together to make more complicated programs.
Saturday, March 11, 2006
Updated Reinforcement Learning Tic Tac Toe Game
- Increased learning speed and decrease xml file size by implementing rotation, and reflection of the states.
- Fixed one minor bug in the Monte Carlo learning in recognizing a final state
- Fixed one minor bug in the Temporal Difference learning in updating the state values
Wednesday, March 08, 2006
Sequence Number Test
I did ok, got 7 right, before I got bored and started to cheat. Some of the numbers that I didn't get look familar, and once I've google them I was upset to see what they were. Oh well. I did find all the answers with help from google.
Tuesday, March 07, 2006
Ten of the Biggest Mistakes Developers Make With Databases
Well here is a summary of it all:
1) Choosing the Wrong Database: If lots of data, choose a better more optimized database.
2) Choosing Too Many Databases: Just develop your programs for one database, don't worry about being compatible for others.
3) Know Your Data: Don't be wrong about the data size, if it is required, etc...
4) It's Just Like Excel, Right?: Databases are more complex then they seem, and should be done by someone with DB understanding.
5) Third Normal Form is Not the Holy Grail: Not everything should be normalized, sometimes it is more efficient not to.
6) What a Great Place to Hide Application Logic!: Database code isn't scrutinized as well as it should be.
7) Who Needs Backups?: (Ok this is too obvious)
8) Yes, You Need Version Control: (Obvious also) If you got people working and changing your database code, it's good to have a version control for backup and updating reasons.
9) Use the Tools: Use the tools and wizards, they make everything cheaper and more efficient in the long run.
10) Don't Assume Everything is a Nail Just Because You Have a Really Big Hammer: Not everything should be in a DB, some things are just very simple and can be put in a local file or XML. It would make everything less complicated.
Those are some good tips to remember.
P.S. The way of "SQL": I always knew there were two ways of saying "SQL".
One: see-quel
-or-
Two: es-que-el
Well I read that if you are basically talking about Oracle and SQL Server then it is pronounce as: see-quel. However, if you are using something like mySQL and DB2 then it is pronounced as es-que-el. Hmmm, an interesting fact.
Friday, March 03, 2006
Fractal Viewer
http://williamandrus.tripod.com/Fractals.html
I still want to add more features like zooming in and out, more fractals, and maybe an editor where the user would be able to change the formula to view different complex systems.
Currently I have an graphical anaylsis of an orbit, a box fractal, sierpinski's triangle, Mandelbrot set, Julia Set, and Newton's Method.
I still got to do a small write up about Dynamical Systems to put up on my other website.
Friday, February 24, 2006
Ghetto Encryption I
You want to send a valuable object to a friend securely. You have a box which can be fitted with multiple locks, and you have several locks and their corresponding keys. However, your friend does not have any keys to your locks, and if you send a key in an unlocked box, the key could be copied en route. How can you send the object securely?
My solution, (4am in the morning), take the box and send your locks unlocked over inside the box with a question, that he should only know the answer to.
Have your friend put his own locks unlocked in this box, answer the question and then lock the box with your locks.
Put all your keys in the box, with his locks securing the outside. Then have him send back the box with nothing on or in it.
Put your item in the box and lock it with all your locks.
I think that covers it.
Monday, February 20, 2006
Old School: Sort Algorithms
Ok, this just brings back good ol' memories of my first two years in the computer science degree. I remember when I had to program all of these and their time results in C. This pages discusses the classic alogrithms:
Bubble sort
Heap sort
Insertion sort
Merge sort
Quick sort
Selection sort
Shell sort
I also did Bi-Directional Bubble Sort and Bucket Sort as two individual programs of sorting algorithms for my final project.
Sunday, February 19, 2006
A Microsoft Riddle:
Ok, I developed a ad-hoc program to help solve this problem. The major variable in the question is the distance. The distance is the variable, in which just complicates the problem. I know the distance is greater 2000, so I tested with the values 2000, 2500, and 3000.
int NYLADistance = 2000;
int LATrainSpeed = 15;
int NYTrainSpeed = 20;
int BirdSpeed = 25;
int LAStart = NYLADistance;
int NYStart = 0;
int BirdStart = NYLADistance;
int hour = 0;
int BirdTrips = 0;
bool FlyingEast = true;
int TotalBirdTravel = 0;
while(LAStart >= NYStart)
{
hour++;
LAStart = LAStart - LATrainSpeed;
NYStart = NYStart + NYTrainSpeed;
if(FlyingEast)
{
BirdStart = BirdStart - BirdSpeed;
if(BirdStart < NYStart)
{
FlyingEast = false;
BirdTrips++;
}
}
else
{
BirdStart = BirdStart + BirdSpeed;
if(BirdStart > LAStart)
{
FlyingEast = true;
BirdTrips++;
}
}
TotalBirdTravel = TotalBirdTravel + BirdSpeed;
}
I came up with these values:
Distance 3000, bird flys 2150
Distance 2500, bird flys 1800
Distance 2000, bird flys 1450
So, by using these numbers I came up with the formula:
y = (7/10)x + 50
y is the bird travel
x is the distance from LA to NY
Wednesday, February 15, 2006
Microsoft's Interviews
"From "Pete" (not his real name):
I walked into my first technical interview at Microsoft, and before I could say anything, the woman says, Youre in an 8x8 stone corridor. I blink and sit down.
Interviewer: The prince of darkness appears before you.
Me: You mean, like, the devil?
Interviewer: Any prince of darkness will do.
Me: Ok.
Interviewer: What do you do?
Me:Can I run? "
Interviewer: Do you want to run?
Me: Hmm I guess not Do I have a weapon?
Interviewer: What kind of weapon do you want?
Me: Um something with range?
Interviewer: Like what?
Me: Uh a crossbow?
Interviewer: What kind of ammo do you have?
Me:Ice arrows?
Interviewer: Why?
Me:Because the prince of darkness is a creature made of fire???
Interviewer: Fine so what do you do next?
Me: I shoot him?
Interviewer: No what do you do?
Me:
Interviewer: You WASTE him! You *WASTE* the prince of darkness!!
Me:Holy crap what have I gotten myself into.
She then tells me that she asks that question for two reasons. 1) Because she wants to know if the candidate is a gamer (which is apparently really important please note: Im not a gamer) and 2) because she wants her question to show up on some website. I hate to accommodate her, but this is definitely the weirdest interview question Ive ever heard of.
Here is another website, that list some of Microsoft's Interview Questions:
http://halcyon.usc.edu/~kiran/msqs.html
Sunday, February 12, 2006
The 3 ants on a triangle problem.
There are 3 ants at 3 corners of a triangle, they randomly start moving towards another corner. What is the probability that they don't collide?
Now, if I just simply look at the problem, I see that the three ants can simply go clockwise, or counterclockwise together. On the third possibility one ant could go clockwise, another counter clockwise, and the third ant wouldn't matter which way it went. This would be the collision making the answer 2/3, but this is wrong.
So lets take another look at it:
Lets name the ants A, B, C respectively, and to make it easier let 0 represent the ant goes clockwise, and 1 represent the ant goes counter-clockwise. We would end up with these possibilities:
0,0,0 = No Collision
0,0,1 = Collision
0,1,0 = Collision
0,1,1 = Collision
1,0,0 = Collision
1,0,1 = Collision
1,1,0 = Collision
1,1,1 = No Collision
This makes the correct answer of 2/8 = 1/4
Another way of looking at this is via the combinatorics way:
Each of the 3 ants has 2 possibilities, making it 2C1 for each ant. This comes out to 2*2*2 = 8 possibilities, now knowing that there are only 2 good outcomes this makes it 2/8 = 1/4.
Monday, February 06, 2006
Regular Expressions for RegularExpressionValidator
which led to a link with great information http://www.regular-expressions.info/tutorial.html
I know some of the regular expressions from my use in VI in Unix/Linux environments, but I guess a refresher is in order. Here is a basic run down (quickly tutorial) of regular expressions in ASP.Net:
^ - the beginning of the input string
$ - the end of the input string
Note: If you omit these markers, an attacker could affix malicious input to the beginning or end of valid content and bypass your filter.
Note: If you try to represent a string of text with anything by just using ^,$, or ^$ then you will run into trouble if a newline is used
? - represents a variable string that may or may not be included
Example: Will(iam)? would represent my name Will and William
\ - represents the escape sequence from the meta-character.
\b - matches before and/or after an alphanumeric sequence
example: ^\bWilliam\b find the whole word "William" by it self at the beginning.
\B - matches before and/or after that isn't an alphanumeric
More info: http://www.regular-expressions.info/wordboundaries.html
\d - matches a single numeric value.
\D - matches anything that is not a numeric value.
[0-9] - represents one numeric digit
Example: \d\+\d would represent any number+number like 1+1 also the expression [0-9]\+[0-9]
\t - represents the non-printable representation of the tab.
\n - represents the non-printable representation of the line feed.
\r - represents the non-printable representation of the carriage return.
\s - represents a white space (tab, carriage return, etc..)
\S - represents not a white space.
\xHEX_VALUE - represents the hex representation of an ASCII character.
Example: \xA9 represents the copy-right symbol
More Info:http://www.regular-expressions.info/characters.html
* - represents zero or more occurrences
+ - represents one or more occurrences
{min,max} - represents a range of numbers of occurrences
Example: \d{0,} represents one or more numeric values
Example: {1,} is the same as +
[a-z] - represents one lowercase letter
[A-Z] - represents one uppercase letter
Example: ^*[a-zA-Z0-9'.]$ represents a single string of zero or more occurrences of lowercase, uppercase, numeric, single-quote, and/or a dot
Example: [WB]ill represents the word of Will or Bill
[^] - represents the negated
Example: Will[^y] represents any string with Will and some other character(s) as long it isn't y. So Willie and Williy would be ok, but Will and Willy would not be.
| - (veritical line) represents or
Example: Will(iam|ie) represents William or Willie
$number - represents a way referencing a previous string
Example: ([w*])(abc)=$1$2 Will always be true in cases like abc=abc , wabc=wabc , wwabc=wwabc , etc....
Be careful when it comes to using the \ -backslash since it is also used in C#. As an advice use the @ to represent your regular expression string as is, or you would be force to write something like \\\\ to represent \\ the literal backslash in the regular expression. Some additional important info on using Regular Expressions in .Net environments: http://www.regular-expressions.info/dotnet.html
Well I hope these are correct, sometimes the wording might not be as correct as it should, making it ambiguously wrong.
Sunday, February 05, 2006
How To: Use mySql with ASP.net/C#
using System.Data;
using System.Data.Odbc;
Define Global Variables:
private System.Data.Odbc.OdbcConnection OdbcCon;
private System.Data.Odbc.OdbcCommand OdbcCom;
private System.Data.Odbc.OdbcDataReader OdbcDR;
DataReader is a read only access, making communication to the database(s) a lot quicker.
Connection String all on one line:
ConStr = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;PORT=3306;
DATABASE=databasename;UID=username;PWD=password;OPTION=3";
Your Query:
string ComStr = "select * from agent where state ='" + TextBox1.Text + "'";
Make Connection:
OdbcCon = new System.Data.Odbc.OdbcConnection(ConStr);
Make Query:
OdbcCom = new OdbcCommand(ComStr,OdbcCon);
Now do your try block:
try
{
if(OdbcCon.State == ConnectionState.Closed)
{
OdbcCon.Open();
}
OdbcDR = OdbcCom.ExecuteReader();
while(OdbcDR.Read())
{
result.Text = "The results of the query are:";
Label1.Text = "State: "+OdbcDR[0].ToString();
Label2.Text = "Value: "+OdbcDR[1].ToString();
Label3.Text = "Visted: "+OdbcDR[2].ToString()+ " times";
}
}OdbcCon.Close();
}
catch(Exception Ex)
{
// An error occured, give details
string warning = Ex.ToString();
Page.Response.Write(warning);
}
Friday, February 03, 2006
Web Services
Using multiple web services into one page, this concept is known as "mash-up". You might have come across these services recently, for example any website that uses Google's maps combining with another web service. Here is an example:
http://www.mywikimap.com/ of combining Google's map with gas prices in your area.
I personally like the way the future of the internet is going (in this aspect). Before Google Maps and their web service, finding directions was only done with Yahoo Maps and other services. Now we can find directions with gas stations, and food services on the way if necessary.
The following website does a nice defintion of what Web Services are and the other technologies behind the development of web services: http://www.webopedia.com/DidYouKnow/
Computer_Science/2005/web_services.asp
Thursday, February 02, 2006
Start: Development Blog
http://williamandrus.tripod.com/index.htm