You are viewing [info]coyote_code's journal

coyote_code
27 September 2011 @ 08:35 am

Occasionally there are some old applications that do not play well with newer versions of IE 6 at the casino where I work. We are forced to roll things back to IE 6 at times. THis usually happens in the case of machines that are crated from images or cloned, and are often VMs (Virtual Machines). So here is a procedure to help with that problem.

Step 1: Make hidden files and hidden folders visible
  1. Click Start, and then click My Documents.
  2. On the Tools menu, click Folder Options.
  3. Click the View tab.
  4. In the Advanced settings list, under Hidden files and folders, click Show hidden files and folders, and then click OK.
Step 2: Uninstall Internet Explorer 7
  1. Click Start, and then click Run.
  2. In the Open box, type %windir%\ie7\spuninst\spuninst.exe, and then click OK.
  3. Follow the wizard instructions to uninstall Internet Explorer 7.
Step 3: Verify that Internet Explorer 6 is restored
  1. Click Start, and then click Run.
  2. In the Open box, type iexplore. Windows Internet Explorer opens.
  3. On the Help menu, click About Internet Explorer. The About Internet Explorer window opens.
  4. If the Version number begins with 6, you have successfully uninstalled IE 7 and restored Internet Explorer 6.
Technorati Tags: internet explorer,IE,uninstall
 
 
coyote_code
17 November 2010 @ 09:58 am

This is just a note on how and why to use collections rather than arrays. We all know that we should… and we all do… but if you meet someone that needs a bit of prodding then here’s just the poker to poke him with, from MSDN:


Collections as an Alternative to Arrays

Visual Studio 2005 - Other Versions

Although collections are most often used for working with the Object Data Type, you can use a collection to work with any data type. In some circumstances, it can be more efficient to store items in a collection than in an array.

If you need to change the size of an array, you must use the ReDim Statement (Visual Basic). When you do this, Visual Basic creates a new array and releases the previous array for disposal. This takes execution time. Therefore, if the number of items you are working with changes frequently, or you cannot predict the maximum number of items you need, you might obtain better performance using a collection.

A collection, which does not have to create a new object or copy existing elements, can handle resizing in less execution time than an array, which has to use ReDim. But if the size does not change, or changes only rarely, an array is likely to be more efficient. As always, performance is highly dependent on the individual application. It is often worth your time to try both an array and a collection.

Specialized Collections

The .NET Framework also provides a variety of classes, interfaces, and structures for general and special collections. The System.Collections and System.Collections.Specialized namespaces contain definitions and implementations that include dictionaries, lists, queues, and stacks. The System.Collections.Generic namespace provides many of these in generic versions, which take one or more type arguments.

If your collection is to hold elements of only one specific data type, a generic collection has the advantage of enforcing type safety. For more information on generics, see Generic Types in Visual Basic.

Example

The following example uses the .NET Framework generic class System.Collections.Generic.List to create a list collection of customer structures.

 

' Define the structure for a customer.
Public Structure customer
    Public name As String
    ' Insert code for other members of customer structure.
End Structure
' Create a module-level collection that can hold 200 elements.
Public custFile As New List(Of customer)(200) 
' Add a specified customer to the collection.
Private Sub addNewCustomer(ByVal newCust As customer)
    ' Insert code to perform validity check on newCust.
    custFile.Add(newCust)
End Sub
' Display the list of customers in the Debug window.
Private Sub printCustomers()
    For Each cust As customer In custFile
        Debug.WriteLine(cust)
    Next cust
End Sub


The declaration of the custFile collection specifies that it can contain elements only of type customer. It also provides for an initial capacity of 200 elements. The procedure addNewCustomer checks the new element for validity and then adds it to the collection. The procedure printCustomers uses a For Each loop to traverse the collection and display its elements.



See Also



Tasks

How to: Declare an Array Variable


How to: Create an Array


How to: Initialize an Array Variable


Troubleshooting Arrays

Reference

ReDim Statement (Visual Basic)

Concepts

Collections in Visual Basic


Generic Types in Visual Basic

Other Resources

Arrays in Visual Basic
 
 
coyote_code
02 November 2010 @ 10:50 am

I don’t think that I have used Telnet in 3 or 4 years but today I needed it. Off to command window and found… no Telnet!

Well… there is a way to enable good old Telnet. Remember that Telnet isn’t very secure which is why it was turned off I’m guessing.

  1. Start
  2. Control Panel
  3. Programs And Features
  4. Turn Windows features on or off
  5. Check Telnet Client
  6. Hit OK

After that you can start Telnet via Command Prompt. Such awesomeness !

 
 
coyote_code
10 December 2009 @ 10:54 am

I recently had to do some importing of text files (a published DTD) into an Excel spreadsheet. As much as we would like it to import cleanly it doesn’t ! So I needed to create a couple of macros in Excel to clean things up.

Macro1 – Concatenate (aka konKat)

This macro, to which I randomly assigned a shortcut key of Ctrl+r, will add a hard return (for multiple rows in a cell) plus the contents of the cell to the right of the selected cell. Then will delete the cell to the right of the currently selected cell shifting the remaining cells to the left. This allows appending multiple cell contents to the current cell with each press of the shortcut key.

Sub konKat()
'
' konKat Macro
'
' Keyboard Shortcut: Ctrl+r
'
    irow = Selection.Row
    icol = Selection.Column
    
    sTmp = ActiveSheet.Cells(irow, icol + 1)
    ActiveSheet.Cells(irow, icol) = ActiveSheet.Cells(irow, icol) & Chr(10) & sTmp
    ActiveSheet.Cells(irow, icol + 1).Delete shift:=xlToLeft
    
End Sub



Macro2 – Add Hard Return (aka addRet)



This macro just cleans up the contents of the some of the cells that had commas, spaces, etc. within them from the import. It’s mostly just an example of using the .replace method on the current cell.



Sub addRet()
'
' addRet Macro
'
' Keyboard Shortcut: Ctrl+w
'
    ActiveCell.Replace What:=",", Replacement:=Chr(10)
    ActiveCell.Replace What:="(", Replacement:=""
    ActiveCell.Replace What:=")", Replacement:=""
    ActiveCell.Replace What:=" ", Replacement:=""

End Sub



Yeah, simple stuff. But it’s some quick and dirty examples that can be used as is, or incorporated into larger works.

 
 
coyote_code
01 December 2009 @ 11:45 am

The following is pretty basic Information, but worth it.

Often in code there is a need for a flag that alternates between two values, something that you might consider a true / false flag. The easy way for this is to use a –1 / +1 pair. Then to alternate it simply requires (example in VisualBasic):

dim iFlag as integer
dim iCnt as integer

iFlag = 1

for iCnt = 1 to 10
    iFlag = -iFlag
loop


This will flip the value from 1 to –1 to 1 to –1 etc...



Sometimes we need to alternate between 0 and 1 instead. This is especially true if the values have already been determined by prior programming or intrinsic functions or values.



in VB this will work:



dim iFlag as integer
dim iCnt as integer

iFlag = 1

for iCnt = 1 to 10
    iFlag = (iFlag + 1) mod 2
Loop



the same thing in JavaScript":



var iFlag = 0;
//
iFlag = (iFlag + 1) % 2;
//



This has an added advantage of working for tri-state or as many states as you want. Change the divisor to 3 and get 0,1,2,0,1,2… for example




 
 
coyote_code
09 September 2009 @ 09:58 am

And I thought our company had a bad time with states (see the link inside the article)

But this state selector is possibly the grand prize winner of all time.

PS: if you don’t want to look at HTML and Javascript code then don’t bother with the link above.

 
 
coyote_code
11 August 2009 @ 03:29 pm

If I did.. I’d probably get fired

I work for a company that creates a web based application. Part of the total package faces only our client (the other part is for the world at large) and because of history and some old legacy bits and pieces we make the statement that “you must use Internet Explorer” for the client facing part. That means that it should be tested and developed only for IE, right? Yup. I’ve even heard The Big Boss say “If I hear the excuse from developers ‘well, it works in FireFox’ one more time I will demand they only use IE for developing.”

So, enough background on that. The next bit is that a new major release of the software is now out in live after passing the alpha and beta tests. One of the things that I did in one section of code was put something in the header of a table. This header, aka ‘table summary’ is never seen except for one condition set. The conditions are this:

  1. Must be using FireFox (remember this is something that we are not supposed to do and don’t support)
  2. Must right mouse click on the table and select ‘properties’

Ok, only a couple steps… but regardless of the browser how often do you right click on a table and then select ‘properties’ yeah about that often is what I thought.

So I was cute and put the word ‘yipee’ in that summary. Apparently the testing department didn’t like that. They created a bug report, with all the attendant overhead and what not. This was to fix something that was not at all evil or a bug, just because they don’t like cute. They probably don’t like puppies either! I tried to explain that there are much funnier things in other products but they wouldn’t accept that, not in our product! Anyway the clip from the bug task is: 

That’s where I hit the dilemma. Sometimes testing insists that they have the final say on wording and such. That means they will send back a report that will say something like “Please make the third word read ‘Fish’ and make sure it is capitalized.” So… do they really want me to chage it so that when you use the wrong browser and then look at properties for a table, it pops up a window that says “something professional?” I’d be glad to do that if they really want it.

 
 
coyote_code
09 July 2009 @ 09:49 am

The following is ripped from “Schneier On Security

Last month, IBM made some pretty brash claims about homomorphic encryption and the future of security. I hate to be the one to throw cold water on the whole thing -- as cool as the new discovery is -- but it's important to separate the theoretical from the practical.

Homomorphic cryptosystems are ones where mathematical operations on the ciphertext have regular effects on the plaintext. A normal symmetric cipher -- DES, AES, or whatever -- is not homomorphic. Assume you have a plaintext P, and you encrypt it with AES to get a corresponding ciphertext C. If you multiply that ciphertext by 2, and then decrypt 2C, you get random gibberish instead of P. If you got something else, like 2P, that would imply some pretty strong nonrandomness properties of AES and no one would trust its security.

The RSA algorithm is different. Encrypt P to get C, multiply C by 2, and then decrypt 2C -- and you get 2P. That's a homomorphism: perform some mathematical operation to the ciphertext, and that operation is reflected in the plaintext. The RSA algorithm is homomorphic with respect to multiplication, something that has to be taken into account when evaluating the security of a security system that uses RSA.

This isn't anything new. RSA's homomorphism was known in the 1970s, and other algorithms that are homomorphic with respect to addition have been known since the 1980s. But what has eluded cryptographers is a fully homomorphic cryptosystem: one that is homomorphic under both addition and multiplication and yet still secure. And that's what IBM researcher Craig Gentry has discovered.

This is a bigger deal than might appear at first glance. Any computation can be expressed as a Boolean circuit: a series of additions and multiplications. Your computer consists of a zillion Boolean circuits, and you can run programs to do anything on your computer. This algorithm means you can perform arbitrary computations on homomorphically encrypted data. More concretely: if you encrypt data in a fully homomorphic cryptosystem, you can ship that encrypted data to an untrusted person and that person can perform arbitrary computations on that data without being able to decrypt the data itself. Imagine what that would mean for cloud computing, or any outsourcing infrastructure: you no longer have to trust the outsourcer with the data.

Unfortunately -- you knew that was coming, right? -- Gentry’s scheme is completely impractical. It uses something called an ideal lattice as the basis for the encryption scheme, and both the size of the ciphertext and the complexity of the encryption and decryption operations grow enormously with the number of operations you need to perform on the ciphertext -- and that number needs to be fixed in advance. And converting a computer program, even a simple one, into a Boolean circuit requires an enormous number of operations. These aren't impracticalities that can be solved with some clever optimization techniques and a few turns of Moore's Law; this is an inherent limitation in the algorithm. In one article, Gentry estimates that performing a Google search with encrypted keywords -- a perfectly reasonable simple application of this algorithm -- would increase the amount of computing time by about a trillion. Moore’s law calculates that it would be 40 years before that homomorphic search would be as efficient as a search today, and I think he’s being optimistic with even this most simple of examples.

Despite this, IBM’s PR machine has been in overdrive about the discovery. Its press release makes it sound like this new homomorphic scheme is going to rewrite the business of computing: not just cloud computing, but "enabling filters to identify spam, even in encrypted email, or protection information contained in electronic medical records." Maybe someday, but not in my lifetime.

This is not to take anything away anything from Gentry or his discovery. Visions of a fully homomorphic cryptosystem have been dancing in cryptographers' heads for thirty years. I never expected to see one. It will be years before a sufficient number of cryptographers examine the algorithm that we can have any confidence that the scheme is secure, but -- practicality be damned -- this is an amazing piece of work.

LiveJournal Tags: ,,
 
 
coyote_code
19 May 2009 @ 10:30 am

More like an aconym – but what ever …

I work in a daze computer software. To get a little closer to what the company wants and needs we review our designed pages in multiple browsers… just to get a handle on the compatibility. So after getting tired of saying “yes, looks fine in Chrome, and Safari… ok good in Opera and FireFox and IE too..” I have created one new word that can normally be used in a two word phrase to indicate that things are good all over.

IFOCS – which may be pronounced as “Eye-Fox"” and stands for Internet Explorer, FireFox, Opera, Chrome, and Safari.

So the statement can be made that it is “IFOCS compatible.”

 
 
coyote_code
11 February 2009 @ 10:58 am

We have a page that uses a number of Ajax functions to load the main body, some drop downs, etc. This page is called from the previous page which ‘may’ add new items into one of the dropdowns.

We noticed that if the end page was accessed then the browser went to the previous page, adding something to the list and then returning to the end page that the dropdownlist was not refreshing with the new list !

Of course, this would only happen in the IE browser (IE 7 in this case). No other browser seemed to have this problem. For the list to refresh it was required to actually close the browser, or end the browser session.

It appears that IE would never run that Ajax code (even though it should run on the server and even though this is on a secure site. Nope, it would just dump out the old dropdown list. I even check this by forcing the code to put out something different and odd in the dropdown and it would not appear in the IE session.

Solution? Very simple and should be part of every Ajax asp code, just put the following ASP at the start of your code:

<%
response.Expires = -1  'prevents caching for IE in particular
%>