Great resource on the JavaScript Document Object.
http://www.comptechdoc.org/independent/web/cgi/javamanual/javadocument.html
Tuesday, December 14, 2010
JavaScript Document Object
Labels:
document,
events,
javascript,
mouse,
object,
onmousemove,
resource
Thursday, November 18, 2010
C# Directory Security
I wanted to be able to change the permissions of a Folder/File when creating a directory in .NET.
This is pretty simple
This is pretty simple
string name = System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();
FileSystemAccessRule administratorRule = new FileSystemAccessRule(
name,
FileSystemRights.FullControl,
InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
PropagationFlags.None,
AccessControlType.Allow);
DirectorySecurity dirSec = new DirectorySecurity();
dirSec.AddAccessRule(administratorRule);
Directory.CreateDirectory(@"C:\TestDirCreate\", dirSec);
Thursday, November 11, 2010
JavaScipt Template Objects or Object Cloning
After doing a lot of research, I stumbled upon a talk by Nicholas C. Zakas about Scalable Javascript Architecture. Great! Time to learn.
So, Yahoo has developed their own way of doing things. They have created a 'Module' pattern. If you watch the talk, he explains it in more detail. The main idea is that the architecture is, ...well, MODULAR! The problem is that he explains about the pattern without explaining all the parts that make it possible.
Let's start with creating an object that has 'Public' and 'Private' members and variables. You start with making an object:
var _myVar2;
This will give your object private variables that are visible to any instance of the object, but not publicly visible.
Next, we add the functions that we want to the object:
}
So, the key is that in the 'return' block, we add the functions we want to make public. We can give whatever name we want to give, and that is the name with which we can access the function. For instance,
var myNewObj = new MyObj();
myNewObj.SomeFunctionName(); // Will execute func2
We cannot access 'func1'. It is private.
Next, we can look at trying to decouple objects from one another. A main point of the talk was to stress the importance of knowledge of the layers.
The architecture looked something like:
MODULES
SANDBOX
APPLICATION CORE
LIBRARY
The modules should only know that the 'sandbox' exists, and have no knowledge of any other part of the system.
That's great and all, but how do we decouple the Application Core from the modules?
YUI has a built-in 'Clone' function. Yay! Except, I don't want to have to incorporate YUI into my project just to use the clone feature. I happen to use jQuery.
It took me a while to figure out, but I got it with some help from: http://oranlooney.com/functional-javascript/
So, the reason we want to do this is, we want to be able to create module instances inside the AppCore, without the AppCore knowing about the modules directly. We 'register' the modules with the AppCore and use a 'Start' method to start the module from the AppCore.
We don't want the AppCore creating direct instances of these modules. So, the war around that is 'cloning'.
So, we have an object:
Now we want to use this object to create instances as modules in our system. We don't want to directly create them, so we must do:
This creates two instances of the original, without direct knowledge of it.
NOTE: In the original object, you MUST use the pre-fix this, otherwise, if the private variable '_name' is changed, it is changed for all instances. So, any reference to a variable inside that object that you do not want STATIC, you must have 'this.myVar'. If you want it static throughout all instances, use 'myVar'.
So, Yahoo has developed their own way of doing things. They have created a 'Module' pattern. If you watch the talk, he explains it in more detail. The main idea is that the architecture is, ...well, MODULAR! The problem is that he explains about the pattern without explaining all the parts that make it possible.
Let's start with creating an object that has 'Public' and 'Private' members and variables. You start with making an object:
var MyObj = function () {var _myVar1;
var _myVar2;
}
This will give your object private variables that are visible to any instance of the object, but not publicly visible.
Next, we add the functions that we want to the object:
MyObj.prototype = (function() {function func1 () {
}
function func2 () {
}
return {
// DON'T forget the constructor!
constructor: MyObj,
SomeFunctionName: func2
}
})();
So, the key is that in the 'return' block, we add the functions we want to make public. We can give whatever name we want to give, and that is the name with which we can access the function. For instance,
var myNewObj = new MyObj();
myNewObj.SomeFunctionName(); // Will execute func2
We cannot access 'func1'. It is private.
Next, we can look at trying to decouple objects from one another. A main point of the talk was to stress the importance of knowledge of the layers.
The architecture looked something like:
MODULES
SANDBOX
APPLICATION CORE
LIBRARY
The modules should only know that the 'sandbox' exists, and have no knowledge of any other part of the system.
That's great and all, but how do we decouple the Application Core from the modules?
YUI has a built-in 'Clone' function. Yay! Except, I don't want to have to incorporate YUI into my project just to use the clone feature. I happen to use jQuery.
It took me a while to figure out, but I got it with some help from: http://oranlooney.com/functional-javascript/
So, the reason we want to do this is, we want to be able to create module instances inside the AppCore, without the AppCore knowing about the modules directly. We 'register' the modules with the AppCore and use a 'Start' method to start the module from the AppCore.
We don't want the AppCore creating direct instances of these modules. So, the war around that is 'cloning'.
So, we have an object:
var original = function () { var _name; } original.prototype = (function () { function Get() { return this._name; } function Set(name) { this._name = name; } return { constructor: original, Get: Get, Set: Set } })();
Now we want to use this object to create instances as modules in our system. We don't want to directly create them, so we must do:
var obj = new original(); function Clone() { } Clone.prototype = obj; var test1 = new Clone(); test1.Set("Locke"); alert(test1.Get()); var test2 = new Clone(); test2.Set("Shepard"); alert(test2.Get()); alert(test1.Get());
This creates two instances of the original, without direct knowledge of it.
NOTE: In the original object, you MUST use the pre-fix this, otherwise, if the private variable '_name' is changed, it is changed for all instances. So, any reference to a variable inside that object that you do not want STATIC, you must have 'this.myVar'. If you want it static throughout all instances, use 'myVar'.
Monday, November 8, 2010
Thursday, November 4, 2010
JavaScipt Array Concat
So, when you concatenate two arrays in javascript, you shouldn't add the original array to the list of arrays to concatenate, unless you want to exponentially grow the array.
{
var array1 = [ 'John Locke' , 'Jack Shepard' ];
var array2 = [ 'Michael Scott', 'Dwight Schrute'];
var array3 = array1.concat(array2);
}
array3 is === [ 'John Locke' , 'Jack Shepard' , 'Michael Scott' , 'Dwight Schrute'];
{
var array1 = [ 'John Locke' , 'Jack Shepard' ];
var array2 = [ 'Michael Scott', 'Dwight Schrute'];
var array3 = array1.concat(array2);
}
array3 is === [ 'John Locke' , 'Jack Shepard' , 'Michael Scott' , 'Dwight Schrute'];
Thursday, September 23, 2010
C# WPF Grid System
There are multiple "root" elements that you can use when designing a WPF application.
I want to talk about the "Grid" element.
This is pretty useful when you have a 'template' layout. When you know where UI elements are going to be, and/or you are sure that your screen will be resized, you can use the 'Grid' element as your root.
The Grid element is very similar to the Table element in HTML.
A specific question I came across, was "Can I make one row a fixed size, while the other rows grow as the user changes the size of the form?". This was an issue, because as the user changes the size of the form, the Grid cells, grow and shrink with the form.
Yes, you can set a specific row's height or a column's width.
There are 3 different ways you can set the height of a row.
row.Height = new GridLength(...
The three choices are:
Pixel - fixed. The value entered will be the amount of pixels exactly.
Auto - this will make the row the size needed by the content.
Star - takes as much as needed, or the amount in percent.
Just thought this was interesting.
I want to talk about the "Grid" element.
This is pretty useful when you have a 'template' layout. When you know where UI elements are going to be, and/or you are sure that your screen will be resized, you can use the 'Grid' element as your root.
The Grid element is very similar to the Table element in HTML.
A specific question I came across, was "Can I make one row a fixed size, while the other rows grow as the user changes the size of the form?". This was an issue, because as the user changes the size of the form, the Grid cells, grow and shrink with the form.
Yes, you can set a specific row's height or a column's width.
There are 3 different ways you can set the height of a row.
row.Height = new GridLength(...
The three choices are:
Pixel - fixed. The value entered will be the amount of pixels exactly.
Auto - this will make the row the size needed by the content.
Star - takes as much as needed, or the amount in percent.
Just thought this was interesting.
Friday, September 3, 2010
CorFlags, C# and InteropServices.COMException (0x80040154): Class not registered
CorFlags is a Visual Studio command line utility that allows an executable that was compiled as (for instance) 'anycpu' to be run on a machine of a different architecture.
Some applications written in VS and compiled with x86, will not run on Windows 7.
The executable needs to be modified using corflags.
The error that caused me to find this issue is
System.Runtime.InteropServices.COMException (0x80040154): Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
Run this in the VS command line. Navigate to the executable folder.
corflags [path] /32bit
Now, the /32bit tells the .net framework to run this app as a 32 bit application. Other options are available.
Some applications written in VS and compiled with x86, will not run on Windows 7.
The executable needs to be modified using corflags.
The error that caused me to find this issue is
System.Runtime.InteropServices.COMException (0x80040154): Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
Run this in the VS command line. Navigate to the executable folder.
corflags [path] /32bit
Now, the /32bit tells the .net framework to run this app as a 32 bit application. Other options are available.
Thursday, September 2, 2010
No applicable name scope exists to resolve the name, Error. C# WPF
This error can occur when:
A storyboard begins -> myStoryBoard.Begin(myElement); <- and a programatically created element has not been added to a parent yet.
Add 'myElement' to a parent on the form.
A storyboard begins -> myStoryBoard.Begin(myElement); <- and a programatically created element has not been added to a parent yet.
Add 'myElement' to a parent on the form.
Tuesday, August 24, 2010
C# WPF Button Blink Problem
In a WPF application, if a button is clicked, the focus gets put on that button.
Sometimes this will cause the button to constantly blink.
In order to stop the button from blinking, some solutions say to put the 'focus' onto another button.
I think, a cleaner way, is to set the 'Focusable' property to false. This doesn't seem as 'hacky' as setting focus to another button, and still fixes the problem.
Sometimes this will cause the button to constantly blink.
In order to stop the button from blinking, some solutions say to put the 'focus' onto another button.
I think, a cleaner way, is to set the 'Focusable' property to false. This doesn't seem as 'hacky' as setting focus to another button, and still fixes the problem.
Labels:
application,
blink,
blinking,
button click,
C#,
constantly,
problem,
stop,
wpf
Wednesday, August 18, 2010
HTML 5 Canvas
I wanted to put some HTML 5 Canvas stuff down.
Since HTML 5 is not finalized, some of this stuff might change.
There are a few gotchas that you will need to look out for.
HTML 5 is NOT XHTML. This means that XHTML standards don't apply. Attributes do not need quotation marks around values. Element tags do not need to be closed. These things are good ideas, but you do not need them.
CANVAS. Man. So, if you want to [STYLE] a canvas, there are some things you need to look out for.
To set the "WIDTH" and "HEIGHT" you need to set the "WIDTH" and "HEIGHT" attribute, not the "STYLE". For instance, instead of style="width:20px; height: 20px;", you set attributes in the tag; like [ width="20" height="20" ].
Since HTML 5 is not finalized, some of this stuff might change.
There are a few gotchas that you will need to look out for.
HTML 5 is NOT XHTML. This means that XHTML standards don't apply. Attributes do not need quotation marks around values. Element tags do not need to be closed. These things are good ideas, but you do not need them.
CANVAS. Man. So, if you want to [STYLE] a canvas, there are some things you need to look out for.
To set the "WIDTH" and "HEIGHT" you need to set the "WIDTH" and "HEIGHT" attribute, not the "STYLE". For instance, instead of style="width:20px; height: 20px;", you set attributes in the tag; like [ width="20" height="20" ].
Tuesday, August 17, 2010
Javascript Charts
This site is full of javascript chart websites.
http://www.articlediary.com/article/25-graph-chart-solutions-for-web-developers-277.html
Don't know if all are good, but www.highcharts.com is awesome.
http://www.articlediary.com/article/25-graph-chart-solutions-for-web-developers-277.html
Don't know if all are good, but www.highcharts.com is awesome.
Thursday, August 5, 2010
Tuesday, August 3, 2010
C# Forms Stop Redraw/Paint
I've tried to stop the 'Paint' event on a C# WinForm without overriding the 'Paint' event.
I've done some research and found a lot of people have this problem, but those problems can be easily fixed using the 'DoubleBuffered' property found on the form itself. The main problem fixed by 'DoubleBuffered' is that the form flickers.
This is not my problem.
I want to stop the 'Paint' event of a 'TreeView', while I expand all the nodes. This is important when there are many nodes in the tree. If you 'Paint' while expanding, the form becomes unresponsive and ugly.
The only solution that I can come up with, is to 'Hide()' the control, expand the nodes, then 'Show()' the control again. I tried this with the 'Form' itself, but it didn't seem natural. By performing the operation with the control, it's tough to tell if the control is redrawing, or the nodes are just being added.
While this is a 'hacky' solution, I don't know any other way.
BTW: SuspendLayout() => ResumeLayout() doesn't stop the 'Paint' event.
I've done some research and found a lot of people have this problem, but those problems can be easily fixed using the 'DoubleBuffered' property found on the form itself. The main problem fixed by 'DoubleBuffered' is that the form flickers.
This is not my problem.
I want to stop the 'Paint' event of a 'TreeView', while I expand all the nodes. This is important when there are many nodes in the tree. If you 'Paint' while expanding, the form becomes unresponsive and ugly.
The only solution that I can come up with, is to 'Hide()' the control, expand the nodes, then 'Show()' the control again. I tried this with the 'Form' itself, but it didn't seem natural. By performing the operation with the control, it's tough to tell if the control is redrawing, or the nodes are just being added.
While this is a 'hacky' solution, I don't know any other way.
BTW: SuspendLayout() => ResumeLayout() doesn't stop the 'Paint' event.
Wednesday, July 21, 2010
C# Determine the pixel length of a string.
This method will determine the length in pixels of the text.
private float FindLengthString(string text)
{
Font _tagFont = new Font("Sans Serif", 8.25f);
float fWidth = _tagFont.Size;
Graphics g = this.CreateGraphics();
fWidth = g.MeasureString(text, _tagFont).Width;
g.Dispose();
return fWidth;
}
Monday, July 19, 2010
VB 6 COM w/ C# libraries
Ok. As much as I love Visual Basic 6 (sarcasm), I was put on a project to ensure that a vb6 app that used C# COM objects compiled and ran.
1. The C# projects, [I used VS 2008], needs special settings in order to work correctly with Visual Basic 6.
a. Go to the project settings. Go to the Compile tab. Go to Advanced Compile option. Change the target framework to 3.5.
b. Visual Studio 2008 changed the location or rc.exe [If you don't have it, you can install the SDK of the .NET framework]. You have to find it on your computer. In the Compile option, there is a 'Build Events...' button. A dialog box appears, and in this box, in the "Pre-Build event command line:" section, there is logic to find rc.exe. Delete all text. Put in --> "[rc.exe location]" /r "$(ProjectDir)InteropUserControl.rc" Now substitute the rc.exe path for [rc.exe location]. /r and $(Project... is exactly the same for all libraries.
c. In References option, remove the Microsoft.InteropFormTools reference.
Ok. Recompile the project. This must be done on the machine that you are going to develop the vb6 on, otherwise, vb6 won't recognize the library.
2. Regasm is a tool that adds assemblies to the registry. Well, when you compile the *.tlb and *.dll files from .NET, use the Visual Studio command line tool. Navigate to the /Release folder of the desired project. Use the command regasm /regfile [dll file name] [reg output file name]. You must have the regasm path in the Environment Variables on MyComputer properties. Regasm with make a [filename].reg. This will be used in the vb6 app to register the COM objects.
3. The Package and Deployment Wizard for Visual Basic 6 is finicky. I couldn't find where to choose the location of the .NET dlls in the *.reg files. I mean, I wanted to be able to choose where the registry knew where my .NET COM object dll files were located, but I couldn't find that. Therefore, I had to change where my dll files were installed. The .tlb files were installed into the /system32/ folder and the dll files were installed into the /apppath/. I'm sure there is a way to change the directory path, but I didn't spend that long on the project.
I may have forgotten a step, if so, I'll update soon.
Monday, July 12, 2010
C# Prefix Casting vs 'as' Casting
The main difference between the two types of casting is what happens when an error occurs.
Prefix Casting: In prefix casting [ Type myVar = (Type)someVar; ] an error will be thrown and must be caught if someVar is not actually of type 'Type'.
'as' Casting: In as casting [ Type myVar = someVar as Type; ] the cast will return 'null' if someVar is not of type 'Type'.
I've read that 'as' Casting is also about five times faster (5x) than prefix casting. I've run my own tests and found out that it really isn't. Or at least not in loops. I've tried converting both 'string' and 'DateTime' objects to object. Prefix was much faster when adding to a list and sometimes faster when just converting the value to another variable.
Prefix Casting: In prefix casting [ Type myVar = (Type)someVar; ] an error will be thrown and must be caught if someVar is not actually of type 'Type'.
'as' Casting: In as casting [ Type myVar = someVar as Type; ] the cast will return 'null' if someVar is not of type 'Type'.
I've read that 'as' Casting is also about five times faster (5x) than prefix casting. I've run my own tests and found out that it really isn't. Or at least not in loops. I've tried converting both 'string' and 'DateTime' objects to object. Prefix was much faster when adding to a list and sometimes faster when just converting the value to another variable.
Tuesday, June 29, 2010
ASP.NET MVC 500.24 Error
This error occurs because Asp.Net cannot apply a detected setting in Integrated managed pipeline mode.
[validation validateintegratedmodeconfiguration="false"]
In the Web.config add this line of code in the [system.webserver] block.
This will ignore the error.
-------------------------
Also, in IIS web.config, in the system.web element, there is the identity impersonate=true element. Delete.
-------------------------
Also, in IIS web.config, in the system.web element, there is the identity impersonate=true element. Delete.
Thursday, June 24, 2010
DataTable Column Mapping for XML
This article will demonstrate how to determine or set a SYSTEM.DATA.DATATABLE.Column as different XML nodes.
// The user must include into their class:
using System.Data;
// ==========
// To determine if a column is an XML attribute after
// loading data
// --- after loading data into the dataset
// --- and finding the table needed
mytable.Columns[].ColumnMapping == MappingType.;
----> There are 4 types
Attribute
Element
Hidden
SimpleType
Columns.MappingType Gets or Sets the mapping type for the column.
Labels:
column,
columnmapping,
data,
datatable,
element,
hidden,
HTML attributes,
mapping,
mappingtype,
simple,
table,
type,
XML,
xml schema,
xsd
Tuesday, June 22, 2010
MySQL Workbench Foreign Key Restraint
In MySQL Workbench, the user can alter tables. When altering tables, the user can add 'foreign keys' and 'indexes' to tables.
MySQL Workbench will not allow the user to add foreign keys in certain situations, and will not give adequate error messages so the user can fix them.
Some important things to remember when altering a table to add foreign keys in MySQL Workbench.
1.
Both columns must be EXACTLY the same type. If one column is unsigned INT(10), the other must be unsigned INT(10).
2.
Since, MySQL Workbench will make an index of a foreign key, the foreign key MUST BE AN INDEX of the referenced table, otherwise the script will not be successful.
Thursday, June 17, 2010
TypeTester
This is a site to test Fonts side-by-side.
Really helpful.
This shows what types look like on different machines.
Wednesday, June 16, 2010
VB 6 Localization
So, a project came up to where I have to localize a VB6 application in another language.
I needed the resource file tutorial, but it has others. It worked for me.
Tuesday, June 15, 2010
Coding Conventions
C# Friends have a good coding convention layout.
Labels:
C#,
code,
coding conventions,
convention,
friends,
indent,
layout
Tuesday, May 25, 2010
JavaScript Addition
Apparently, IEEE makes standards for JavaScript that make accurate addition difficult.
I haven't found the exact standard, but I'm looking for it.
When you add numbers with decimals, JavaScript will add value.
For instance:
115.04 + 15 = 130.04000000000002
Instead of 130.04
So, I found a work around for this. Use *.toPrecision(##).
toPrecision will allows you to truncate the value.
Labels:
addition,
decimal place,
Error,
javascript,
math,
precision,
to,
toprecision
Tuesday, May 11, 2010
Z-index
There is a CSS property z-index, which lets the developer set the 'stack order' of elements on an HTML page.
Z-index only works with 'positioned' elements, for instance: position: absolute;
Z-index, also, has the greatest number in front of the lowest number.
Z-index only works with 'positioned' elements, for instance: position: absolute;
Z-index, also, has the greatest number in front of the lowest number.
ASP.NET MVC 403 Error
There is an error, when using ASP.NET MVC, that gives you HTTP 403 error.
When, the rest of the MVC site is working, but it cannot access a specific controller, look for a folder named after the controller.
For instance,
If the controller that cannot be accessed is SecurityController, but the rest of the controllers work, look for a folder in the root directory named "Security". ASP.NET MVC tries to access this folder instead of the actual controller.
Wednesday, May 5, 2010
WCF Alternative Config with MEF
This website describes how to use an alternate config file with WCF.
Basically, this is a way to do it, also.
ConfigurationChannelFactory factory = null;
try
{
string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
string configFile = path + @"\FOT.Services.Plugins.RAT.MainServer.dll.config";
ExeConfigurationFileMap configFileMap = new ExeConfigurationFileMap();
configFileMap.ExeConfigFilename = configFile;
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configFileMap, ConfigurationUserLevel.None);
System.ServiceModel.EndpointAddress endPointAddress = new System.ServiceModel.EndpointAddress("net.tcp://" + rigIP + ":8052/SatelliteAuthorizationService");
factory = new ConfigurationChannelFactory("NetTcpBinding_IAuthorizationService", config, endPointAddress);
EventLogger.LogEvent(EventLogger.LogCode.Debug, EventLogger.LogLevel.Trace, id: "877", className: "Moderator", methodName: "CreateWell", eventMessage: "Loaded Config File.");
}
catch (Exception ex)
{
EventLogger.LogEvent(EventLogger.LogCode.Unknown_Error, EventLogger.LogLevel.Error, id: "881", className: "Moderator", methodName: "CreateWell", eventMessage: ex.Message, stackTrace: ex.StackTrace);
}
IAuthorizationService client = factory.CreateChannel();
int error = client.CreateWell(authorizationKey, Convert.ToInt32(wellId), databaseName, productType, productVersion);
Labels:
.NET,
config,
config files,
configuration,
mef,
WCF
Monday, April 19, 2010
Threading the UI in WinForms/WPF
I figured out how to put the UI on a separate thread than the functionality.
This is what you do in the MyForm.cs class. Begin invoke on the Dispatcher.
You must create a DELEGATE -> ClickDelegate and cast the new delegate as that.
Labels:
.NET,
button click,
C#,
Delegate,
graphical user interface,
gui,
separate thread,
threading,
ui,
user interface
Thread Static
A variable or class can be static, but only static to a thread using:
[ThreadStatic] Class Attribute
http://msdn.microsoft.com/en-us/library/system.threadstaticattribute(vs.80).aspx
Thursday, April 15, 2010
One-click download for text file on HTML
To create a one-click download link on a webpage, for a text file that is basically a 'csv' or comma separated values file, put the '*.csv' extension.
.Net MySQL Connector Error
Apparently there is an error that can occur when a MySQL command tries to execute, but the execution takes longer than the default 'CommandTimeout' of 30 seconds.
To fix the problem, change to MySQLCommand.CommandTimeout to something more useful.
Labels:
.NET,
Error,
MySQL,
mysql commands,
mysql connector
MySQL_Upgrade MySQL_Check fix for "column count of mysql.proc is wrong"
from command prompt: (remember to have NO space between '-p' and '[password]')
C:>mysql_check -u [user] -p[password] --repair --all-databases
This will repair your databases. This does not work on InnoDB.
C:>mysql_upgrade -u [user] -p[password] --all-databases
This will upgrade your databases.
This fixes the 'column count of mysql.proc is wrong' error when using MySQL Workbench on a databases that has been created with MySQL Server earlier than 5.2
Monday, April 5, 2010
Netstat
For networking information there are some handy 'Command Prompt' commands.
%> netstat
-a : listening and established ports
-an : all (I think)
-o: all owning processes with each connection
Tuesday, March 30, 2010
Monday, March 29, 2010
C# Event Handlers
I didn't know this but events can cause memory leaks.
This is a blog that shows how C# 4.0 events will not need to be locked. ( didn't know 3.0 events needed to be locked. )
Also, events can cause memory leaks if the Handler is not disposed of. ( myHander = null ).
Labels:
C#,
dispose,
event handler,
events,
memory leak,
memory leaks
Tuesday, March 23, 2010
SQLite to CSV in Python
To begin this mission, I know nothing about Python.
In 20 minutes, I have a sqlite database outputting data to a csv file.
WOW!
import sqlite3
conn = sqlite3.connect('C:/SQLite/db.sql')
curse = conn.cursor()
data = curse.execute('select * from Data where DATETIME([DateTime]) >= DATETIME("2010-03-20 05:00:00") AND DATETIME([DateTime]) <= DATETIME("2010-03-20 15:00:00");')
f = open('output.csv', 'w')
for row in data:
print >> f, row
------
7 lines of code. Awesome.
Wednesday, March 10, 2010
Debugging a Windows Service without installing
Well, first, to install using installutil [myapp.exe], you must put an environment variable in your system. -> InstallUtil.exe is in Microsoft.NET folder.
Visual Studio 2008 will not let you Debug a windows service. In the Project Properties, in the Debug tab, put [some command line argument...like /c for console]. This will send a command line argument to your application.
Surround the
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new MainDataService()
};
ServiceBase.Run(ServicesToRun);
With an
if(commandLineArg == "/c")
{
[code above]
}
This will run your application in Visual Studio
Wednesday, February 24, 2010
MySQL Query Browser Reset Auto Increment
Fairly simple.
Right Click on the table.
Click "Edit Table"
Click "Advanced Options" tab
Set Auto Increment to [last value] + 1.
Monday, February 15, 2010
HTML Horizontal Scroll
There is a simple way to make a 'div' horizontally scrollable.
Use css and have that div's class property:
.myDivsClass
{
overflow: auto;
}
Tuesday, January 26, 2010
Wednesday, January 13, 2010
JavaScript Charting
This is a great 3d javascript chart library
http://dragan.yourtree.org/code/canvas-3d-graph/
http://dragan.yourtree.org/code/canvas-3d-graph/
Tuesday, January 12, 2010
ASP.NET MVC RC 2 Publish problems
So there was a major problem publishing my ASP.NET MVC site.
This Virtual Directory does not allow contents to be listed.
This Virtual Directory does not allow contents to be listed.
This was the error. To fix this, you must
1. Open IIS 6
2. Open the properties for your site
3. Goto Home or Virtual Directory
4. Click Configuration (at the bottom)
5. Insert wildcard for aspnet_isapi.dll
You can find better instructions http://haacked.com/archive/2008/11/26/asp.net-mvc-on-iis-6-walkthrough.aspx
Then, in order to have things like MySQL work, you must put any .dll files in the bin. It won't magically transfer during a publish.
Labels:
ASP.NET,
Directory Contents Error,
MVC,
Publish Error
Tuesday, January 5, 2010
IE Img tag
I.E. doesn't like [input type="image"] inside a link.
It will just loop back to the parent page.
Use ]img] tag.
It will just loop back to the parent page.
Use ]img] tag.
Error: 'b' is null or not an object, MicrosoftAjax.js error
There is an error when using MicrosoftAjax.js library for MVC 2.0.
When using the Ajax helper, Ajax.BeginForm, you can specify a OnSuccess javascript function.
This needs to be used as a callback, meaning that you cannot put ().
So...
OnSuccess="MyFunc()" // error needs to be...
OnSuccess="MyFunc"
When using the Ajax helper, Ajax.BeginForm, you can specify a OnSuccess javascript function.
This needs to be used as a callback, meaning that you cannot put ().
So...
OnSuccess="MyFunc()" // error needs to be...
OnSuccess="MyFunc"
Monday, January 4, 2010
HTML Symbols
Here's a cool website for HTML symbols.
http://www.webdesignerwall.com/tutorials/using-html-symbol-entities/
http://www.webdesignerwall.com/tutorials/using-html-symbol-entities/
Subscribe to:
Posts (Atom)