Skip to main content

Posts

Showing posts from 2010

JQuery Templates for Visual Studio

I found a good blog on using JQuery Templates. Reposting here so I can find it again easily if I need it. Hopefully it helps anyone else that may find this as well. http://weblogs.asp.net/dwahlin/archive/2010/11/20/reducing-code-by-using-jquery-templates.aspxAdditional infohttp://api.jquery.com/category/plugins/templates.You can download the jQuery Templates script here along with a sample application or reference one of the following Microsoft CDN scripts:http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.jshttp://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js

Generic object TryParse

In my opinion whenever you need to parse a value you should always use the TryParse method to make your code more robust and able to handle errors better. The draw back to this is you and up writing a lot of if else statements. I got tired of doing this so was trying to find a more abstracted way to do this for all my values. I found this bit of code very handy. So far it has worked great! public T GetValue<T>(object obj){if (obj != null) { Type type = typeof(T); T value = default(T); var methodInfo = (from m in type.GetMethods(BindingFlags.Public | BindingFlags.Static)where m.Name == "TryParse" select m).FirstOrDefault();if (methodInfo == null)returndefault(T);object result = methodInfo.Invoke(null, newobject[] { obj, value });if ((result != null) && ((bool)result)) { methodInfo = (from m in type.GetMethods(BindingFlags.Public | BindingFlags.Static)

Hardening the TCP/IP Stack

I had to spend some time today writing a registry file that would harden the TCP/IP stack. I did not want to manually update all the servers so figured I would just set up a registry file to do it for me. Below is the setting you can put in a .reg file to harden the stack. REMINDER : this comes with no warranty and you should always backup your registry before you make any changes.Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TcpIp\Parameters]
"SynAttackProtect"=dword:00000002
"TcpMaxPortsExhausted"=dword:00000001
"TcpMaxHalfOpen"=dword:000001f4
"TcpMaxHalfOpenRetried"=dword:00000190
"TcpMaxConnectResponseRetransmissions"=dword:00000002
"TcpMaxDataRetransmissions"=dword:00000002
"EnablePMTUDiscovery"=dword:00000000
"KeepAliveTime"=dword:000493e0 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\N…