- Cloud Computing
- Non-relational databases
- Next-generation distributed computing
- Web-Oriented Architecture (WOA)
- Mashups
- Open Supply Chains via APIs
- Dynamic Languages
- Social computing
- Crowdsourcing and peer production architectures
- New Application Models
From http://hinchcliffe.org/archive/2009/03/17/16712.aspx
superscan - Ping sweep
nslookup
> Server ipaddress
> Set type=any
> Ls –d target.com
sqlping2
net view /domain - Identify domains on the wire
net view /domain:domain_name - Identify machines in the domain
net use \\10.1.1.20\ipc$ "" /user:"" - Establish null session connection
getmac \\10.1.1.20 - Obtain network transport information
psexec \\10.1.1.20 cmd.exe - Obtain a remote command shell
netmon 3.0
You may want to check the book: Hacking Exposed: Network Security Secrets and Solutions for more detailed tips and information.
Comments Off
A sample of LINQ provider.
using System;
using System.Collections;
namespace LINQSample
{
class Program
{
static void Main(string[] args)
{
var myNumberServer = new MyNumberServer(323, 2);
var query = from a in myNumberServer
where a != 3
select a;
foreach(var item in query)
{
Console.WriteLine(item);
}
}
}
public class MyNumberServer
{
private readonly int _numberToServer;
private readonly int _length;
public MyNumberServer(int init, int length)
{
_numberToServer = init;
_length = length;
}
public IEnumerator GetEnumerator()
{
for (int i = 0; i < _length; i++)
{
yield return _numberToServer;
}
}
}
public static class Extensions
{
public static IEnumerable Where(this MyNumberServer source, Func<int, bool> predicate)
{
foreach (int item in source)
{
if (predicate(item))
{
yield return item;
}
}
}
public static IEnumerable Select(this MyNumberServer source, Func<object, object> selector)
{
foreach (var item in source)
{
yield return selector(item);
}
}
public static IEnumerable Cast(this MyNumberServer source)
{
foreach (var item in source)
{
yield return (int)(item);
}
}
}
}
Note: This is a sample from the book “Essential LINQ”.
IQueryable<T> is the type used in LINQ to SQL queries. IQueryable<T> differs from IEnumerable<T> in that it includes an expression tree. In particular, the type takes the following shape:
public interface IQueryable<T> : IEnumerable<T>, IQueryable, IEnumerable
{
}
The important interface in this declaration is IQueryable:
public interface IQueryable: IEnumerable
{
Type ElementType {get;}
Expression Expression {get;}
IQueryProvider Provider {get;}
}
The key property here is the middle one - Expression. IQueryable<T> implements IEnumerable<T>.
Comments Off
Dynamic reflection is the classic .Net reflection. Now there is a new pattern called “Static Reflection” which is very popular in some open source code like nHibernate. Static Reflection’s main
benefit is “refactoring” friendly. For example, in the following code snippet, if you use the static relfection and change the property name, it won’t break. If you use the string to locate the property, it will break easily.
//Classic Reflection
var entity = new SampleEntity();
entity.SetValue(entity, "Id", 100); //dynamic binding
entity.SetValue(entity, "Name", "Sample");
//Static Relection
var entity1 = new SampleEntity();
entity1.SetValue(e => e.Id, 100); //early binding
entity1.SetValue(e => e.Name, "Sample");
// Static reflections.cs
using System;
using System.Linq.Expressions;
using System.Reflection;
namespace LinqExpressionSample
{
public class SampleEntity
{
public int Id { get; set; }
public string Name { get; set; }
public void SetValue<T>(T entity, string propertyName, object value)
{
PropertyInfo propertyInfo = typeof (T).GetProperty(propertyName);
propertyInfo.SetValue(entity, value, null);
}
}
public static class Extension
{
public static void SetValue<T>(this T entity, Expression<Func<T, object>> expression, object value)
{
MemberExpression memberExpression = GetMemberExpression(expression);
var propertyInfo = memberExpression.Member as PropertyInfo;
propertyInfo.SetValue(entity, value, null);
}
private static MemberExpression GetMemberExpression<T, TValue>(Expression<Func<T, TValue>> expression)
{
if (expression == null)
{
return null;
}
if (expression.Body is MemberExpression)
{
return (MemberExpression)expression.Body;
}
if (expression.Body is UnaryExpression)
{
var operand = ((UnaryExpression)expression.Body).Operand;
if (operand is MemberExpression)
{
return (MemberExpression)operand;
}
if (operand is MethodCallExpression)
{
return ((MethodCallExpression)operand).Object as MemberExpression;
}
}
return null;
}
}
}
Comments Off
If you use WCF to create web services, you need to define your data contracts by using DataContract/DataMember attributes.
Actually you can use them directly for serialization/deserialization in your code. Following is a sample of how to use DataContract/DataMember attributes for fast object Xml serialization and deserialization.
using System.IO;
using System.Runtime.Serialization;
using System.Text;
using System.Xml;
namespace DataContractSerialization
{
class Program
{
static void Main(string[] args)
{
Student student = new Student()
{
Age = 12,
Name = "David"
};
DataContractSerializer dcs = new DataContractSerializer(typeof(Student));
StringBuilder sb = new StringBuilder();
using(XmlWriter writer = XmlWriter.Create(sb))
{
dcs.WriteObject(writer, student);
}
string xml = sb.ToString();
using (XmlTextReader reader = new XmlTextReader(new StringReader(xml)))
{
Student newStudent = (Student) dcs.ReadObject(reader, true);
}
}
}
[DataContract(Namespace="http://www.netinverse.com")]
public class Student
{
[DataMember]
public string Name { get; set; }
[DataMember]
public int Age { get; set; }
}
}
Comments Off
If you have worked with MSI for a while, I bet you have encountered this: You have built and installed an MSI. Later on you change the WiX of it and build the new MSI, when you try to uninstall the old MSI with the new one, the uninstall fails.
In this case, you can
1) Use the utility tool MSIZap to clean up manually.
2) Or, do a force install with the new MSI using msiexec’s Repair Options. After that you can uninstall the MSI and go back to the good state.
msiexec /i /fe your_installer.msi
Repair Options
/f[p|e|c|m|s|o|d|a|u|v]
Repairs a product
p - only if file is missing
o - if file is missing or an older version is installed (default)
e - if file is missing or an equal or older version is installed
d - if file is missing or a different version is installed
c - if file is missing or checksum does not match the calculated value
a - forces all files to be reinstalled
u - all required user-specific registry entries (default)
m - all required computer-specific registry entries (default)
s - all existing shortcuts (default)
v - runs from source and recaches local package
Comments Off
A sample master WiX file has includes:
<Directory Id="BIN" Name="bin">
<?include ..\include\shared.wxi?>
<Component Id="Service.SharedFiles" DiskId="1" Guid="72e3b959-9515-40ba-a095-bf788aa3d617">
<CreateFolder>
<Permission User="Administrators" GenericAll="yes" />
A sample shared.wxi to be included:
<?xml version="1.0"?>
<Include>
<Component Id="Component_1" Guid="58345065-0314-41fd-9992-d960f297ba9a" DiskId="1">
<File Id="File1" Name="Net_~1.dll" LongName="NetInverse.core.dll"
KeyPath="yes" Compressed="yes" src="$(var.COREDIR)\bin\" />
Managed Memory Leak will be reported by an OutOfMemoryException exception thrown by the CLR. There are a few reasons will result in it.
1) Too many objects are alive.
2) Object handle leak. Use !sos.objsize to list handles.
3) Heap fragmentation. Use !sos.dumpheap to get excessive GC Heap fragmentation report.
Comments Off
There are two types of heap corruptions: 1) NT Heap Corruption 2) GC Heap Corruption.
GCSTRESS is a checked or debugging build with some registry keys set used to debug the GC Heap Corruption. It forces the garbage collection to occur very oftern to shake out a bug.