Monday, November 30, 2009

how-do-i-know-if-have-rsi-or-carpal-tunnel


About how sometimes we don't pay attention to what our body is saying. I'm still thinking that we are like any other job part, we depend on our hands to work and if we abuse from our body we will pay the price highly.

here's a link to SO over the question.

Wednesday, November 25, 2009

here they are Semantics.

speaking about semantics...heres a short example.

class car {
int wheels = 4;
string engine;
}

car mybike = new car();
mybike.wheels = 2;
mybike.engine = null;

The code is error-free, but is semantically incorrect. It reflects poorly on the programmer





Thursday, November 19, 2009

IIS over Home Basic Windows Vista

I found a guy on the web while i was searching for some sutff who asked this error over windows vista basic. I guess the guy wanted to deploy a website in his machine or some other end-user.
So i thought I would be good to point to wich features the IIS 70 would be enable at:

Depending on which version of Vista you have, install ASP or upgrade to a version which supports IIS.

  • Windows Vista Home Premium Edition
  • Windows Vista Professional Edition
  • Windows Vista Ultimate Edition

Wednesday, November 18, 2009

Adding a value with Insert instead of Add method


Adding a value with Insert instead of Add method, wich gets me to the index, as an first argument
and the text as second argument.


var query = from filtxxxr in db.Entity
where fxxxr.Page == thispage
where fixxxr.Shared || filterUser > 0
orderby fixxxr.id descending
select new
{
id,
Name,
Page,
Shared
};
DropDownList.DataSource = query;
DropDownList.Items.Insert(0,"No Applied Filter");
DropDownList.DataValueField = "id";
DropDownList.DataTextField = "Name";
DropDownList.DataBind();

Tuesday, November 17, 2009

formating a datetimepicker

Some times we want to give a certain format on a datepicker control that we created. here's a quick example

private void picker_Loaded(object sender, RoutedEventArgs e)// the datapicker's load event.
{
this.picker.Text = DateTime.Now.ToString("dd-MMM-yyyy");
}

private void picker_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
{
this.picker.Text = this.picker.SelectedDate.Value.ToString("dd-MMM-yyyy");
}

a quit of a short example

var valueDate = valueDatePicker.SelectedDate.Value.ToString("s");

returns the set with the ISO format (yyyy-mm-dd)




Friday, November 13, 2009

list of Code answers by Scott Hanselman's

I was looking at SO for a few things over linq when it came to my face a questino about and interview to a .net developer.. and then digging a bit into the question I found this list at Scott Hanselman's Blog.. i took a piece of the entry for my quick reference.. but there is a few sections that can be useful. Check it out if you want to see the whole list.

What Great .NET Developers Ought To Know

Everyone who writes code

  • Describe the difference between a Thread and a Process?
  • What is a Windows Service and how does its lifecycle differ from a "standard" EXE?
  • What is the maximum amount of memory any single process on Windows can address? Is this different than the maximum virtual memory for the system? How would this affect a system design?
  • What is the difference between an EXE and a DLL?
  • What is strong-typing versus weak-typing? Which is preferred? Why?
  • Corillian's product is a "Component Container." Name at least 3 component containers that ship now with the Windows Server Family.
  • What is a PID? How is it useful when troubleshooting a system?
  • How many processes can listen on a single TCP/IP port?
  • What is the GAC? What problem does it solve?

Senior Developers/Architects

  • What’s wrong with a line like this? DateTime.Parse(myString);
  • What are PDBs? Where must they be located for debugging to work?
  • What is cyclomatic complexity and why is it important?
  • Write a standard lock() plus “double check” to create a critical section around a variable access.
  • What is FullTrust? Do GAC’ed assemblies have FullTrust?
  • What benefit does your code receive if you decorate it with attributes demanding specific Security permissions?
  • What does this do? gacutil /l | find /i "Corillian"
  • What does this do? sn -t foo.dll
  • What ports must be open for DCOM over a firewall? What is the purpose of Port 135?
  • Contrast OOP and SOA. What are tenets of each?
  • How does the XmlSerializer work? What ACL permissions does a process using it require?
  • Why is catch(Exception) almost always a bad idea?
  • What is the difference between Debug.Write and Trace.Write? When should each be used?
  • What is the difference between a Debug and Release build? Is there a significant speed difference? Why or why not?
  • Does JITting occur per-assembly or per-method? How does this affect the working set?
  • Contrast the use of an abstract base class against an interface?
  • What is the difference between a.Equals(b) and a == b?
  • In the context of a comparison, what is object identity versus object equivalence?
  • How would one do a deep copy in .NET?
  • Explain current thinking around IClonable.
  • What is boxing?
  • Is string a value type or a reference type?
  • What is the significance of the "PropertySpecified" pattern used by the XmlSerializer? What problem does it attempt to solve?
  • Why are out parameters a bad idea in .NET? Are they?
  • Can attributes be placed on specific parameters to a method? Why is this useful?

Thursday, November 12, 2009

ItemDataBound, ItemCommand

Here are some differences between the ItemDataBound and the ItemCommand.



ItemBound is fired when each and every record is binded with the datagrid.
ItemCommand will be fired when the control in datagrid is operated.



The ItemCreated event fires once for every DataWebControlNameItem added to the data Web control. It fires before the DataWebControlNameItem's DataItem property is assigned. The ItemDataBound event also fires once for every DataWebControlNameItem added to the data Web control, but this event fires after the DataWebControlNameItem's DataItem property is assigned. Finally, the ItemCommand event fires whenever the Command event for a Button or LinkButton within the data Web control fires


Wednesday, November 11, 2009

getting done things

public static string GetFilterExpression(int filterId)
{
var db = new UserQuery();
var filter = db.Filters.Single(f => f.Id == filterId);
var filterExpressions = filter.FilterExpressions;
var expressions = new List();
foreach(FilterExpression expr in filterExpressions)
{
expressions.Add(string.Format(expr.Operator.Operation, expr.ColumnName, expr.Value));
}
string logicalOperator = (filter.MatchAll) ? " AND " : " OR ";
return String.Join(logicalOperator, expressions.ToArray());
}

Tuesday, November 10, 2009

Die Mauer ist gefallen



Yesterday was the 20th anniversary of the fall of the wall of Berlin.
I was watching "Good Bye Lenin" a movie who has captured me from it's narrative, a bit pop a few may say but a telling of a change. I wonder how was to live in an enviroment like that. Still more to come for the humanity.

Here is a link I found releted to the activities..


Here is a link from the embassy in my country:





Saturday, November 7, 2009

Controls and differente stuff

i found a few stuff going around in these days.. here are some new stuff to me , from asp.net 2.0 and asp.net 3.5



Hide SideBar of Wizard Control


<asp:Wizard DisplaySideBar="false" >


applying validation group to previous and next button in a wizard control













Friday, November 6, 2009

about how to calculate a checkin -checkout at nights


the solution to the date is like these in the case we just care for the entrance.


Thursday, November 5, 2009

Changes with a list

Inserting from the entity with a list.


foreach(ListItem itemlist in MyListBox.Items)
{
db.MyEntities.InsertOnSubmit(new MyEntity()
{
Id = variableId,
name = itemlist.Value
});
}

with a child:

foreach (ListItem col in SListBox.Items)
{
newentityMaster.Childentity.Add(new Childentity {
FilterId = newfilter.id,
ColumnName = col.Value,

});
}





getting my changes performed (DML, insert, delete, updates).

db.GetChangeSet().Inserts

Visual Studio ShortCuts

Here are some helpful keyboard shortcut keys for Visual Studio 2008. You probably know most, but some you won't know. For instance, did you know that Ctrl+. is the same as Sift+Alt+F10?

Note: Some of the shortcuts won't work in all environment configurations (web, C#, etc).

To use, hold down the control key and hit the key combination. Works on the whole document, a specific line, or a selection of code.

Update References/ Add Using Statement (Ctrl +. or Shift +Alt +F10)
I'm referring to the underline that appears under a variable to perform an action like add a using statement, or refacter a method or class name. Not sure what it's called but I use it all the time. Ex:ClassName

List Members (Ctrl +J or Ctrl +K, L)
Displays the autocomplete list for classes, methods, or properties.

List Parameter Info (Ctrl +Shift +Space or Ctrl +K +P)
Lists the parameters for a method. Use this shortcut when your cursor is inside the parenthesis of a method.

Auto Format (Ctrl +K, D or Ctrl +E, D)
Formats C#, VB, ASPX, Javascript, CSS, XML, XSL, and HTML code according to generally accepted formatting standards for the respective programming language. Makes code look nice and neat.

Quick Watch (Ctrl +Alt +Q)
Highlight some code and hit these shortcut keys to display the Quick Watch dialog.

Comment / Uncomment (Ctrl +K, C / Ctrl +K, U)
Comments or uncomments a block of code. Works with C#, VB, ASPX.

Code Bookmarks
Use these to bookmark a line of code. You can cycle through the bookmarks across any file within a project. Bookmarks come in very handy, try it out.

Set/Unset Bookmark (Ctrl +K, K)
Next Bookmark (Ctrl +K, N)

Surround With (Ctrl +S)
Surrounds a block of code with a code snippet.

Build & Debug Shortcuts
Set/Unset Breakpoint (F9)
Build (F6 or Ctrl +Shift +B)

Start Debugging (F5)

Start Without Debugging (Ctrl +F5)

Stop Debugging (Shift +F5)

Continue (F5)

Step Over (F10)

Step Into (F11)

Step Out (Shift +F11)

Wednesday, November 4, 2009

error on Membership.GetAllUser();

Error calling the method GetAllUser(); this was caused by the fact that i was not having a membership provider for the test application.


listbox.DataSource = Membership.GetAllUsers();









so here's the code snippet used to solve the fact



Monday, November 2, 2009

order by in LINQ (basic example)

I have a table of filters from wich I want to get my last ID inserted , so I thought that I would sort in descending first and get the first element of the list.

Here's how to do a simple task like this.


var firstFilter = db.Filters.OrderByDescending(f => f.id).FirstOrDefault();