Monday, July 02, 2012

WCF KnownTypes and ServiceKnownTypes

 

When using a compiler one gets used to polymorphism.

How would you describe polymorphism? Polymorphism for data objects is little more than rearranging and adding data to a form.

I'd say someone invites it over to a party, you have the PartInfo class

public class PartyInfo
{
public string Address { get; set; }
public string Phone { get; set; }
}


Sara, your friend calls you up and informs you about three other parties, however these parties have other information, one has Theme information, another has data about the DJ, and a third includes ages of the people there.

public class PartyDJData : PartyInfo
{
public string DJ { get; set; }
public string PreviousPerformances { get; set; }
public string MusicTypesPlayed { get; set; }
}

public class PartyTheme : PartyInfo
{
public string Theme { get; set; }
public bool IsDressup { get; set; }
public bool IsDiscountForDressup { get; set; }
}

public class PartyAges: PartyInfo
{
int[] Ages { get; set; }
}
You're a very diligent person, and want to write this down.  Say you get a pad and paper, and start writing.
Party1:
Address : Yavne 24
Phone: 5555-FFF
 
Party2:
DJ : Joe Schmoe / Previous : saras bash, MusicTypes = House/ClubTrance.
Address: 123 kressent, drv
Phone: XXX-YYY
 
Party3:
Theme: Angels and demons, IsDressup = yeah, IsDiscountForDressup = yeah
Address = 154 vos str
phone: FFF-YYY
 
Party 4: 
Address : Hilton Hotel on the beach
Ages { 25-35}
Phone : GGG-XXX
 
 
now when you talk to your friend Adam, you tell him
You: “Hey Adam, and got the skinny on the good parties, get a pen!”
Adam: Ok, shoot!
Party1: {Address : Yavne 24, Phone: 5555-FFF}
Adam: ok cool
Party2: {Address: 123 kressent, drv, Phone: XXX-YYY}, oh and the dj is DJ “Joe Schmoe” who has Previously done saras bash he plays House/ClubTrance.
Adam: wait. Whos the DJ at the first party ? 
You: I don’t know
Adam: ok, next?
You: It’s a theme party! Theme: Angels and demons, it’s Dressup not required but you get DiscountForDressup!
Address = 154 vos str, phone: FFF-YYY
Adam: Whos the DJ ?
You: Dunno!
Adam: Is the party on kressent themed too ?
You: goo question, I think not.
Adam: Ok, lets continue with the list, then we can divide forces and fill out the rest of the info.
You: It’s ok theres only one more party, my sister told me about it.
its at Hilton on the beach man! oh and it caters to 25-35 so you will finally find someone to teach you some manners!
Adam:Yeah Whatever, so who’s the DJ ?
You: I dunno.
Adam: DUDE!!!!!!

Play-by-play serialization

so what happened here?
You had all kinds of different party the info data which you listed under the party info DTO.  They all derived from PartyInfo, but are not exactly the same and each have different attributes which Adam is not expecting.

When Adams started talking to you on the phone he could've asked you what kind of data are you gonna give me because than a I need to set up my pad correctly.  To which you might answer a different answer for every week.  Sometimes you had DJ information sometimes you have Theme information. !!  Sometimes you had both !!

Sometimes you had none.

But you're not willing to commit.  Not willing to tell him all the options.  So he has no way of knowing.

Adam expected you to give him the same information and details for every party.  He actually created the party info class and was trying to fill it up, but every time you added more details, and you didn't tell him in advance what kind of options to expect, so all this back and forth was in trying to figure out what to do with the new information and where to stick it in his pad!

What basically happened was he was distraught.
 


The KnownType Attribute


By relaying some information at the very beginning we could have helped Adam make sense of information.


If they would have written

[KnownType(typeof(PartyDJData))]
[KnownType(typeof(PartyTheme))]
[KnownType(typeof(PartyAges))]
public class PartyDataForTonight
{
public IEnumerable< PartyInfo > parties { get; set; }
}


Adam could have tried to figure out the data on his own.


So why can’t you just use Polymophism ?


Well Polymorphism makes more sense when you have a the TYPE of the instance at hand.


sometimes this is not the case.


The Deserializer (Adam) will go over the data and try to understand which PartyInfo you were referring to. For some reason they did not try the “try polymiphism first and if stuck shout” the moved directly to the “shout” part.


if you send a bunch of PartyInfo objects down the wire they will fail in deserialization. what you need to do is add the KnownType to them. his will help with understanding how to deal with them and what to deserialize given the chance.


this will prove to be performance degrading as for every “PossibleType” the deserializer will have to stop, ponder what class to deserialize this too and only then deserialize.


If


next time I’ll talk about ServiceKnown Type.

Tuesday, June 26, 2012

DBS Stuff

 

Files

Located under Files

image

clip_image001

Data: Initial at least 3 GB | Autogrowth, at least 100MB each iteration. Better to use in Megabytes rather than in Percent

Log: Initial size 7GB |Autogrowth at least 100MB each iteration.

FILE GROUPS

Different files, preferably on different machines

Allows tables, and in general SQL objects, to be created in different files

CREATE TABLE [dbo].[Status](
    [StatusId] [smallint] IDENTITY(1,1) NOT NULL,
    [Type] [nchar](50) NOT NULL,
CONSTRAINT [PK_Status] PRIMARY KEY CLUSTERED
(
    [StatusId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

 

Brown is the index Filegroup

Purple is the Table FileGroup

Primary is the default file group when none are created

 

LOG

Use a sequential writing hard disk - such as Raid 0 or Raid 1.

Full – saves everything, incl all bulk inserts (values), is reduced only when db is backed up| used for differential backups.

Bulk – saves almost everything, not including bulk inserts i.e. It only saves the size of the bulk insert without the data itself.

Simple – a cyclical log file that only saves data not yet committed as well as last check points.

DATA

User random access writing hard disk – such as Raid 5

Hebrew

Use collation "HEBREW_CI_AS"

Collation however only works for varchar

In general than adding data in Unicode don't forget to use N'מידע חשוב'! The N stands for Unicode.

SQL DDL

Decimal (Scale, Precision)

Scale – number of digits

Precision – number of digits (of scale) which are decimal.

SQL prefers INT over other types in general.

 

Nchar / Varchar

Nchar – char that is Unicode (not dynamic)

varchar - Variable (dynamic) sized data strings. (Penalty of size of string – 2bytes)

Nvarchar – Dynamic Unicode string (incl the penalty)

Unicode – takes up 2 chars for every char (2X the space)

Misc

Add Indexes to most ForeignKey constraints

DataBase projects

CLR allows to add Dot.NET CLR dlls that can plugin and create new "Functions", that run using Dot.Net engine per row (like any sql function).

To create ->

Visual Studio è New Projectè DataBase è SqlServerè CLR Database project

Service Broker

Like a crippled msmq.

Includes an Event driven DeQueue that can trigger a stored procedure

You can configure Max currents

Is Transactionable {with rollback support }

Tuesday, June 05, 2012

Publish and deploy

For those still looking, I had to make sure to:

  • Specify port 8172, use the default service name (msdeploy.axd), use https and check the box to allow untrusted certificates in the publish service url from Visual Studio:https://serveraddress:8172/msdeploy.axd

Also, I found this IIS article to be extremely helpful for setting up the service.

Pasted from <http://stackoverflow.com/questions/5490478/vs-2010-publish-using-web-deploy>

http://www.microsoftpdc.com/2009/FT56?type=wmvhigh

http://learn.iis.net/page.aspx/516/configure-the-web-deployment-handler/

When faced with :

Web deployment task failed.(Could not complete the request to remote agent URL 'https://dev1:8172/msdeploy.axd?site=Default web site'.)

Could not complete the request to remote agent URL 'https://dev1:8172/msdeploy.axd?site=Default web site'.

The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.The remote certificate is invalid according to the validation procedure.

clip_image001

The Service URL without the http:// defaults to https://

BUT, because Https means Secure, we need a certificate.

However the IIS is not configured with a certificate, so it fails

You need to check the
"Allow untrusted certificate" checkbox

Sunday, April 08, 2012

Web Deployment on IIS7

 

Transforms Web.Config.Release

http://vishaljoshi.blogspot.com/2009/02/web-deployment-with-vs-2010-and-iis.html

 

Install IIS7 Deployment

download Web Platform Installer for IIS7, only way I managed was to install chrome, and then download it.

image YAY microsoft, lock me out and make me install an UNSAFE browser just to do basic admin IT work.

http://technet.microsoft.com/en-us/library/dd569059.aspx

image

image

select custom

image

http://learn.iis.net/page.aspx/1022/how-to-configure-a-site-for-publishing-with-web-deploy/

Web Deploy 2.0 includes a new UI in IIS Manager to configure an IIS site for Web Deploy publishing. This UI serves two purposes:

  1. Sets up file system permissions to enable the Web Deploy publishing service to publish to the site
  2. Generates a publish settings file which can be used in tools like WebMatrix or Visual Studio 2010 to publish to the site without having to enter publishing settings manually

Let's say that we want to grant a local Windows user "JohnDoe" publishing access to the IIS site, contoso.com:

  1. Start IIS Manager by clicking Start > Run and typing "inetmgr.exe"
  2. Connect to the server you want to manage.
  3. Expand the Sites node and right click "contoso.com"
  4. Click Deploy > Configure for Web Deploy Publishing...
  5. The following UI will show - you can simply click "Setup" and the currently logged-in user will be granted Web Deploy publishing permissions.

 

Now try to publish from VS STUDIO 2010

If you get this error Could not load file or assembly bla bla bla one of its dependencies. An attempt was made to load a program with an incorrect format it might be a 32bit/64bit issue

Go to IIS -> Application Pool -> Advance Settings -> Enable 32-bit Assemblies

http://stackoverflow.com/questions/41449/i-get-a-an-attempt-was-made-to-load-a-program-with-an-incorrect-format-error-o

image

 

And now FINALLY

I works

Tuesday, April 03, 2012

Log4Net Configuration trouble

Recently i had some log4net configuration trouble

log4net has a feature in its configuration file where it tries to read Configuration name tags from the config file and locates them as writable properties on the class (Logger/Appender etc..) using reflection.

the function used is

protected void log4net.Repository.Hierarchy.XmlHierarchyConfigurator.SetParameter(XmlElementelement,objecttarget)
this function locates the property for you and updates its data if it finds it if not it fills your screen and logs with garbage until its fixed!
It will even locate the property if you write it in the wrong case.
However, it does not help you in locating your error. I do not expect log4net developers to write a “google-style” {did you mean xxx} function. But I think they could have a better log response
instead of a bland
LogLog.Error(declaringType, "XmlHierarchyConfigurator: Cannot find Property [" + name + "] to set object on [" + target.ToString() + "]");


It would be nicer (I think) to write something like

LogLog.Error(declaringType,
string.Format(
"{2}Reflection did not find Writeable Property/Field named [{0}]. Check ObjectBrowser for class {1} and see what writable attributes/fields exist. maybe misspelled? You XML Error is located in {3}"
, name, target.ToString(), "XmlHierarchyConfigurator", element.ParentNode.InnerXml)
);

which would give something like

XmlHierarchyConfiguratorReflection did not find Writeable Property/Field named [hello]. Check ObjectBrowser for object log4net.Repository.Hierarchy.DefaultLoggerFactory+LoggerImpl and see what writable attributes/fields exist. maybe misspelled? You XML Error is located in <level value=\"Info\" /><hello value=\"4\" /><appender-ref ref=\"LogFileAppender\" /><appender-ref ref=\"RSLogFileAppenderInfo\" /><appender-ref ref=\"RSLogFileAppenderFatal\" />"


for the error of adding the field “hello” to the XML.


This is at the very least a more helpful comment.


At least now I know what to look for. any attribute in log4nt configuration must have a real writeable field/property in the log4net object hierarchy.


good to know.


 


Mickey Perlstein

Preview Pane : Windows 7

 

forgot all about this one

taken from http://www.winvistaclub.com/t81.html

But, if you have a custom file type; and wish to register a plain text or a multimedia preview handler, for this custom file type, you can do so using this utility.

Winhelponline’s PreviewConfig Utility allows you add or remove preview handler for a file type. Its a very useful and a easy-to-use utility. Worth a check-out. Do read its ReadMe file first.

Friday, March 02, 2012

Console write Color Encoder

 

Sometimes I use a console logger, for simple apps.and it’s more important to see the data than the text for a programmer.

I have written a simple Console encoding app that spits color encoded console lines to the console.

I may some day write a log4net logger that does this, but for now:

public static string EncodeConsole(string message
, params object[] args)
{



string content = message;
string pattern = @"{(.*?)}";
MatchCollection mc = Regex.Matches(content, pattern
,RegexOptions.Compiled); //compiled is faster

#region make better Exception that string.format
if (mc.Count > args.Length)
{
string format1 = "you supplied {0} params, but require {1} in the template";
///erro message
string err = string.Format(format1, args.Length, mc.Count);
throw new FormatException( err );
}
#endregion

string encoded = message;
foreach (Match item in mc)
encoded = encoded.Replace(item.Value, ",#,").Replace(",,", ",");

var arr = encoded.Split(',');
string out_ = "";
int matchnum = 0;

for (int i = 0; i < arr.Length; i++)
{
if (arr[i][0] == '#')
{
Console.ForegroundColor = ConsoleColor.White;
Console.BackgroundColor = ConsoleColor.Blue;
var oldmatch = mc[matchnum].Value;
var g = oldmatch.Split(':');

//will always be 0 for data
string match = "{0}";
if (g.Length > 1)
match = "{0:" + g[1];

var data = string.Format(match, args[matchnum]);
arr[i] = data;
matchnum++;
}
else
Console.ResetColor();


Console.Write(arr[i]);
out_ += arr[i];

}
Console.WriteLine("");

return out_;
}



Tuesday, February 14, 2012

Visual Studio TFS very slow

It so happens that in Visual studio, the connection to a TFS server is through a possible proxy server. (A default one)

 

If you VS is slow to take TFS,

go to the

Visual Studio 10.0/Common7/IDE/devenv.exe.config file

go to the bottom

locate <system.net>

and add

    <system.net>
    <defaultProxy enabled="false" />
        <settings>
            <ipv6 enabled="true"/>
        </settings>
    </system.net>
    <appSettings>
        <add key="TestProjectRetargetTo35Allowed" value="true" />
    </appSettings>
</configuration>

this will stop it from looking for your TFS server on the internet

Thursday, December 15, 2011

A Reflective Question

I was recently asked a Question in an interview about Creating a function that can read reflection of certain aspects off a class instance. (some version of debugger … I guess)

anyway, here’s my solution (using recursion of course)

private static string Reflective(string instanceName, Type type, object obj, int depth)
{
StringBuilder sb = new StringBuilder();

string format = "* <{0}> {1}";
for (int i = 0; i <= depth; i++)
format = ("\t") + format;

sb.AppendFormat("\n" + format,
type.Name, instanceName);

if (obj == null)
return sb.ToString()
+ "-> {Null}";

FieldInfo[] fields = type.GetFields();
foreach (FieldInfo fld in fields)
{
format = "<{2}> {0}={1}";
for (int i = 0; i <= depth; i++)
format = ("\t") + format;
if (fld.FieldType.IsPrimitive)
{
string val = (obj==null)? "NULL" : fld.GetValue(obj)+"";
sb.AppendFormat("\n\t" + format,
fld.Name, val, fld.FieldType.Name);
}
else
{
sb.Append(
Reflective(fld.Name, fld.FieldType,
fld.GetValue(obj),
depth+1));
}
}
return sb.ToString();
}
}



How to use



var computer = new Computer
{
CPUs = 4,
Display = null,
AnotherDisp = new Monitor {
Height = 768, Width = 1024, Zoom = 2
}

};


string s = Reflective("computer", computer.GetType(), computer, 0 );
Console.WriteLine(s);



Will print out



* <Computer> computer

        * <Monitor> Display-> {Null}


        <Int32> CPUs=4


        * <Monitor> AnotherDisp


                <Int32> Width=1024


                <Int32> Height=768


                <Int32> Zoom=2


Thursday, December 08, 2011

Android Source Files

 

for some reason, the open-source project Google setup for android with all the Git’s and Repos and stuff is very well mainained but requires a degree in particle physics to understand.

This is especially true, if you’re just trying to look under the hood of android and not interested in joining the project per-say or  uploading stuff of your own to a Git repository.

I come from Windows and am unused to becoming an IT specialist to install and use development software.

looking around different blogs and sites I finally found a likeminded individual interested in spreading the joy of SIMPLE and EASY rather than COMPLEX and REQUIRES HOURS OF UNDERSTANDING to do android things.

I want to develop for android, not be part of a complex Operating System’s development team (at least not for now).

I found a blogger who has likeminded views on the subject.

http://mobilebytes.wordpress.com/2010/06/30/classes-source-for-eclipse/

He has downloaded, stripped, mapped, vm’s and refitted the sources for android classes ready for Eclipse.

I uploaded them to megaupoad as well to lower this bloggers bandwidth problems (in case he pays for them)

and here they are:

Android version source megaupload URL I uploaded it to
1.5 r3 http://www.megaupload.com/?d=OL71VL2F
1.6 r2 http://www.megaupload.com/?d=B5F0R1AV
2.01 r1 http://www.megaupload.com/?d=MIJOHYYI
2.1 r1 http://www.megaupload.com/?d=93048HL0
2.2 froyo http://www.megaupload.com/?d=UJRSNLHN

 

In case you don’t know how to wire this up:

Step 1

Download the source codes into a directory such as c:\android\android-sdk-source\

SNAGHTML498a857

Step 2

1) open eclipse, open a project you wish to view the source of:

 

Right click on android.jar – select image

2) Select properties (last one on the context menu) or press Alt-Enter

3) In the window that comes up, under Java source Attachment select External file, then find the source file you downloaded in my case C:/Android/android-sdk-sources/android-sdk-1.6_r2-src.jar

image

4) click Open on the Windows Folder

5) and OK on the eclipse, and you should be all sourced up.

usage:

Click F3 on an android class such as BroadcastReceiver.class and you will see the source code.

image

Word of warning to the Debuggers out there.

YOUR USE OF ANDROID SOURCES and Versionage does not mean the EMULATOR is using the same version - if your app is for android 1.6 (as most should be) and your emulator is 2.2, the source you should attach is 2.2 as the emulator works under 2.2 and not 1.6

make sense?

Good luck

Mickey Perlstein

Sunday, November 27, 2011

Mobility conference

Today I went to the mobility conference. Here are a few things that I learned:

When developing a mobile app you need to ask yourself a couple of questions:

Stickiness over time - will the user be installing it and forgeting all about it or will she be using it always.

  • stickiness will be created also by using Facebook and twitter and other such posts in social media.
  • viral is very important - word of mouth is much better than buying your users (i.e. Advertising)
      • create value to the user
      • make it social
      • make it enjoyable
      • make it very viral
  • very little apps offered to VCs are life-changing ones
  • lowering the customer acquisition costs - interesting someone else to use it - if the only way I can use it is if you use it -  it helps you use it - and helps me gain new customers.

Respond to every support call

Challenges facing the mobile market:

  • Security on mobile is challenging
  • Discoverability is very hard
  • Revenue streams are shocking
  • new challenges - the mobile market place brings in bouncers - a new phase of rejects from the marketplace/apple/google etc.  adds and other layer of challenges
  • Problems with revenue streams especially when direct to consumer
  • Ad revenue alone is a bad model
  • Different mobile users are of different user types and should be considered accordingly

What is the user experience, what the apps does the user usually use. Do your best to create a single application connected to all the application's the user uses, or unifying them.  Try changing the UIx using the same backend(s). 

The new user paradigm : There is no such thing as the final user - all users are middle users, and will be RE sending an edited version of the data in a new way to someone else – who will again be a middle user recreating and sending it to someone else.  So the data itself needs to be dynamic and available (perma links).

Analytics are very important!!!  Not only in web but even more so in mobile apps.  What's tabs are pressed, how the user uses a system, what gestures are used etc.

The smart phone is not always connected, think not connected systems think synchronization

Real time collaboration - the users are used to real time collaboration with their colleagues, think constant syncing with server think multiple user interface think multiple users.

Platforms: every couple of months and you platform comes out, each platform comes with its own resolution, abilities, controls and OS.

IMG_20111127_150413

Try to think cross-platform: maybe abstraction layers like HTML 5, phonegapp, flex

UIX

  • All female users are righties (except for a small promil)
  • Most male users are righties
  • A lot of male users are colorblind

idea of Cool:

  • Users need to be set in a certain zone
  • There should be a flow to the application - remember when you scroll on the iPhone the scrolling continues even for a bit - even though you've stopped scrolling

The user’s mental image should agree with the user's experience

REACTION   VISUALIZATION
  SIMILAR DIFFERENT
SIMILAR positive nothing/positive
DIFFERENT BAD!!! N/A

if the users visual experience is the same*  and the reaction is similar meaning the same gestures apply the same interaction takes place the user uses the same cognitive abilities to manipulate the screen then to the reaction is a positive one

However, if the users visual experience is the same however the reaction required by the user is different such as scrolling vs.  Gesturing, right clicking vs. long press, gesturing with two fingers vs.  Selecting with a mouse Et cetera, the user's learning curve would be longer, and their overall experience would be bad.

* the screen looks the same on a desktop and on the mobile or on the tablet/pad

Friday, November 04, 2011

QR Codes and Contact information - part 2

Because of Error Correction
you can ad readable text too (not a lot)

QR Codes and Contact information

-- This blog is being written by Microsoft Windows 7 speech recognition software, so if there are some errors I missed, please excuse me.

Today I was reading a LinkedIn article by Lynne, more a blog post actually. I dunno if it's her company or if she works there is this is an advertisement, but still it intrigued me.

http://www.linkedin.com/groupItem?view=&gid=1062177&type=member&item=78767032&commentID=57065334&report%2Esuccess=8ULbKyXO6NDvmoK7o030UNOYGZKrvdhBhypZ_w8EpQrrQI-BBjkmxwkEOwBjLE28YyDIxcyEO7_TA_giuRN#commentID_57065334

Recently I was at a DLD conference where I met someone who had an iPhone 4, she insisted that we connect through WhatsApp so she could send me full contact record that would be installed directly into my phone - including all her numbers, contact information and even a picture.

This got me thinking, I was out of business cards and there were too many people in the conference so Internet was a problem and slow plus the fact that the lot of foreign dignitaries were there and not all of them had Internet. EVERYONE had some form of smartphone (iPhone 3, iPhone 4, android, windows mobile phone, and even some new Nokia phones).

There has to be some kind of method to communicate data between these phones.

vCard doesn't work for android, although it used to work for my old Nokia e71.

Then I saw Lynne’s blog post (above) and decided there must be a better way.

WhatsApp contact transferring is not the solution - but it is the doorway though which I entered the field.

So Googling my way around, I started reading about QR Codes, and found out that their are different identifiers hidden in the text part of the QRCode.

The first one I found was the MATMSG

According to NT DoCoMo Japan, these are the identifiers available:

1. MATMSG: - this will automatically a allow you to open an email, the TO, the Subject and the body as well as your signature can be embedded into QR code. I don't know why one would use this, as it is almost an invasion of privacy for nontechnical people, this would be a nice way of stealing their e-mail address all they need to do is just click enter on their phone and you have their email. But whatever I'm not the cyber police, and I really like the expression

“When you make something idiot proof - they just invent a better idiot”

2. MEBKM - this allows you to install a bookmark in one's browser, the NAME and URL are fields.

3. LAPL – don’t know if this really works, because obviously we're not using NT DoCoMo but it's supposed to start an application according to its ADF key (whatever that is).

4. MECARD - the holy grail.

Allows one to send contact information directly into your contact application. I've tested this on android with success, and I'm about to test this also on other devices soon (hopefully yours)Open-mouthed smile

Contact Grabber

So using any QR Code generator, in the text option, you can add your own contact information. The fields are:

Field Info Comment
N: your Name When a field is divided by a comma (,), the first half is treated as the last name and the second half is treated as the first name.
TEL: your phone number 1 to 24 digits
TEL-AV: your number for Video Calls 1 – 24 digits
EMAIL: your email
ADR: Address The fields divided by commas (,) denote PO box, room number, house number, city, prefecture, zip code and country, in order.
BDAY: your birthday 8 digits consist of the year (4 digits), month (2 digits) and day (2 digits), in order.
URL: your homepage
NICKNAME: Your nickname
NOTE: a note I would probably add something about you as well as the conference. This will help the receiver remember where they met you

Then I found this bad boy http://www.quickmark.com.tw/en/qrcode-datamatrix-generator/?qrmecard

Which is exactly to make a universal contact for your smartphone.

This is My contact info if you want to check and see if it works for you.

111004140850 MECARD:
N:Perlstein,Mickey;
TEL:+972-checktheQRCODE;
EMAIL:pitronot-AT-bigfoot.com;
URL:http\://mperlstein.blogspot.com;NOTE:Server/Client/Mobile Developer and Consultant. I offer unique services in all aspects of your Technical project\, from conceptualization\, through Financial and Strategic Models all the way to Product launch.;;

So create your contact data, save it on your phone’s picture gallery, and let someone scan it off your phone.

YAY for old technology.

Thursday, November 03, 2011

Ruby On Rails

 

I met a guy who seemed to know his stuff at an entrepreneurship (don’t you just hate that word?).  His name is Ori Pekelman (in case you're interested), and he told me about ruby on rails version 3.1.

A few years ago I heard about the Ruby, and I tried it out but I didn't really see the point in it. Another unstructured language is not what we need.

However if Ori says that he can create a whole web site in 5 minutes, maybe it's worth my time to investigate a bit further.

After googling for a bit,I found two sites:

http://Railsforzombies.org which is a really cool site, and http://tryruby.org.

After playing around with Railsforzombies, I come to a couple of conclusions:

1.  dot.net 3.5 lambda methods is taken directly from Ruby.

2.  dot.net 3.5 entities is taken from Ruby’s Rails, even the plural/Singular Classes vs. Tables naming conventions.

3. dot.net 4 MVC is probably taken from Ruby’s Rails as well.

 

I'm disappointed in you Microsoft, I thought you invented something cool.  Turns out you just took something cool and brought it to the masses.

Kudos to you th

Thursday, September 29, 2011

WCF and Large Packets of data : part 2

 

excerpts from http://msdn.microsoft.com/en-us/library/ms789010.aspx

To enable streaming, define the OperationContract appropriately and enable streaming at the transport level.

To stream data

  1. To stream data, the OperationContract for the service must satisfy two requirements:

    1. The parameter that holds the data to be streamed must be the only parameter in the method. For example, if the input message is the one to be streamed, the operation must have exactly one input parameter. Similarly, if the output message is to be streamed, the operation must have either exactly one output parameter or a return value.
    2. At least one of the types of the parameter and return value must be either Stream, Message, or IXmlSerializable.

 

[ServiceContract(Namespace = "http://Microsoft.ServiceModel.Samples")]
public interface IStreamingSample
{
[OperationContract]
Stream GetStream(string data);
[OperationContract]
bool UploadStream(Stream stream);
[OperationContract]
Stream EchoStream(Stream stream);
[OperationContract]
Stream GetReversedStream();

}





GetStream operation receives some buffered input data as a string, which is buffered, and returns a Stream, which is streamed. Conversely



UploadStream takes in a Stream (streamed) and returns a bool (buffered).



EchoStream takes and returns Stream and is an example of an operation whose input and output messages are both streamed.



GetReversedStream takes no inputs and returns a Stream(streamed).



2. Streaming must be enabled on the binding. You set a TransferMode property, which can take one of the following values:




  • Buffered,


  • Streamed, which enables streaming communication in both directions.


  • StreamedRequest, which enables streaming the request only.


  • StreamedResponse, which enables streaming the response only.

Backup Schemes

 

SQL

http://social.msdn.microsoft.com/Forums/en/sqlexpress/thread/5e70a1c9-8495-4c83-8040-897a7c62783e

http://www.sqldbatips.com/displaycode.asp?ID=26

http://expressmaint.codeplex.com/

 

WMI

http://www.vbsed.com/scripts/desktop/restore/scr_317.aspit – restore points

VbsEdit includes all these samples!

Download now! (32-bit version)
version 4.0   -   The evaluation version never expires

Tuesday, September 20, 2011

So my test is on its way

I have been commissioned to write a distributed Backup service system. basically we’re talking about a Server element and multiple Services each polled by the server or polling the server – I have yet to decide that.

Each Service element will be able to backup a server and communicate back to the main Server element about its success or failure.

The server will then commission all the backup up data and get it to the main location.

the server will create a log detailing each services state : success/failure.

In step 2, there will be a GUI

Step 1, Design the Backup service element

 

For Now I have the Service element which I named BackupUtility

It asks a Factory for the right BackupEngine (I called it BackupWorker) and using IBackupWorker I manipulate it.

I Took newkie’s code from code-project (love that site btw) ThreadBase<T>.

He wrote two implementations, and using some knowhow I transformed it into a cancalable version I decided I don’t need, and reverted back. YEAY Sad smile

So now I wrote a class that implements it and adds logging to the start and finish and has some more fun parts. and a Factory to retrieve it. – had a heck of a time with log4net not reading its configuration file. – I wish log4net could just say HEY COUNLDNT FIND CONFIG FILE instead of spewing garbage when in debug mode – ooof

 

Next is the Parser

as the Workers are Threads and run asynchronously, 

As a worker threads are run asynchronously, the log files are also very jumbled up.  I have two options:

1) create two log files

2) parse/ sort the single log file

I’m guessing I’ll go with 1 because I think I wont know how many log files there will be until runtime. and I plan to use some version of DataTable to store my data. <this will also help in part two which is the WCF service and data transfers>

 

I have found a Microsoft Tool called Log Parser, so it’s a dandy

checking it out now

Monday, September 19, 2011

Log4Net Patterns

 

taken from http://logging.apache.org/log4net/release/sdk/log4net.Layout.PatternLayout.html

The recognized conversion pattern names are:

a - Equivalent to appdomain - Used to output the friendly name of the AppDomain where the logging event was generated.

c - Equivalent to logger

C - Equivalent to type

class - Equivalent to type

d - Equivalent to date

enclosed between braces. For example, %date{HH:mm:ss,fff} or %date{dd MMM yyyy HH:mm:ss,fff}. If no date format specifier is given then ISO8601 format is assumed (Iso8601DateFormatter).

For better results it is recommended to use the log4net date formatters. These can be specified using one of the strings "ABSOLUTE", "DATE" and "ISO8601" for specifying AbsoluteTimeDateFormatter, DateTimeDateFormatter and respectively Iso8601DateFormatter. For example, %date{ISO8601} or %date{ABSOLUTE}.

These dedicated date formatters perform significantly better than ToString.

exception - Used to output the exception passed in with the log message.

If an exception object is stored in the logging event it will be rendered into the pattern output with a trailing newline. If there is no exception then nothing will be output and no trailing newline will be appended. It is typical to put a newline before the exception and to have the exception as the last data in the pattern.

F - Equivalent to file Used to output the file name where the logging request was issued.

WARNING Generating caller location information is extremely slow. Its use should be avoided unless execution speed is not an issue.

See the note below on the availability of caller location information.

identity - Used to output the user name for the currently active user (Principal.Identity.Name).

WARNING Generating caller information is extremely slow. Its use should be avoided unless execution speed is not an issue.

l - Equivalent to location

L - Equivalent to line

location

Used to output location information of the caller which generated the logging event.

The location information depends on the CLI implementation but usually consists of the fully qualified name of the calling method followed by the callers source the file name and line number between parentheses.

The location information can be very useful. However, its generation is extremely slow. Its use should be avoided unless execution speed is not an issue.

See the note below on the availability of caller location information.

level - Used to output the level of the logging event.

line - Used to output the line number from where the logging request was issued.

WARNING Generating caller location information is extremely slow. Its use should be avoided unless execution speed is not an issue.

See the note below on the availability of caller location information.

logger - Used to output the logger of the logging event. The logger conversion specifier can be optionally followed by precision specifier, that is a decimal constant in brackets.

If a precision specifier is given, then only the corresponding number of right most components of the logger name will be printed. By default the logger name is printed in full.

For example, for the logger name "a.b.c" the pattern %logger{2} will output "b.c".

m - Equivalent to message

M - Equivalent to method

message - Used to output the application supplied message associated with the logging event.

mdc - The MDC (old name for the ThreadContext.Properties) is now part of the combined event properties. This pattern is supported for compatibility but is equivalent to property.

method - Used to output the method name where the logging request was issued.

WARNING Generating caller location information is extremely slow. Its use should be avoided unless execution speed is not an issue.

See the note below on the availability of caller location information.

n - Equivalent to newline

Outputs the platform dependent line separator character or characters.

This conversion pattern offers the same performance as using non-portable line separator strings such as "\n", or "\r\n". Thus, it is the preferred way of specifying a line separator.

ndc - Used to output the NDC (nested diagnostic context) associated with the thread that generated the logging event.

p - Equivalent to level

P - Equivalent to property

properties - Equivalent to property

property - Used to output the an event specific property. The key to lookup must be specified within braces and directly following the pattern specifier, e.g. %property{user} would include the value from the property that is keyed by the string 'user'. Each property value that is to be included in the log must be specified separately. Properties are added to events by loggers or appenders. By default the log4net:HostName property is set to the name of machine on which the event was originally logged.

If no key is specified, e.g. %property then all the keys and their values are printed in a comma separated list.

The properties of an event are combined from a number of different contexts. These are listed below in the order in which they are searched.

the event properties
The event has Properties that can be set. These properties are specific to this event only.
the thread properties
The Properties that are set on the current thread. These properties are shared by all events logged on this thread.
the global properties
The Properties that are set globally. These properties are shared by all the threads in the AppDomain.

r - Equivalent to timestamp

t - Equivalent to thread

timestamp

Used to output the number of milliseconds elapsed since the start of the application until the creation of the logging event.

thread

Used to output the name of the thread that generated the logging event. Uses the thread number if no name is available.

type

Used to output the fully qualified type name of the caller issuing the logging request. This conversion specifier can be optionally followed by precision specifier, that is a decimal constant in brackets.

If a precision specifier is given, then only the corresponding number of right most components of the class name will be printed. By default the class name is output in fully qualified form.

For example, for the class name "log4net.Layout.PatternLayout", the pattern %type{1} will output "PatternLayout".

WARNING Generating the caller class information is slow. Thus, its use should be avoided unless execution speed is not an issue.

See the note below on the availability of caller location information.

u - Equivalent to identity

username - Used to output the WindowsIdentity for the currently active user.

WARNING Generating caller WindowsIdentity information is extremely slow. Its use should be avoided unless execution speed is not an issue.

utcdate - Used to output the date of the logging event in universal time. The date conversion specifier may be followed by a date format specifier enclosed between braces. For example, %utcdate{HH:mm:ss,fff} or %utcdate{dd MMM yyyy HH:mm:ss,fff}. If no date format specifier is given then ISO8601 format is assumed (Iso8601DateFormatter).

The date format specifier admits the same syntax as the time pattern string of the ToString.

For better results it is recommended to use the log4net date formatters. These can be specified using one of the strings "ABSOLUTE", "DATE" and "ISO8601" for specifying AbsoluteTimeDateFormatter, DateTimeDateFormatter and respectively Iso8601DateFormatter. For example, %utcdate{ISO8601} or %utcdate{ABSOLUTE}.

These dedicated date formatters perform significantly better than ToString.

w - Equivalent to username

x - Equivalent to ndc

X - Equivalent to mdc

% -The sequence %% outputs a single percent sign.

The single letter patterns are deprecated in favor of the longer more descriptive pattern names.

Sunday, September 18, 2011

UPDATED: Getting Log4Net to work with Dot.Net Framework 4.0

 

UPDATED: If you want to write code for Log4Net and you’re using dot.net 4 and it won’t compile do the following

open the src directory and open the log4net.csproj –> update it to dot.net 4

  1. Project Properties :
    1. Application : Target Framework : .Net Framework 4
      image
    2. Build : Conditional compilation symbols: change NET_1_0 to NET_4_0
      image
  2. AssemblyInfo.cs

Line 52: copy the line 52 and 53

and paste it under line 52

change #elseif(NET_1_0) to #elseif(NET_4_0)

and change Framework 1.0 to Framework 4.0

image

3. in References: Delete System.Data, System.Web references and add Reference : System.Data and System.Web from the .NET tab

*this is don’t so they are Framework 4 compatible (before they were Framework 1.1 compatible, which is not good enough for Framework 4.0 I guess.

Now change The SystemInfo CurrentThreadId from the Obsolete GetCurrentThreadId to the new System.Threading.Thread.CurrentThread.ManagedThreadId;

image

 

Next

Some security changes were made in the .NET 4.0 framework. In the AssemblyInfo.cs file of the log4net project, you'll find the following line:
[assembly: System.Security.AllowPartiallyTrustedCallers] –

This is affected by the security changes. Take a look at this page for more details: http://msdn.microsoft.com/en-us/library/system.security.allowpartiallytrustedcallersattribute.aspx.

because it’s bad for dot.net 4 , but not for anything else

add

image

 

Now Build using Release and all should work.

good luck

Wednesday, August 10, 2011

Layout of the Android Main.xml and friends

 

Being a Dot.Net programmer for several years now. It’s kinda hard downgrading back to good old eclipse and eclipse plugins.

 

It’s like watching RHPS at home, it’s the same except for all the bells and whistles. And tell ya the truth, You go to watch the show in the cinema because of the bells an whistles. Actually one would argue that without the bells and whistles throwing crap at each other, shouting APs and playing around with water pistols is damn right stupid – but I digress.

I found this site http://developer.android.com/guide/topics/ui/declaring-layout.html pretty useful to understand most of the technobabble about how to setup the vocab and the naming and stuff.

 

In general, if you want to work WITHIN the framework, you must learn these rules. ELSE? else you’re a regular programmer that fights the framework rather than embracing it and then shouting that M$ is just an evil system that doesn’t allow you to customize….

or in this case I guess it’s be G$$gle’s day in court vs the undisciplined programmers.

It’s kinda hard readjusting to setText vs .Text in properties and all this workaround shit.

too bad google went all NIH on us, and didn’t take a page out of the dot.net handbook.

had the added partial class life would’ve been sooo much simpler. this is like programming in 1995 again using tools designed to fight the good fight rather than tools to just WORK. I’ve half a mind to write my own hack to offer partial classes and point click services to the ADT – but I’m too lazy and underpaid for that. (or as I said before, I have only half a mind).

 

Back to the framework, and excuse my rants

So the layout file will contain a layout type located in the res/layout directory

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
             
android:layout_width="fill_parent"
             
android:layout_height="fill_parent"

             
android:orientation="vertical" >

   
<TextView android:id="@+id/text"
             
android:layout_width="wrap_content"
             
android:layout_height="wrap_content"
             
android:text="Hello, I am a TextView" />
   
<Button android:id="@+id/button"
           
android:layout_width="wrap_content"
           
android:layout_height="wrap_content"
           
android:text="Hello, I am a Button" />
</LinearLayout>


After you've declared your layout, you need to load it.



the default Activity loads a Layout of:




public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
}



I love it how the “main” is itallicized and bolded, soo cute donchathink ?



so how do we write the ID ? we write it using



<Button android:id=”@+id/my_Button” />



this will be created in the R.java respectfully.



on the onCreate() method you can reach the Button using



Button myButton  = (Button) findViewVyId(R.id.my_Button);



HELLO GOOGLE! WAKE UP



Dot.NET solved this is Dot.Net 2.0!



Specifically in ASP.NET. the xml parser the creates on the fly dot.net code? _Default.aspx class that locates the button and makes the connection ?



Why should I be writing automatic and seziphic code instead of programming my app? This is not something a programmer should be dealing with. this is something you should have written into your designer – oof.