<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-13014608</id><updated>2026-03-10T03:55:19.944-07:00</updated><category term="CAB"/><category term="Events"/><category term="SCSF"/><category term="About Face"/><category term="Ajax"/><category term="Caching Application Block Instrumentation Performance Monitor PerfMon"/><category term="ClickOnce"/><category term="Egypt"/><category term="Enterprise Library"/><category term="EventTopic"/><category term="Reactive Extensions RX C#"/><category term="Technology"/><category term="VAB"/><category term="Vacation"/><category term="WCF Security https authorization authentication"/><category term="cross domain problem"/><category term="exceptions"/><category term="first post"/><category term="fortify TFS integration Build"/><category term="forward"/><category term="global"/><category term="gmail"/><category term="hajj haj الحج"/><category term="handling"/><category term="hotmail"/><category term="iphone"/><category term="load balance"/><category term="multible subscribers"/><category term="multithreading"/><category term="network"/><category term="nlb"/><category term="sharepoint error"/><category term="tfs2008 vss migration"/><category term="unhandled"/><category term="visualizer"/><title type='text'>Ayman</title><subtitle type='html'>Senior software engineer with C#, and DevOps experience, ASP.Net, Html5, Jquery and SQL. Proven skills in business process re-engineering, producing architectural artifacts, designing high quality business and technical solutions, database modeling; applying best practices and manage implementations on site.&#xa;</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://aliayman.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://aliayman.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Ayman Ali</name><uri>http://www.blogger.com/profile/04089520193997921426</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKvUKAMsijXeg19hAydX5kYx8jhwScaIJfKaek8nf0MQ7XRt6oJG70KDPbzhHw2IrHn0n4ZkSh98tNQyU25tEDAgr-dg0evqF3NQarfEvLxEPubltwW6jbETKlCRVkjw/s220/Pic314.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>47</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-13014608.post-8654451972301075132</id><published>2018-01-12T16:05:00.001-08:00</published><updated>2018-01-16T19:39:53.360-08:00</updated><title type='text'>JWT Sample Code</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;u&gt;Json Web Token.&lt;/u&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
Looks like Json Web Tokens or simply JWT is having a lot of popularity that Microsoft released a library to encrypt and decrypt those tokens.&lt;br /&gt;
&lt;br /&gt;
In order to generate a JWT token you should install this nuget package&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
System.IdentityModel.Tokens.Jwt&lt;/div&gt;
&lt;br /&gt;
Then you can generate tokens that contain information like CompanyId, UserName or even password as follows&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;font-size: xx-small;&quot;&gt;private&amp;nbsp; string Secret = &quot;db3OIsj+BXE9NZDy0t8W3TcNekrF+2d/1sFnWG4HnV8TZY30iTOdtVWJG8abWvB1GlOgJuQZdcF2Luqm/hccMw==&quot;;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;font-size: x-small;&quot;&gt;public&amp;nbsp; string GenerateToken()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // var hmac = new HMACSHA256();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //Secret = Convert.ToBase64String(hmac.Key);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var sKey = Convert.FromBase64String(Secret);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var tHandler = new JwtSecurityTokenHandler();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var tDesc = new SecurityTokenDescriptor&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Subject = new ClaimsIdentity(new[]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; new Claim(&quot;companycode&quot;, &quot;companycode&quot;),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; new Claim(&quot;username&quot;, &quot;username&quot;),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; new Claim(&quot;password&quot;, &quot;password&quot;),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; new Claim(&quot;companyid&quot;, &quot;25&quot;),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Expires = DateTime.UtcNow.AddMinutes(45),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(sKey),SecurityAlgorithms.HmacSha256Signature),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Issuer = &quot;HajOnSoft.com&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; };&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var stoken = tHandler.CreateToken(tDesc);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return&amp;nbsp; tHandler.WriteToken(stoken);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
In the generate token method, you can add claims to pass parameters as you please.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To get a specific value from the token you can call a method like this&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public&amp;nbsp; int GetCompanyId(string token)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; try&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var tokenHandler = new JwtSecurityTokenHandler();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var jwtToken = tokenHandler.ReadToken(token) as JwtSecurityToken;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (jwtToken == null)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return -1;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var symmetricKey = Convert.FromBase64String(Secret);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var validationParameters = new TokenValidationParameters()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RequireExpirationTime = true,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ValidateIssuer = false,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ValidateAudience = false,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; IssuerSigningKey = new SymmetricSecurityKey(symmetricKey)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; };&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SecurityToken securityToken;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var principal = tokenHandler.ValidateToken(token, validationParameters, out securityToken);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var myClaim = jwtToken.Claims.FirstOrDefault(x =&amp;gt; x.Type == &quot;companyid&quot;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (myClaim != null)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return int.Parse(myClaim.Value);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return -1;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; catch (Exception ex)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return -1;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
for more information visit&lt;br /&gt;
&lt;a href=&quot;http://techcerberus.blogspot.com/2017/03/jwt-in-aspnet-web-api-and-mvc.html&quot;&gt;http://techcerberus.blogspot.com/2017/03/jwt-in-aspnet-web-api-and-mvc.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aliayman.blogspot.com/feeds/8654451972301075132/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/13014608/8654451972301075132' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/8654451972301075132'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/8654451972301075132'/><link rel='alternate' type='text/html' href='http://aliayman.blogspot.com/2018/01/jwt-sample-code.html' title='JWT Sample Code'/><author><name>Ayman Ali</name><uri>http://www.blogger.com/profile/04089520193997921426</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKvUKAMsijXeg19hAydX5kYx8jhwScaIJfKaek8nf0MQ7XRt6oJG70KDPbzhHw2IrHn0n4ZkSh98tNQyU25tEDAgr-dg0evqF3NQarfEvLxEPubltwW6jbETKlCRVkjw/s220/Pic314.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13014608.post-3049855795678702946</id><published>2017-12-17T19:31:00.003-08:00</published><updated>2017-12-17T19:31:32.749-08:00</updated><title type='text'>On MicroServices</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Microservices is Service Oriented Architecture done well. It is based on creating small services (micro-sized) that are focussed on a business domain and are small enough to be called Micro. Every microservice service should be doing one thing (one thing only) and doing it very well. should be light weight and technology agnostic and communicate via something like http REST, each service should own its own database and be independently changeable and deployable. Every transaction will most likely be completed by many services and because there are many services there should be a way to monitor them.&lt;br /&gt;
&lt;br /&gt;
Every Microservice should be &lt;b&gt;Coherent&lt;/b&gt;&amp;nbsp;and that means it is focussed on doing one thing, it should not change because another service is changing or a new column in some database is being added. That means when adding new functionality you should add a new micros service. &lt;span style=&quot;color: #222222; font-family: arial, sans-serif; font-size: x-small;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;You micorservice should have only one reason to change.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;Autonomous&lt;/b&gt;,&amp;nbsp;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: #222222; font-family: arial, sans-serif; font-size: x-small;&quot;&gt;Should be independent and own its contracts, independently developed. should probably respond right away via asynchronous&amp;nbsp;patterns, you should also look into Message Queue, RabbitMQ and ATOM.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: arial, sans-serif; font-size: x-small;&quot;&gt;&lt;b&gt;Observable, &lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: #222222; font-family: arial, sans-serif; font-size: x-small;&quot;&gt;You should have a central monitoring System to know what services are operational now and what is their individual health status. monitor exceptions, centralized&amp;nbsp;logging, maintain correlation ID, etc.. there are many software solutions&amp;nbsp;that provide this out of the box already like Azure Service fabric. basically every service should be able to register itself so that other services can discover it is up and running. &lt;b&gt;Resilient&lt;/b&gt;, Services should also be able to fail gracefully and provide&amp;nbsp;default values when they are not operational.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: #222222; font-family: arial, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: #222222; font-family: arial, sans-serif; font-size: x-small;&quot;&gt;You may however provide an API gateway for all clients as an entry point for all Microservices. the API gateway can perform some common tasks like authentication and then relay to the specific&amp;nbsp;microservice.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: #222222; font-family: arial, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: #222222; font-family: arial, sans-serif; font-size: x-small;&quot;&gt;Every microservice should own its own database, for shared data you can create a separate microservice for static or shared data but should not provide a single monolithic service for all system wide CRUD operations since it will continuously&amp;nbsp;change which is against the first princible which is cohesion.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aliayman.blogspot.com/feeds/3049855795678702946/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/13014608/3049855795678702946' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/3049855795678702946'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/3049855795678702946'/><link rel='alternate' type='text/html' href='http://aliayman.blogspot.com/2017/12/on-microservices.html' title='On MicroServices'/><author><name>Ayman Ali</name><uri>http://www.blogger.com/profile/04089520193997921426</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKvUKAMsijXeg19hAydX5kYx8jhwScaIJfKaek8nf0MQ7XRt6oJG70KDPbzhHw2IrHn0n4ZkSh98tNQyU25tEDAgr-dg0evqF3NQarfEvLxEPubltwW6jbETKlCRVkjw/s220/Pic314.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13014608.post-6588592383732327720</id><published>2017-11-27T19:18:00.004-08:00</published><updated>2017-11-27T19:18:30.701-08:00</updated><title type='text'>Tree traversal</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
If you will be asked in an interview to traverse a tree most likely it will not be depth first or breadth first but rather it will be a special traversal. You will be given a hierarchical table with ID&#39;s and parent ID&#39;s like the following table for instance.&lt;br /&gt;
The table below indicate that the first two nodes has no parent for instance, and then few nodes are under one of them and so on.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;margin: 0 auto; text-align: center; width: 50%;&quot;&gt;
&lt;table style=&quot;text-align: left;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span style=&quot;background-color: yellow;&quot;&gt;ID
&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span style=&quot;background-color: yellow;&quot;&gt;ParentId&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span style=&quot;background-color: yellow;&quot;&gt;Name&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span style=&quot;background-color: yellow;&quot;&gt;5
&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span style=&quot;background-color: yellow;&quot;&gt;null&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span style=&quot;background-color: yellow;&quot;&gt;Grandfather&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span style=&quot;background-color: yellow;&quot;&gt;8
&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span style=&quot;background-color: yellow;&quot;&gt;null&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span style=&quot;background-color: yellow;&quot;&gt;Grandmother&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span style=&quot;background-color: yellow;&quot;&gt;7
&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span style=&quot;background-color: yellow;&quot;&gt;5&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span style=&quot;background-color: yellow;&quot;&gt;son 1&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span style=&quot;background-color: yellow;&quot;&gt;4
&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span style=&quot;background-color: yellow;&quot;&gt;5&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span style=&quot;background-color: yellow;&quot;&gt;daughter&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span style=&quot;background-color: yellow;&quot;&gt;2
&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span style=&quot;background-color: yellow;&quot;&gt;5&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span style=&quot;background-color: yellow;&quot;&gt;son 2&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span style=&quot;background-color: yellow;&quot;&gt;3
&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span style=&quot;background-color: yellow;&quot;&gt;7&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span style=&quot;background-color: yellow;&quot;&gt;grandchild&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;br /&gt;
and then you will be asked to print the above nodes as follows&lt;br /&gt;
-Grandfather&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; -Son 1&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; -Grandchild&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; -daughter&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; -Son 2&lt;br /&gt;
-Grandmother&lt;br /&gt;
&lt;br /&gt;
Here is the solution with explanation&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; &lt;/span&gt;Program&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;{&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;void&lt;/span&gt; Main(&lt;span class=&quot;s1&quot;&gt;string&lt;/span&gt;[] args)&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;{&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;var&lt;/span&gt; n = MakeModel();&lt;span class=&quot;s3&quot;&gt;// Make the model &lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;PrintNode(n, &lt;span class=&quot;s1&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;s4&quot;&gt;Customer&lt;/span&gt;{ID = -1, ParentId = &lt;span class=&quot;s1&quot;&gt;null&lt;/span&gt;, Name = &lt;span class=&quot;s5&quot;&gt;&quot;-1&quot;&lt;/span&gt;}, -1);&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;s3&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //Pass one node that can combine the root nodes under it&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s4&quot;&gt;Console&lt;/span&gt;.ReadKey();&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;}&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;void&lt;/span&gt; PrintNode(&lt;span class=&quot;s4&quot;&gt;List&lt;/span&gt;&amp;lt;&lt;span class=&quot;s4&quot;&gt;Customer&lt;/span&gt;&amp;gt; nodes, &lt;span class=&quot;s4&quot;&gt;Customer&lt;/span&gt; n, &lt;span class=&quot;s1&quot;&gt;int&lt;/span&gt; dept)&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;{&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s3&quot;&gt;//Algorithm&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p4&quot;&gt;
&lt;span class=&quot;s2&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//When readhing a node, immediately print it&lt;/div&gt;
&lt;div class=&quot;p4&quot;&gt;
&lt;span class=&quot;s2&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//Get all children for the current node and recursively call the same method passing a child node at a time&lt;/div&gt;
&lt;div class=&quot;p4&quot;&gt;
&lt;span class=&quot;s2&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//each time you go one level deeper increase a the depth variable that maintaines&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;p4&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //how deep in the tree you are now&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;if&lt;/span&gt; (dept &amp;gt;= 0) &lt;span class=&quot;s4&quot;&gt;Console&lt;/span&gt;.WriteLine( &lt;span class=&quot;s1&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;s4&quot;&gt;String&lt;/span&gt;(&lt;span class=&quot;s5&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;s6&quot;&gt;\t&lt;/span&gt;&lt;span class=&quot;s5&quot;&gt;&#39;&lt;/span&gt;, dept) + &lt;span class=&quot;s5&quot;&gt;&quot;-&quot;&lt;/span&gt; +&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &lt;/span&gt;n.Name);&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;var&lt;/span&gt; children = nodes.Where(x =&amp;gt; x.ParentId == n.ID).ToList();&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;foreach&lt;/span&gt; (&lt;span class=&quot;s1&quot;&gt;var&lt;/span&gt; child &lt;span class=&quot;s1&quot;&gt;in&lt;/span&gt; children)&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;PrintNode(nodes, child, dept + 1);&lt;/div&gt;
&lt;div class=&quot;p4&quot;&gt;
&lt;span class=&quot;s2&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//Code here will execute on the way back&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;}&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;s4&quot;&gt;List&lt;/span&gt;&amp;lt;&lt;span class=&quot;s4&quot;&gt;Customer&lt;/span&gt;&amp;gt; MakeModel()&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;{&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;var&lt;/span&gt; output = &lt;span class=&quot;s1&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;s4&quot;&gt;List&lt;/span&gt;&amp;lt;&lt;span class=&quot;s4&quot;&gt;Customer&lt;/span&gt;&amp;gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;{&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;s4&quot;&gt;Customer&lt;/span&gt; {ID = 5, ParentId = -1, Name = &lt;span class=&quot;s5&quot;&gt;&quot;Grandfather&quot;&lt;/span&gt;},&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;s4&quot;&gt;Customer&lt;/span&gt; {ID = 8, ParentId = -1, Name = &lt;span class=&quot;s5&quot;&gt;&quot;Grandmother&quot;&lt;/span&gt;},&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;s4&quot;&gt;Customer&lt;/span&gt; {ID = 7, ParentId = 5, Name = &lt;span class=&quot;s5&quot;&gt;&quot;Son 1&quot;&lt;/span&gt;},&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;s4&quot;&gt;Customer&lt;/span&gt; {ID = 4, ParentId = 5, Name = &lt;span class=&quot;s5&quot;&gt;&quot;daughter&quot;&lt;/span&gt;},&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;s4&quot;&gt;Customer&lt;/span&gt; {ID = 2, ParentId = 5, Name = &lt;span class=&quot;s5&quot;&gt;&quot;Son 2&quot;&lt;/span&gt;},&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;s4&quot;&gt;Customer&lt;/span&gt; {ID = 3, ParentId = 7, Name = &lt;span class=&quot;s5&quot;&gt;&quot;Grandchild&quot;&lt;/span&gt;}&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;};&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;return&lt;/span&gt; output;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;}&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;}&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;p5&quot;&gt;
&lt;span class=&quot;s2&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;public&lt;span class=&quot;s2&quot;&gt; &lt;/span&gt;class&lt;span class=&quot;s2&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s4&quot;&gt;Customer&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;{&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;int&lt;/span&gt; ID { &lt;span class=&quot;s1&quot;&gt;get&lt;/span&gt;; &lt;span class=&quot;s1&quot;&gt;set&lt;/span&gt;; }&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;int&lt;/span&gt;? ParentId { &lt;span class=&quot;s1&quot;&gt;get&lt;/span&gt;; &lt;span class=&quot;s1&quot;&gt;set&lt;/span&gt;; }&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;string&lt;/span&gt; Name { &lt;span class=&quot;s1&quot;&gt;get&lt;/span&gt;; &lt;span class=&quot;s1&quot;&gt;set&lt;/span&gt;; }&lt;/div&gt;
&lt;style type=&quot;text/css&quot;&gt;
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Consolas; color: #33a2bd}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Consolas}
p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Consolas; min-height: 11.0px}
p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Consolas; color: #008f00}
p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Consolas; color: #0433ff}
span.s1 {color: #0433ff}
span.s2 {color: #000000}
span.s3 {color: #008f00}
span.s4 {color: #33a2bd}
span.s5 {color: #b4261a}
span.s6 {color: #ff2f91}
&lt;/style&gt;















































&lt;br /&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;}&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aliayman.blogspot.com/feeds/6588592383732327720/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/13014608/6588592383732327720' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/6588592383732327720'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/6588592383732327720'/><link rel='alternate' type='text/html' href='http://aliayman.blogspot.com/2017/11/tree-traversal.html' title='Tree traversal'/><author><name>Ayman Ali</name><uri>http://www.blogger.com/profile/04089520193997921426</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKvUKAMsijXeg19hAydX5kYx8jhwScaIJfKaek8nf0MQ7XRt6oJG70KDPbzhHw2IrHn0n4ZkSh98tNQyU25tEDAgr-dg0evqF3NQarfEvLxEPubltwW6jbETKlCRVkjw/s220/Pic314.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13014608.post-3807316734723640415</id><published>2017-11-01T22:26:00.000-07:00</published><updated>2017-11-01T22:26:01.217-07:00</updated><title type='text'>Merge two sorted arrays</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;p1&quot;&gt;
//Given two sorted integer arrays A and B, merge B into A as one sorted array.&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//example 1346789&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;35689 &lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;var&lt;/span&gt; arr1 = &lt;span class=&quot;s2&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;s3&quot;&gt;List&lt;/span&gt;&amp;lt;&lt;span class=&quot;s2&quot;&gt;int&lt;/span&gt;&amp;gt; { 4,5 };&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;var&lt;/span&gt; arr2 = &lt;span class=&quot;s2&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;s3&quot;&gt;List&lt;/span&gt;&amp;lt;&lt;span class=&quot;s2&quot;&gt;int&lt;/span&gt;&amp;gt; { 1,2,3 };&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//Loop length of arr1 - start 0 untill end of array - p = index&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//Optimization use shortest array&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//Pick element at p, compare it with all elements in arr2 - Loop Arr2 start from last point examined&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//if arr1 Element &amp;lt;= arr2 element and &amp;lt; arr2&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//insert arr1 element left of arr2 element, otherwise keep going&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;var&lt;/span&gt; r2 = arr2.Count;&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;s2&quot;&gt;int&lt;/span&gt; p = 0; p &amp;lt; arr1.Count; p++)&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;{&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;s2&quot;&gt;int&lt;/span&gt; j = 0; j &amp;lt; r2; j++)&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;{&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;if&lt;/span&gt; (arr1[p] &amp;lt;= arr2[j])&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;{&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;arr2.Insert(j, arr1[p]);&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;r2 = arr2.Count;&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;break&lt;/span&gt;;&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;}&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt; (j == r2-1) &lt;/span&gt;//Last item in arr2 and loop did not break above&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;{&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;arr2.Add(arr1[1]);&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;r2 = arr2.Count;&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;}&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;}&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;style type=&quot;text/css&quot;&gt;
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Consolas; color: #008f00}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Consolas; min-height: 11.0px}
p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Consolas}
span.s1 {color: #000000}
span.s2 {color: #0433ff}
span.s3 {color: #33a2bd}
&lt;/style&gt;

































&lt;br /&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;}&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aliayman.blogspot.com/feeds/3807316734723640415/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/13014608/3807316734723640415' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/3807316734723640415'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/3807316734723640415'/><link rel='alternate' type='text/html' href='http://aliayman.blogspot.com/2017/11/merge-two-sorted-arrays.html' title='Merge two sorted arrays'/><author><name>Ayman Ali</name><uri>http://www.blogger.com/profile/04089520193997921426</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKvUKAMsijXeg19hAydX5kYx8jhwScaIJfKaek8nf0MQ7XRt6oJG70KDPbzhHw2IrHn0n4ZkSh98tNQyU25tEDAgr-dg0evqF3NQarfEvLxEPubltwW6jbETKlCRVkjw/s220/Pic314.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13014608.post-5330059518742430613</id><published>2017-11-01T14:37:00.001-07:00</published><updated>2017-11-01T14:37:28.396-07:00</updated><title type='text'>Insertion Sort</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt; arr = &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s3&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;gt; { 5,6,1,2,3,1 };&lt;/span&gt;// input.ToCharArray().Cast&amp;lt;int&amp;gt;().ToList();&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//Loop length of array - start from second position&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//Compare pointer to previous item&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//make smaller to the left untill you reach the beginning of the array&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;var&lt;/span&gt; currentItem = 0;&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;s2&quot;&gt;int&lt;/span&gt; p = 1; p &amp;lt; arr.Count; p++)&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;{&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;currentItem = arr[p];&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//Loop from current p position to beginning of array - pointing at location of comparison with current item and potential location of currentItem&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//If currentItem is smaller then swap&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;s2&quot;&gt;int&lt;/span&gt; i = p - 1 ; i &amp;gt;= 0; i--)&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;{&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;if&lt;/span&gt; (currentItem &amp;lt; arr[i])&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;{&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;var&lt;/span&gt; temp = arr[i];&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;arr[i] = currentItem;&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;arr[i+1] = temp;&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;}&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;else&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;{&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;break&lt;/span&gt;;&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;}&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;}&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;}&lt;/div&gt;
&lt;style type=&quot;text/css&quot;&gt;
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Consolas; color: #008f00}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Consolas; min-height: 11.0px}
p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Consolas}
span.s1 {color: #000000}
span.s2 {color: #0433ff}
span.s3 {color: #33a2bd}
&lt;/style&gt;





























&lt;br /&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aliayman.blogspot.com/feeds/5330059518742430613/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/13014608/5330059518742430613' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/5330059518742430613'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/5330059518742430613'/><link rel='alternate' type='text/html' href='http://aliayman.blogspot.com/2017/11/insertion-sort.html' title='Insertion Sort'/><author><name>Ayman Ali</name><uri>http://www.blogger.com/profile/04089520193997921426</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKvUKAMsijXeg19hAydX5kYx8jhwScaIJfKaek8nf0MQ7XRt6oJG70KDPbzhHw2IrHn0n4ZkSh98tNQyU25tEDAgr-dg0evqF3NQarfEvLxEPubltwW6jbETKlCRVkjw/s220/Pic314.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13014608.post-7549935667457046058</id><published>2017-10-31T21:47:00.001-07:00</published><updated>2017-10-31T21:47:42.023-07:00</updated><title type='text'>Find Peak</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//given a number of characters find the peak character which is the current that is repeated the most, there can be more than one character at the peak if the number of repeatition tie&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;var&lt;/span&gt; input = &lt;span class=&quot;s3&quot;&gt;&quot;abbabacdexxxxxxdx&quot;&lt;/span&gt;; &lt;span class=&quot;s4&quot;&gt;//return x&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;var&lt;/span&gt; arr = input.ToCharArray();&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;arr = arr.OrderBy(x=&amp;gt; x).ToArray(); &lt;/span&gt;//order the list to know when to stop counting occurence&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//Initialize result container&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;var&lt;/span&gt; result = &lt;span class=&quot;s2&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;s5&quot;&gt;List&lt;/span&gt;&amp;lt;&lt;span class=&quot;s2&quot;&gt;char&lt;/span&gt;&amp;gt;();&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//Loop length of array - pointing to index from left p = 0&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;var&lt;/span&gt; currentMax = 0;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;var&lt;/span&gt; prevChar = arr[0];&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;var&lt;/span&gt; r = 0;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;s2&quot;&gt;int&lt;/span&gt; p = 0; p &amp;lt; arr.Length ; p++)&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;{&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;if&lt;/span&gt; (arr[p] == prevChar)&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;{&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;r++;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;}&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;else&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;{&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;if&lt;/span&gt; (r &amp;gt; currentMax)&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;{&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;result = &lt;span class=&quot;s2&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;s5&quot;&gt;List&lt;/span&gt;&amp;lt;&lt;span class=&quot;s2&quot;&gt;char&lt;/span&gt;&amp;gt; { arr[p - 1] };&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;}&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;if&lt;/span&gt; (r == currentMax)&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;{&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;result.Add(arr[p - 1]);&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;}&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;currentMax = r;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;prevChar = arr[p];&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;r = 1;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;}&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;}&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//Keep previous character&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//Compare arr[p] to previous&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//Equal count repeatition r of a&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//not equal stop counting repeatition and compare to max if less than max discard&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//If equal to max append to peak&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//if less than discard&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//greater than max&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//discard output collected previously and initialize it only with this character&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;if&lt;/span&gt; (r &amp;gt; currentMax)&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;{&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;result = &lt;span class=&quot;s2&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;s5&quot;&gt;List&lt;/span&gt;&amp;lt;&lt;span class=&quot;s2&quot;&gt;char&lt;/span&gt;&amp;gt; { arr.Last() };&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;}&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;if&lt;/span&gt; (r == currentMax)&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;{&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;result.Add(arr.Last());&lt;/div&gt;
&lt;style type=&quot;text/css&quot;&gt;
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Consolas; color: #008f00}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Consolas}
p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Consolas; min-height: 11.0px}
span.s1 {color: #000000}
span.s2 {color: #0433ff}
span.s3 {color: #b4261a}
span.s4 {color: #008f00}
span.s5 {color: #33a2bd}
&lt;/style&gt;

















































&lt;br /&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;}&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aliayman.blogspot.com/feeds/7549935667457046058/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/13014608/7549935667457046058' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/7549935667457046058'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/7549935667457046058'/><link rel='alternate' type='text/html' href='http://aliayman.blogspot.com/2017/10/find-peak.html' title='Find Peak'/><author><name>Ayman Ali</name><uri>http://www.blogger.com/profile/04089520193997921426</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKvUKAMsijXeg19hAydX5kYx8jhwScaIJfKaek8nf0MQ7XRt6oJG70KDPbzhHw2IrHn0n4ZkSh98tNQyU25tEDAgr-dg0evqF3NQarfEvLxEPubltwW6jbETKlCRVkjw/s220/Pic314.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13014608.post-1670920881732921362</id><published>2017-10-31T17:35:00.005-07:00</published><updated>2017-10-31T17:35:53.481-07:00</updated><title type='text'>Reverse string without its special characters</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Special characters need to stay in place while the entire string is reversed&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;//Reverse string without moving any special character from its place&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;var&lt;/span&gt; input = &lt;span class=&quot;s3&quot;&gt;&quot;ab$cde#x&quot;&lt;/span&gt;; &lt;span class=&quot;s4&quot;&gt;//&quot;xe$cdb#a&quot;;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;var&lt;/span&gt; arr = input.ToCharArray();&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;var&lt;/span&gt; h = -1;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;var&lt;/span&gt; t = -1;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//Loop - half length of the array with pointer index of array from left&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;s2&quot;&gt;int&lt;/span&gt; p = 0; p &amp;lt; arr.Length/2; p++)&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;{&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//Find non special character from left&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;if&lt;/span&gt; (&lt;span class=&quot;s5&quot;&gt;Regex&lt;/span&gt;.IsMatch(arr[p].ToString(),&lt;span class=&quot;s3&quot;&gt;&quot;[a-z]&quot;&lt;/span&gt;) &amp;amp;&amp;amp; h &amp;lt; 0) &lt;span class=&quot;s4&quot;&gt;//non special character&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;h = p;&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//Find non special chracter from right&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;if&lt;/span&gt; (&lt;span class=&quot;s5&quot;&gt;Regex&lt;/span&gt;.IsMatch(arr[arr.Length - p - 1].ToString(), &lt;span class=&quot;s3&quot;&gt;&quot;[a-z]&quot;&lt;/span&gt;) &amp;amp;&amp;amp; t &amp;lt; 0) &lt;span class=&quot;s4&quot;&gt;//non special character&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;t = arr.Length - p - 1;&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//If holding two non special chracters then swap them&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt; (h &amp;gt;= 0 &amp;amp;&amp;amp; t &amp;gt;= 0) &lt;/span&gt;//Non special chracters both directions&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;{&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s4&quot;&gt;//Swap&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;var&lt;/span&gt; temp = arr[h];&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;arr[h] = arr[t];&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;arr[t] = temp;&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;h = -1;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;t = -1;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;}&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;style type=&quot;text/css&quot;&gt;
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Consolas; color: #008f00}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Consolas}
p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Consolas; min-height: 11.0px}
span.s1 {color: #000000}
span.s2 {color: #0433ff}
span.s3 {color: #b4261a}
span.s4 {color: #008f00}
span.s5 {color: #33a2bd}
&lt;/style&gt;



































&lt;br /&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;}&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aliayman.blogspot.com/feeds/1670920881732921362/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/13014608/1670920881732921362' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/1670920881732921362'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/1670920881732921362'/><link rel='alternate' type='text/html' href='http://aliayman.blogspot.com/2017/10/reverse-string-without-its-special.html' title='Reverse string without its special characters'/><author><name>Ayman Ali</name><uri>http://www.blogger.com/profile/04089520193997921426</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKvUKAMsijXeg19hAydX5kYx8jhwScaIJfKaek8nf0MQ7XRt6oJG70KDPbzhHw2IrHn0n4ZkSh98tNQyU25tEDAgr-dg0evqF3NQarfEvLxEPubltwW6jbETKlCRVkjw/s220/Pic314.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13014608.post-6357756045766620004</id><published>2017-10-31T14:39:00.000-07:00</published><updated>2017-10-31T14:39:51.826-07:00</updated><title type='text'>Rotate Array</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: 17px; line-height: 1.5; margin-bottom: 1.25em; padding: 0px; text-rendering: optimizeLegibility;&quot;&gt;
Rotate an array of n elements to the right by k steps.&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: 17px; line-height: 1.5; margin-bottom: 1.25em; padding: 0px; text-rendering: optimizeLegibility;&quot;&gt;
For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4]. How many different ways do you know to solve this problem?&lt;/div&gt;
&lt;br /&gt;
Using LINQ&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;var&lt;/span&gt; arr = &lt;span class=&quot;s1&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;List&lt;/span&gt;&amp;lt;&lt;span class=&quot;s1&quot;&gt;int&lt;/span&gt;&amp;gt; { 1, 2, 3, 4, 5, 6, 7 };&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;s3&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//Rorate array to the right&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;var&lt;/span&gt; k = 10 % 7;&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;s3&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//should move to the beginnning&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;var&lt;/span&gt; output = arr.Skip(arr.Count - k).ToList();&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;output.AddRange(arr.Take(arr.Count - k));&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;style type=&quot;text/css&quot;&gt;
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Consolas}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Consolas; color: #008f00}
p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Consolas; min-height: 11.0px}
span.s1 {color: #0433ff}
span.s2 {color: #33a2bd}
span.s3 {color: #000000}
&lt;/style&gt;










&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;Console&lt;/span&gt;.ReadLine();&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
Using Add Method&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;var&lt;/span&gt; arr = &lt;span class=&quot;s1&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;List&lt;/span&gt;&amp;lt;&lt;span class=&quot;s1&quot;&gt;int&lt;/span&gt;&amp;gt; { 1, 2, 3, 4, 5, 6, 7 };&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;s3&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//Rorate array to the right&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;var&lt;/span&gt; k = 10 % 7;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;s3&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//Move the head of the array to the tail number of times = k&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;s1&quot;&gt;int&lt;/span&gt; i = 0; i &amp;lt; arr.Count - k; i++)&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;{&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;arr.Add(arr[0]);&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;arr.RemoveAt(0);&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;




&lt;style type=&quot;text/css&quot;&gt;
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Consolas}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Consolas; color: #008f00}
span.s1 {color: #0433ff}
span.s2 {color: #33a2bd}
span.s3 {color: #000000}
&lt;/style&gt;










&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;}&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
Using Insert&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;var&lt;/span&gt; arr = &lt;span class=&quot;s1&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;List&lt;/span&gt;&amp;lt;&lt;span class=&quot;s1&quot;&gt;int&lt;/span&gt;&amp;gt; { 1, 2, 3, 4, 5, 6, 7 };&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;s3&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//Rorate array to the right&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;var&lt;/span&gt; k = 10 % 7;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;s3&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//Move the head of the array to the tail number of times = k&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;s1&quot;&gt;int&lt;/span&gt; i = 0; i &amp;lt; k; i++)&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;{&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;arr.Insert(0, arr.Last());&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;arr.RemoveAt(arr.Count -1);&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;




&lt;style type=&quot;text/css&quot;&gt;
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Consolas}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Consolas; color: #008f00}
span.s1 {color: #0433ff}
span.s2 {color: #33a2bd}
span.s3 {color: #000000}
&lt;/style&gt;










&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;}&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aliayman.blogspot.com/feeds/6357756045766620004/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/13014608/6357756045766620004' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/6357756045766620004'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/6357756045766620004'/><link rel='alternate' type='text/html' href='http://aliayman.blogspot.com/2017/10/rotate-array.html' title='Rotate Array'/><author><name>Ayman Ali</name><uri>http://www.blogger.com/profile/04089520193997921426</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKvUKAMsijXeg19hAydX5kYx8jhwScaIJfKaek8nf0MQ7XRt6oJG70KDPbzhHw2IrHn0n4ZkSh98tNQyU25tEDAgr-dg0evqF3NQarfEvLxEPubltwW6jbETKlCRVkjw/s220/Pic314.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13014608.post-2774210738854219298</id><published>2017-10-31T00:22:00.000-07:00</published><updated>2017-10-31T00:22:57.584-07:00</updated><title type='text'>Reverse Words in a string</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: 17px; line-height: 1.5; margin-bottom: 1.25em; padding: 0px; text-rendering: optimizeLegibility;&quot;&gt;
Given an input string, reverse the string word by word. A word is defined as a sequence of non-space characters.&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: 17px; line-height: 1.5; margin-bottom: 1.25em; padding: 0px; text-rendering: optimizeLegibility;&quot;&gt;
The input string does not contain leading or trailing spaces and the words are always separated by a single space.&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: 17px; line-height: 1.5; margin-bottom: 1.25em; padding: 0px; text-rendering: optimizeLegibility;&quot;&gt;
For example,&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;Given s = &quot;the sky is blue&quot;,&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;return &quot;blue is sky the&quot;.&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: 17px;&quot;&gt;Could you do it in-place without allocating extra space?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;Allocating Extra space for output&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;var&lt;/span&gt; input = &lt;span class=&quot;s2&quot;&gt;&quot;ayman ali&quot;&lt;/span&gt;;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;input = &lt;span class=&quot;s2&quot;&gt;&quot; &quot;&lt;/span&gt; + input;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;var&lt;/span&gt; arr = input.ToCharArray();&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;var&lt;/span&gt; output = &lt;span class=&quot;s1&quot;&gt;string&lt;/span&gt;.Empty;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;var&lt;/span&gt; b = 0;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;var&lt;/span&gt; e = arr.Length;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;s1&quot;&gt;int&lt;/span&gt; p = arr.Length - 1; p &amp;gt;= 0; p--)&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;{&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;s3&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;s3&quot;&gt; (arr[p] == &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&#39; &#39;&lt;/span&gt;&lt;span class=&quot;s3&quot;&gt; )&lt;/span&gt;// little off beginning of word&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;{&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;b = p + 1;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;output += input.Substring(b, e - b) + &lt;span class=&quot;s2&quot;&gt;&quot; &quot;&lt;/span&gt;;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;e = p ;&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;}&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;}&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s4&quot;&gt;Console&lt;/span&gt;.WriteLine(output.TrimEnd(&lt;span class=&quot;s2&quot;&gt;&#39; &#39;&lt;/span&gt;));&lt;/div&gt;
&lt;style type=&quot;text/css&quot;&gt;
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Consolas}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Consolas; color: #008f00}
p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Consolas; min-height: 11.0px}
span.s1 {color: #0433ff}
span.s2 {color: #b4261a}
span.s3 {color: #000000}
span.s4 {color: #33a2bd}
&lt;/style&gt;



















&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;s4&quot;&gt;Console&lt;/span&gt;.ReadLine();&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
Without allocating extra space&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//Reverse words in string&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;var&lt;/span&gt; input = &lt;span class=&quot;s3&quot;&gt;&quot;ayman ali&quot;&lt;/span&gt;;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;input = input + &lt;span class=&quot;s3&quot;&gt;&quot; &quot;&lt;/span&gt;;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;var&lt;/span&gt; arr = input.ToCharArray();&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//Loop - Pointer (p) is index - Length is length of array&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//If space found - e = p - 1, begin (b) saved from before&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//Reverse string in place&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//Loop half length of string&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//i to m (Mirror) m = e-i&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//Reverse whole string&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;var&lt;/span&gt; b = 0;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;var&lt;/span&gt; e = 0;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;s2&quot;&gt;int&lt;/span&gt; p = 0; p &amp;lt; arr.Length ; p++)&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;{&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;if&lt;/span&gt; (arr[p] == &lt;span class=&quot;s3&quot;&gt;&#39; &#39;&lt;/span&gt;)&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;{&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;e = p - 1;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;s2&quot;&gt;int&lt;/span&gt; i = b; i &amp;lt; (b+ (e-b) /2); i++)&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;{&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;var&lt;/span&gt; temp = arr[i];&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;var&lt;/span&gt; m = e - (i - b);&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;arr[i] = arr[m];&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;arr[m] = temp;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;}&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;b = p + 1;&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;}&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;}&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//arr need to be revsrsed&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;e = arr.Length-1;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;s2&quot;&gt;int&lt;/span&gt; p = 0; p &amp;lt; e/2; p++)&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;{&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;var&lt;/span&gt; temp = arr[p];&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;var&lt;/span&gt; m = e - p - 1;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;arr[p] = arr[m];&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;arr[m] = temp;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;}&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s4&quot;&gt;Console&lt;/span&gt;.WriteLine(&lt;span class=&quot;s2&quot;&gt;string&lt;/span&gt;.Join(&lt;span class=&quot;s2&quot;&gt;string&lt;/span&gt;.Empty, arr.Take(e)));&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;




&lt;style type=&quot;text/css&quot;&gt;
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Consolas; color: #008f00}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Consolas}
p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Consolas; min-height: 11.0px}
span.s1 {color: #000000}
span.s2 {color: #0433ff}
span.s3 {color: #b4261a}
span.s4 {color: #33a2bd}
&lt;/style&gt;












































&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;s4&quot;&gt;Console&lt;/span&gt;.ReadLine();&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aliayman.blogspot.com/feeds/2774210738854219298/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/13014608/2774210738854219298' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/2774210738854219298'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/2774210738854219298'/><link rel='alternate' type='text/html' href='http://aliayman.blogspot.com/2017/10/reverse-words-in-string.html' title='Reverse Words in a string'/><author><name>Ayman Ali</name><uri>http://www.blogger.com/profile/04089520193997921426</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKvUKAMsijXeg19hAydX5kYx8jhwScaIJfKaek8nf0MQ7XRt6oJG70KDPbzhHw2IrHn0n4ZkSh98tNQyU25tEDAgr-dg0evqF3NQarfEvLxEPubltwW6jbETKlCRVkjw/s220/Pic314.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13014608.post-5280331709117294400</id><published>2017-10-30T23:20:00.003-07:00</published><updated>2017-10-30T23:20:52.551-07:00</updated><title type='text'>Reverse Word Characters in Place</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Given a string, Reverse every word in the string in place. For example if you have Ayman Ali, running the algorithm should result in namyA ilA.&lt;br /&gt;
&lt;br /&gt;
Solutions&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//Reverse words in string&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;var&lt;/span&gt; input = &lt;span class=&quot;s3&quot;&gt;&quot;ayman ali&quot;&lt;/span&gt;;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;input += &lt;span class=&quot;s3&quot;&gt;&quot; &quot;&lt;/span&gt;;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//Convert into Array&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;var&lt;/span&gt; arr = input.ToCharArray();&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//Loop Through the array with the length of the array&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt; b = 0; &lt;/span&gt;//Pointer to an actual element&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;var&lt;/span&gt; e = 0;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;s2&quot;&gt;int&lt;/span&gt; i = 0; i &amp;lt; arr.Length; i++)&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;{&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;if&lt;/span&gt; (arr[i] == &lt;span class=&quot;s3&quot;&gt;&#39; &#39;&lt;/span&gt;) &lt;span class=&quot;s4&quot;&gt;//Space reached&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;{&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;e = i - 1;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s4&quot;&gt;//Rotate in place&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;s2&quot;&gt;int&lt;/span&gt; p = b; p &amp;lt; e - ((e-b) / 2); p++)&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;{&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;var&lt;/span&gt; temp = arr[p];&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;var&lt;/span&gt; m = e - (p - b);&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;arr[p] = arr[m];&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;arr[m] = temp;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;}&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;b = e + 2;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;}&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;}&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//If first element note b = Begin of new word&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//IF space or end of string&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;Record the position as end of word (e)&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;Rotate the word beginning with b and ending with e&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;let b = e + 2&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s4&quot;&gt;//Else&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;Continue&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s4&quot;&gt;//End Loop&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//Rotate a word&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//Loop through the word (Length half the word) begin with b and end with e&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//Save Pointer element temporarily&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//Save mirror position (m) into pointer position (p) - Define mirror position&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//save p into m&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s5&quot;&gt;Console&lt;/span&gt;.WriteLine(&lt;span class=&quot;s2&quot;&gt;string&lt;/span&gt;.Join(&lt;span class=&quot;s3&quot;&gt;&quot;&quot;&lt;/span&gt;,arr.Take(arr.Length-1)));&lt;/div&gt;
&lt;div class=&quot;p3&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;//Console.WriteLine(string.Join(&quot;,&quot;, out));&lt;/div&gt;
&lt;style type=&quot;text/css&quot;&gt;
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Consolas; color: #008f00}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Consolas}
p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Consolas; min-height: 11.0px}
span.s1 {color: #000000}
span.s2 {color: #0433ff}
span.s3 {color: #b4261a}
span.s4 {color: #008f00}
span.s5 {color: #33a2bd}
&lt;/style&gt;














































&lt;br /&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;s5&quot;&gt;Console&lt;/span&gt;.ReadLine();&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aliayman.blogspot.com/feeds/5280331709117294400/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/13014608/5280331709117294400' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/5280331709117294400'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/5280331709117294400'/><link rel='alternate' type='text/html' href='http://aliayman.blogspot.com/2017/10/reverse-word-characters-in-place.html' title='Reverse Word Characters in Place'/><author><name>Ayman Ali</name><uri>http://www.blogger.com/profile/04089520193997921426</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKvUKAMsijXeg19hAydX5kYx8jhwScaIJfKaek8nf0MQ7XRt6oJG70KDPbzhHw2IrHn0n4ZkSh98tNQyU25tEDAgr-dg0evqF3NQarfEvLxEPubltwW6jbETKlCRVkjw/s220/Pic314.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13014608.post-1774174252970716425</id><published>2017-06-06T16:10:00.004-07:00</published><updated>2017-06-06T16:10:24.487-07:00</updated><title type='text'>File upload and unzipping files</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
If you want to unzip a file here are few lines that unzips a zip file and delivers the contents as a stream. Here I am assuming the zip file contain images&lt;br /&gt;
&lt;span style=&quot;background-color: #eeeeee;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: #eeeeee;&quot;&gt;&amp;nbsp;if (fuPhotos.FileName.ToLower().EndsWith(&quot;.zip&quot;))&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #eeeeee;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #eeeeee;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var za = new System.IO.Compression.ZipArchive(fuPhotos.PostedFile.InputStream);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #eeeeee;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; foreach (var entry in za.Entries)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #eeeeee;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #eeeeee;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var img = System.Drawing.Image.FromStream(entry.Open());&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #eeeeee;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; img.Save(@&quot;c:\temp\&quot; + Path.GetFileName(entry.FullName));&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #eeeeee;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #eeeeee;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt;&amp;nbsp;if (fuPhotos.FileName.ToLower().EndsWith(&quot;.zip&quot;))&lt;/span&gt;&lt;br /&gt;
This line allows you to check the extension so you are certain the user is uploading a zip file. the extension is one way of detecting that.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt;var za = new System.IO.Compression.ZipArchive(fuPhotos.PostedFile.InputStream);&lt;/span&gt;&lt;br /&gt;
This line will get the stream of that file, you need to get a stream because the stream is a generic object that you can handle with other classes like StreamReader, StreamWriter, FileStream, MemoryStream and other objects like System.Drawing.Image that can get you an image from a stream&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt;&amp;nbsp;foreach (var entry in za.Entries)&lt;/span&gt;&lt;br /&gt;
This line allows you to loop to work on every entry in the zip file. the entry is a file inside the zip file. you can access its name, contents, etc..&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt;var img = System.Drawing.Image.FromStream(entry.Open());&lt;/span&gt;&lt;br /&gt;
The Image class can read a stream and entry.Open gets the stream of the entry&lt;br /&gt;
&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt;img.Save(@&quot;c:\temp\&quot; + Path.GetFileName(entry.FullName));&lt;/span&gt;&lt;br /&gt;
This line allows you to save the stream&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can deal with multiple files if the user uploads multiple files if you change your code as follows&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt;foreach (var onezipFile in fuPhotos.PostedFiles)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (onezipFile.FileName.ToLower().EndsWith(&quot;.zip&quot;))&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var za = new System.IO.Compression.ZipArchive(onezipFile.InputStream);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; foreach (var entry in za.Entries)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var img = System.Drawing.Image.FromStream(entry.Open());&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; img.Save(@&quot;c:\temp\&quot; + Path.GetFileName(entry.FullName));&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aliayman.blogspot.com/feeds/1774174252970716425/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/13014608/1774174252970716425' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/1774174252970716425'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/1774174252970716425'/><link rel='alternate' type='text/html' href='http://aliayman.blogspot.com/2017/06/file-upload-and-unzipping-files.html' title='File upload and unzipping files'/><author><name>Ayman Ali</name><uri>http://www.blogger.com/profile/04089520193997921426</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKvUKAMsijXeg19hAydX5kYx8jhwScaIJfKaek8nf0MQ7XRt6oJG70KDPbzhHw2IrHn0n4ZkSh98tNQyU25tEDAgr-dg0evqF3NQarfEvLxEPubltwW6jbETKlCRVkjw/s220/Pic314.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13014608.post-7697126227227962045</id><published>2017-01-26T12:28:00.001-08:00</published><updated>2017-02-22T07:30:18.170-08:00</updated><title type='text'>How to deliver your baby in Canada for Free (Almost)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
If you do not have health insurance when you first arrive to Canada and you are pregnant it will be very expensive to deliver your baby without insurance. Normal delivery is $3,000 and C-Section can reach $10,000 for more information you can review &lt;a href=&quot;https://secure.cihi.ca/free_products/Costs_Report_06_Eng.pdf&quot;&gt;this report&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
There is a free service that you can benefit from called &lt;a href=&quot;http://www.communitymidwivesoftoronto.ca/&quot;&gt;Community Midwifes&lt;/a&gt; which can help you deliver for $600 including all lab work and hospital fees.&lt;br /&gt;
&lt;br /&gt;
To start you need to visit &lt;a href=&quot;http://accessalliance.ca/contact-us/&quot;&gt;Access Point on Jane &lt;/a&gt;which is a community center located at&lt;br /&gt;
&lt;span style=&quot;background-color: #f3f3f3; font-family: &amp;quot;arial&amp;quot;; font-size: 14px;&quot;&gt;761 Jane St. 2nd Floor, Toronto, ON M6N 4B4&amp;nbsp;&lt;/span&gt;on Thursdays from 4:00 to 7:00 PM&amp;nbsp;&lt;span style=&quot;background-color: #f3f3f3; font-family: &amp;quot;arial&amp;quot;; font-size: 14px;&quot;&gt;416-760-8677&lt;/span&gt;&lt;br /&gt;
They will interview you and ask if you are a landed immigrant and waiting for OHIP? They do not usually check ID or landing papers but it is better if you have them with you. Then they will transfer you to the nearest midwife clinic, one of them is located at 344 Bloor street west and is called &lt;a href=&quot;http://www.communitymidwivesoftoronto.ca/&quot;&gt;Community Midwifes of Toronto.&lt;/a&gt;&amp;nbsp;and their telephones are.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4DRfZhZe1JLMyh_14jF4tQ-kvOH5MkZnsnNSFw0tM66t_MU8QrjrZ-vygFVJnJjrYNCRq2YM89YKeDriTMwgiJx6bWtox8hlTxQWWYNgAHaKXOTAD9o0K3mWndZsT7TNhav9pIQ/s1600/Scan+1.jpeg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;372&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4DRfZhZe1JLMyh_14jF4tQ-kvOH5MkZnsnNSFw0tM66t_MU8QrjrZ-vygFVJnJjrYNCRq2YM89YKeDriTMwgiJx6bWtox8hlTxQWWYNgAHaKXOTAD9o0K3mWndZsT7TNhav9pIQ/s640/Scan+1.jpeg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Then you will be able to see your midwife once every two weeks and then once every week, for all blood, &amp;nbsp;lab work and ultrasound they will give you a letter (which works as your insurance) that looks like this and this letter you can give to the lab and the lab will not charge you any thing.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlWzt45W30Veg_k1xnsZXT82zcncp5N0usBUqWnIjr1tXq2xaKEvArhyQ83_lS3yDYT54w7SWkj0BPI_8FSy7dtCmHzmKWmv4MzZmBD_Fc_Ir4ynUPz0LgFSZqfKbDLOs75U4OPg/s1600/PaymentLetter+copy.jpeg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlWzt45W30Veg_k1xnsZXT82zcncp5N0usBUqWnIjr1tXq2xaKEvArhyQ83_lS3yDYT54w7SWkj0BPI_8FSy7dtCmHzmKWmv4MzZmBD_Fc_Ir4ynUPz0LgFSZqfKbDLOs75U4OPg/s640/PaymentLetter+copy.jpeg&quot; width=&quot;459&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Here is a list of all the labs that accept this payment letter.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvcv7B9QXTUCPvG5Nfc4xOC5yimFK7bnK9VxDfcaqGUNan4f3_VFDFRt8Xa7lBraLo2JQ7H6mbKK7bxBzPM664FRvmGOU1rfQrpI1DqPdKKGKGP9SgecbhIL_Y-ged0KEbDoSVSQ/s1600/Scan.jpeg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvcv7B9QXTUCPvG5Nfc4xOC5yimFK7bnK9VxDfcaqGUNan4f3_VFDFRt8Xa7lBraLo2JQ7H6mbKK7bxBzPM664FRvmGOU1rfQrpI1DqPdKKGKGP9SgecbhIL_Y-ged0KEbDoSVSQ/s640/Scan.jpeg&quot; width=&quot;461&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
For ultrasound they will give you a request that looks like this&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWA7kFEdmUPJIIthKzlo4N20OSFEM_odbeCEgj8Eld4kcU9qL69xuXkVo7t8TtdcCzmDZl4_Nr5zOgyJUpS15C5JaDyi7gZ_REzSZeV8oYcVX9Cn7JcQ21xAzrOQxDzgJRk9a8UA/s1600/UltraSound.jpeg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWA7kFEdmUPJIIthKzlo4N20OSFEM_odbeCEgj8Eld4kcU9qL69xuXkVo7t8TtdcCzmDZl4_Nr5zOgyJUpS15C5JaDyi7gZ_REzSZeV8oYcVX9Cn7JcQ21xAzrOQxDzgJRk9a8UA/s640/UltraSound.jpeg&quot; width=&quot;460&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
If you need to see a doctor then you must talk to the midwife and she will transfer you to a doctor, not every doctor accept their payment letter but one who does is Dr. Susan Sheppard. Tel: 416-867-3728 located at&amp;nbsp;&lt;span style=&quot;background-color: #f7f6f4; font-family: &amp;quot;arial&amp;quot; , &amp;quot;lucida&amp;quot; , &amp;quot;verdana&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: 14.4px;&quot;&gt;410 Sherbourne St., 4th Floor,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: #f7f6f4; font-family: &amp;quot;arial&amp;quot; , &amp;quot;lucida&amp;quot; , &amp;quot;verdana&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: 14.4px;&quot;&gt;Toronto, Ontario,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: #f7f6f4; font-family: &amp;quot;arial&amp;quot; , &amp;quot;lucida&amp;quot; , &amp;quot;verdana&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: 14.4px;&quot;&gt;M4X 1K2. For more info &lt;a href=&quot;http://www.stmichaelshospital.com/programs/familypractice/health-centre-410.php&quot;&gt;please visit&amp;nbsp;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The doctor can also send you to do some lab work and it is better if you go to the same list of labs above. The doctor may send you to a different lab, but you need to ask her to give you the request on ministry of health form.&lt;br /&gt;
&lt;br /&gt;
If you are strong enough you can delivery in a birth center without &lt;a href=&quot;http://americanpregnancy.org/labor-and-birth/epidural/&quot;&gt;Epidural&lt;/a&gt;, &lt;a href=&quot;http://www.torontobirthcentre.ca/&quot;&gt;Toronto birth center&lt;/a&gt; is located at&amp;nbsp;&lt;span style=&quot;background-color: white; color: #222222; font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: 13px;&quot;&gt;525 Dundas St E, Toronto, ON M5A 2B6 and you can call to request a tour&amp;nbsp;&lt;/span&gt;&lt;a class=&quot;fl r-i_83X_5Xt1lA&quot; data-number=&quot;+14163668080&quot; data-pstn-out-call-url=&quot;&quot; data-rtid=&quot;i_83X_5Xt1lA&quot; data-ved=&quot;0ahUKEwiQuZXwz-DRAhWL3YMKHeTcAvkQkAgIsAUoADBq&quot; href=&quot;https://www.blogger.com/null&quot; jsaction=&quot;r.oVdbr2mIpA8&quot; jsl=&quot;$t t-6xg4lalHw8M;$x 0;&quot; style=&quot;background-color: white; color: #1a0dab; cursor: pointer; font-family: arial, sans-serif; font-size: 13px; text-decoration: underline;&quot; title=&quot;Call via Hangouts&quot;&gt;(416) 366-8080&lt;/a&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: &amp;quot;arial&amp;quot; , sans-serif; font-size: 13px;&quot;&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The final step is actual delivery. If you are going to delivery in the birth center then it is totally free and you do not need to pay anything. If you prefer to have an easier delivery using Epidural then you need to deliver at the hospital once of the hospitals affiliated with midwifes is &lt;a href=&quot;http://www.stmichaelshospital.com/&quot;&gt;St. Michael hospital &lt;/a&gt;which is located at&amp;nbsp;30 Bond St., Toronto, Ontario M5B 1W8.&lt;br /&gt;
&lt;br /&gt;
The hospital requires a payment of $600 which covers 3 days at $200/day. your midwife will give you an admission letter and another letter like this that you need to take to the hospital and pay $600 which is a great deal.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEho0FlnmRov5rPMl5jLBDzg8LLZfKeOORnqTf9F0h1SHGrUzSww316z0kHi7Zn3KLWGQTSyUMlYAm6-njnFBpUaKp-s18jiEU2RoSj8_7Gvtl3ZW_VZVriw3SOyLcz9tJ4-i56p7Q/s1600/hospital.jpeg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEho0FlnmRov5rPMl5jLBDzg8LLZfKeOORnqTf9F0h1SHGrUzSww316z0kHi7Zn3KLWGQTSyUMlYAm6-njnFBpUaKp-s18jiEU2RoSj8_7Gvtl3ZW_VZVriw3SOyLcz9tJ4-i56p7Q/s640/hospital.jpeg&quot; width=&quot;460&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
With this payment, you will not pay any thing else for any lab work or medicine at the hospital. Even Epidural is covered in these $600.&lt;br /&gt;
&lt;br /&gt;
Finally, they will give you a paper to keep in case of emergency and in case you had to go to any other hospital. These two papers contain all information about you and they look like this&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5ydRbgmBUlnZETwjsCk_fvRh2nbD_Ap2zwsxWuB5IYsU6lm2UE-cKzl8iO0lwheOYlfTwAKYIV0c6uGOHOMdQlJd2HhStuL7yUR68RiNMQD3t0ScpMBooEYSv6L_0Eo4-drQUxA/s1600/Vitals1.jpeg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5ydRbgmBUlnZETwjsCk_fvRh2nbD_Ap2zwsxWuB5IYsU6lm2UE-cKzl8iO0lwheOYlfTwAKYIV0c6uGOHOMdQlJd2HhStuL7yUR68RiNMQD3t0ScpMBooEYSv6L_0Eo4-drQUxA/s640/Vitals1.jpeg&quot; width=&quot;466&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, you should prepare for your C-Section appointment, Ours was by Dr. Howard Berger and you need the direct hospital number, their 15th Floor number is 416-864-5252&lt;br /&gt;
&lt;br /&gt;
After birth, your baby will either feed on breast milk or formula and may suffer a little bit of Jaundice and you will be seen by a Pediatric in the hospital.&lt;br /&gt;
&lt;br /&gt;
No matter what you do, do not go to 61 Queen st E, to see Dr. Cheema. This clinic is very unprofessional, our appointment was at 8:45 in the morning, we arrived at 8:25 AM and have only been seen at 10:00 AM imagine? they seem to be disrespectful of people&#39;s time. you will be disappointed that you keep your daughter undressed and ready to be seen for an hour.&lt;br /&gt;
&lt;br /&gt;
I hope this information helps you have a smooth planning to this magical moment and best of luck.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aliayman.blogspot.com/feeds/7697126227227962045/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/13014608/7697126227227962045' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/7697126227227962045'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/7697126227227962045'/><link rel='alternate' type='text/html' href='http://aliayman.blogspot.com/2017/01/how-to-deliver-your-baby-in-canada-for.html' title='How to deliver your baby in Canada for Free (Almost)'/><author><name>Ayman Ali</name><uri>http://www.blogger.com/profile/04089520193997921426</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKvUKAMsijXeg19hAydX5kYx8jhwScaIJfKaek8nf0MQ7XRt6oJG70KDPbzhHw2IrHn0n4ZkSh98tNQyU25tEDAgr-dg0evqF3NQarfEvLxEPubltwW6jbETKlCRVkjw/s220/Pic314.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4DRfZhZe1JLMyh_14jF4tQ-kvOH5MkZnsnNSFw0tM66t_MU8QrjrZ-vygFVJnJjrYNCRq2YM89YKeDriTMwgiJx6bWtox8hlTxQWWYNgAHaKXOTAD9o0K3mWndZsT7TNhav9pIQ/s72-c/Scan+1.jpeg" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13014608.post-8823336120432457057</id><published>2015-04-25T01:54:00.003-07:00</published><updated>2015-04-25T02:08:14.587-07:00</updated><title type='text'>PDF417 Test Url</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;color: #5d5d5d; font-family: Lato; font-size: 16px;&quot;&gt;&lt;a href=&quot;pdf417://scan?type=PDF417&amp;amp;beep=true&amp;amp;callback=http://hajonsoft.com/pdf417.aspx?data=[data]&quot;&gt;pdf417://scan?type=PDF417&amp;amp;beep=true&amp;amp;callback=http://hajonsoft.com/pdf417.aspx?data=[data]&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aliayman.blogspot.com/feeds/8823336120432457057/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/13014608/8823336120432457057' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/8823336120432457057'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/8823336120432457057'/><link rel='alternate' type='text/html' href='http://aliayman.blogspot.com/2015/04/pdf417-test-url.html' title='PDF417 Test Url'/><author><name>Ayman Ali</name><uri>http://www.blogger.com/profile/04089520193997921426</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKvUKAMsijXeg19hAydX5kYx8jhwScaIJfKaek8nf0MQ7XRt6oJG70KDPbzhHw2IrHn0n4ZkSh98tNQyU25tEDAgr-dg0evqF3NQarfEvLxEPubltwW6jbETKlCRVkjw/s220/Pic314.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13014608.post-5775983942798930986</id><published>2013-01-30T19:29:00.002-08:00</published><updated>2013-01-30T20:10:55.260-08:00</updated><title type='text'>Calling Javascript from Content Page</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Is it really easy with play with JavaScript? for instance, If you have a content page within&amp;nbsp;or referencing a&amp;nbsp;master page. your content page has a drop down box and a text field. &lt;br /&gt;
&lt;br /&gt;
You want to show or hide the text field based on the drop down box&amp;nbsp;contents.&lt;br /&gt;
&lt;br /&gt;
Let&#39;s say the drop down contain a list of airports for the user to choose from. only if the user chooses the value other in this drop down, you want to show the text field. &lt;br /&gt;
&lt;br /&gt;
It may not be as simple as &lt;br /&gt;
&lt;br /&gt;
if (dfcDropDown.Text == &quot;Other&quot;) dfsTextBox.Visible = True; else dfsTextBox.Visible = False;&lt;br /&gt;
&lt;br /&gt;
It will be little more involved than that.&lt;br /&gt;
&lt;br /&gt;
First you need to write a function in Java script. This funtion you can not just put it anywhere in the aspx. you have to put it under the asp:Content tag. which might look like this&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;asp:content contentplaceholderid=&quot;MainContent&quot; id=&quot;BodyContent&quot; runat=&quot;server&quot;&gt;&lt;/asp:content&gt;&lt;/strong&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.727272033691406px;&quot;&gt;&amp;lt;asp:Content ID=&quot;BodyContent&quot; runat=&quot;server&quot; ContentPlaceHolderID=&quot;&lt;/span&gt;&lt;wbr style=&quot;background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.727272033691406px;&quot;&gt;&lt;/wbr&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.727272033691406px;&quot;&gt;MainContent&quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Second you need to make a java script block and write your function using GetElementById.&amp;nbsp;When calling getElementById, the Id of the control will be little tricker. you can not as a matter of fact put the Id of the control directly. you must use a syntax like this &amp;amp;lt;%=dfcDropDown.ClientID%&amp;amp;gt; to get the name of the control at run time. Here is a sample Javascript method that will hide the text box based on the drop down box value&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.727272033691406px;&quot;&gt;
&amp;lt;script type=&quot;text/javascript&quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; function ShowHideTextBox() {&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.727272033691406px;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (document.getElementById(&#39;&amp;lt;%=&lt;wbr&gt;&lt;/wbr&gt;dfcDropDownBoxt.ClientID%&amp;gt;&#39;).value == &quot;Other&quot;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; document.getElementById(&#39;&amp;lt;%=&lt;wbr&gt;&lt;/wbr&gt;dfsTextBox.ClientID%&amp;gt;&#39;).style.&lt;wbr&gt;&lt;/wbr&gt;display = &#39;none&#39;; //hide textbox&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; document.getElementById(&#39;&amp;lt;%=&lt;wbr&gt;&lt;/wbr&gt;dfsTextBox.ClientID%&amp;gt;&#39;).style.&lt;wbr&gt;&lt;/wbr&gt;display = &#39;block&#39;; //show textbox&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.727272033691406px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
Now, we have a code that will do what we need and we need to trigger this code when the use changes the value of the drop down box. well, we can not hook this code directly to the drop down box from within the aspx. we have to use the code behind to do that. it turns out that the onChange event is not available from within the aspx page. We must hook the onChange event using c# like this&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;dfcdropDown.Attributes.Add(&quot;onChange&quot;, &quot;ShowHideTextBox();&quot;);&lt;br /&gt;
&lt;br /&gt;
and we must do this in the code behind.&lt;br /&gt;
&lt;br /&gt;
Not that simple haaa;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aliayman.blogspot.com/feeds/5775983942798930986/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/13014608/5775983942798930986' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/5775983942798930986'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/5775983942798930986'/><link rel='alternate' type='text/html' href='http://aliayman.blogspot.com/2013/01/calling-javascript-from-content-page.html' title='Calling Javascript from Content Page'/><author><name>Ayman Ali</name><uri>http://www.blogger.com/profile/04089520193997921426</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKvUKAMsijXeg19hAydX5kYx8jhwScaIJfKaek8nf0MQ7XRt6oJG70KDPbzhHw2IrHn0n4ZkSh98tNQyU25tEDAgr-dg0evqF3NQarfEvLxEPubltwW6jbETKlCRVkjw/s220/Pic314.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13014608.post-8030072454750841025</id><published>2012-03-14T14:55:00.006-07:00</published><updated>2012-03-14T16:49:46.184-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Reactive Extensions RX C#"/><title type='text'>Reactive Extensions Gems</title><content type='html'>As I am learning about reactive extensions I want to post some code that I think is useful. Before using the code here you may want to download Reactive Extensions for your .Net Framework version. It is located at &lt;a href=&quot;http://www.microsoft.com/download/en/details.aspx?id=24940&quot;&gt;http://www.microsoft.com/download/en/details.aspx?id=24940&lt;br /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style=&quot;color:#000099;&quot;&gt;Observable.Interval(TimeSpan.FromSeconds(1)).Subscribe(DoSomething); &lt;/span&gt;&lt;br /&gt;What it does: it will call a method called DoSomething that acceptes one parameter of type long.&lt;br /&gt;What can you do with it: You can use this line to call the DoSomething every second and send emails for example. before this line you can retrieve the list of customers to send emails to, and every second grab one customer and send email to him/her&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 102);&quot;&gt;Observable.Timer(TimeSpan.FromSeconds(5),TimeSpan.FromSeconds(1)).Subscribe(DoSomething);&lt;/span&gt;&lt;br /&gt;What it does: Call a method every second after waiting for three seconds initially.&lt;br /&gt;What you can do with it: You can send emails to customers after waiting a specific perdiod of time.</content><link rel='replies' type='application/atom+xml' href='http://aliayman.blogspot.com/feeds/8030072454750841025/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/13014608/8030072454750841025' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/8030072454750841025'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/8030072454750841025'/><link rel='alternate' type='text/html' href='http://aliayman.blogspot.com/2012/03/reactive-extensions-gems.html' title='Reactive Extensions Gems'/><author><name>Ayman Ali</name><uri>http://www.blogger.com/profile/04089520193997921426</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKvUKAMsijXeg19hAydX5kYx8jhwScaIJfKaek8nf0MQ7XRt6oJG70KDPbzhHw2IrHn0n4ZkSh98tNQyU25tEDAgr-dg0evqF3NQarfEvLxEPubltwW6jbETKlCRVkjw/s220/Pic314.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13014608.post-4161685194152795317</id><published>2012-02-08T11:10:00.000-08:00</published><updated>2012-02-08T11:11:40.490-08:00</updated><title type='text'>Silverlight Gems</title><content type='html'>Response.Redirect&lt;br /&gt;&lt;br /&gt;System.Windows.Browser.HtmlPage.Window.Navigate(new Uri(&quot;http://cnn.com&quot;)); //You can use &quot;_blank&quot; as a second paramter to popup the cnn.com in a new window&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Response.QueryString&lt;br /&gt;System.Windows.Browser.HtmlPage.Document.DocumentUri.Query;</content><link rel='replies' type='application/atom+xml' href='http://aliayman.blogspot.com/feeds/4161685194152795317/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/13014608/4161685194152795317' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/4161685194152795317'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/4161685194152795317'/><link rel='alternate' type='text/html' href='http://aliayman.blogspot.com/2012/02/silverlight-gems.html' title='Silverlight Gems'/><author><name>Ayman Ali</name><uri>http://www.blogger.com/profile/04089520193997921426</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKvUKAMsijXeg19hAydX5kYx8jhwScaIJfKaek8nf0MQ7XRt6oJG70KDPbzhHw2IrHn0n4ZkSh98tNQyU25tEDAgr-dg0evqF3NQarfEvLxEPubltwW6jbETKlCRVkjw/s220/Pic314.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13014608.post-7907429612483812353</id><published>2011-02-28T09:13:00.000-08:00</published><updated>2011-02-28T09:41:26.853-08:00</updated><title type='text'>Tips for Pilgrimage to Mecca</title><content type='html'>I already wrote my experience in the Hajj of 2010 which was in Arabic and can be found &lt;a href=&quot;http://aliayman.blogspot.com/2010/12/2010.html&quot;&gt;here&lt;/a&gt;, I still have some more tricks and tips that can make your trip a lot easier. Those tricks has to do with making phone calls, transportation etc...&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;You should take with you&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;1- Odorless Soap, so you can wash after going to the toilet. You will not have time for shopping and may not find what you need.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;2- Hair cutter, when you need to cut your hair you will find everyone busy and expensive. Imagine millions are looking for barbershops.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;3- Towel, Some of the temporary hotels you will stay in will not provide towels. Also in the tents you are on your own.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;4- Container for Zamzam water. If you buy containers from there, you will have to walk to find a store and it will be expensive.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;5- Your laptop. Usually hotels will have Wifi and you can call your family using any VOIP&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;6- Bring your VOIP telephone (Or Magic Jack), you can connect it to the hotel internet and call your family.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;7- Bring your cell phone (some people says don&#39;t because you will lose it, I&#39;d say bring it but don&#39;t take it outside the hotel). You can get STC SIM card for 40 Rial (Pre loaded with 50 Rial)and call 902 they will give you daily internet on you SIM card. 10 Rial for one hour or 24 Rial for the whole day. They will send you a message if you click the link on it, it will setup your tel. Make sure your tel support arabic otherwise ask them to send you the message in English.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;8- More than one Ihram cloth. you will need one more and washing them is the same as buying new ones. I would say bring three total.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;What to do&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;1- When finishing tawaf try to get out gradually. if you find yourself on the 7th round and close to Kaaba try to exit the tawaf gradually and not one time.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;2- After your done with Jamarat continue walking and you will find yourself out &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;3- in your telephone always bookmark the important locations in the map. with your GPS you can go back. Places like your tent will be ex termly important when you get lost. bookmark the location of el 7aram so you can go back to it if you get lost.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;4- Go to Tan3eem to make another Omra (you can make Omra any number of times) Tan3eem bus is two Rial each way.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;5- Best times for Omra (7aram will be kinda empty) 9-10 AM , 1-3 AM, 1-3 PM&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;6- If you are with a group, then hold hands during tawaf. you will support each other and will not fall.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;7- Be vigilant they will ask women to sit in a separate area close to prayer times. If you sit beside your wife and hoping you will pray beside each other, it may not happen. They will ask women to leave their space and go somewhere else. If you are looking for a place for prayer and you see some women sitting there you can wait and take their place when they ask them to leave.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;8- In Medina, best times to pray in Rawda 1:30 AM. stand b Seddek Door, they will open at 2:00 AM&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;9- Do not take Taxi&#39;s just wave to any car, it will stop and you can negotiate the price to go anywhere.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;10-If you will take the bus from Azizia to Mena, and the bus will make two trips. get in the second trip not the first. The first trip the guide may get lost, so do not go in the first trip unless you enjoy getting lost.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;11- If you can have a motor cycle for the last day of Hajj or bicycle, you will be a king in transportation.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here is a summary for Hajj days.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Day 8 Thu Hejja (Tarwiya): sleep in Menna, wakeup at 5:00 am. Fajr prayer then bus to Arafat.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Day 9 Thu Hejja (Arafa): stay in arafat untill Maghrib, then bus to Muzdalafa, sleep in Mozdalafa in sleeping bag&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Day 10 Thu Hejja (El nahr or Eid): Bus to Mena, then walk (3 Km) to Jamarat, throw first Jamara and Tahallom from Ihram.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Day 11 Thu Hejja (Tashreek Awal): Throw three Jamarat.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Day 12 Thu Hejja (Tashreek Thani): Throw three Jamarat. Tawaf Wada3, Ifada, Sa3i and leave to Airport if you are Mota3agel.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aliayman.blogspot.com/feeds/7907429612483812353/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/13014608/7907429612483812353' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/7907429612483812353'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/7907429612483812353'/><link rel='alternate' type='text/html' href='http://aliayman.blogspot.com/2011/02/tips-for-pilgrimage-to-mecca.html' title='Tips for Pilgrimage to Mecca'/><author><name>Ayman Ali</name><uri>http://www.blogger.com/profile/04089520193997921426</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKvUKAMsijXeg19hAydX5kYx8jhwScaIJfKaek8nf0MQ7XRt6oJG70KDPbzhHw2IrHn0n4ZkSh98tNQyU25tEDAgr-dg0evqF3NQarfEvLxEPubltwW6jbETKlCRVkjw/s220/Pic314.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13014608.post-7490797500657305813</id><published>2011-02-18T10:28:00.001-08:00</published><updated>2011-03-11T10:52:40.348-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="tfs2008 vss migration"/><title type='text'>VSS2005 to TFS2008 Migration steps</title><content type='html'>&lt;div&gt;Migration for VSS to TFS is covered in may articles on the internet like this &lt;a href=&quot;http://nigelonagile.com/2010/09/01/step-by-step-vss-to-tfs-migration/&quot;&gt;favorite post&lt;/a&gt;. However most of the tutorials does not come with a lot of screen shots. Here in this post I am posting screen shots to help you along the way.&lt;/div&gt;&lt;div&gt;If you create a specific folder for the migration then it would look like the following. and you may create a folder for your project which will contain your usermap.xml&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1r29DefifM9QcHMUQp-T43UwsX7Rn2OWlR-xBWTqYMS4D9k4xbLgi0k1P9P8ThHZKQgw02oIA68yDV7R5vkVUNHuLr9iQSiQ1E5aVgMDGoSFJkO2N-gbdjlaHYUcRIpiV8hS5Ow/s1600/blog_userMap.jpg&quot;&gt;&lt;img style=&quot;cursor:pointer; cursor:hand;width: 200px; height: 61px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1r29DefifM9QcHMUQp-T43UwsX7Rn2OWlR-xBWTqYMS4D9k4xbLgi0k1P9P8ThHZKQgw02oIA68yDV7R5vkVUNHuLr9iQSiQ1E5aVgMDGoSFJkO2N-gbdjlaHYUcRIpiV8hS5Ow/s200/blog_userMap.jpg&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5575806427851232322&quot; /&gt;&lt;/a&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1r29DefifM9QcHMUQp-T43UwsX7Rn2OWlR-xBWTqYMS4D9k4xbLgi0k1P9P8ThHZKQgw02oIA68yDV7R5vkVUNHuLr9iQSiQ1E5aVgMDGoSFJkO2N-gbdjlaHYUcRIpiV8hS5Ow/s1600/blog_userMap.jpg&quot;&gt;&lt;/a&gt;Then you should open your VSS database that you want to migrate using VSS2005. your database in VSS should look something like this.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1r29DefifM9QcHMUQp-T43UwsX7Rn2OWlR-xBWTqYMS4D9k4xbLgi0k1P9P8ThHZKQgw02oIA68yDV7R5vkVUNHuLr9iQSiQ1E5aVgMDGoSFJkO2N-gbdjlaHYUcRIpiV8hS5Ow/s1600/blog_userMap.jpg&quot;&gt;&lt;/a&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8eIYI64pLIfmOBBL2366Ozgj1SAJbEsqkF_CHYzK-s1djKmmosJgVTPfFD9s1OSstN5GrOe9BwKEOiGTq4RMei6c7oHly-sIu7RkojCebJzZ65gd9YPH8LODpPLuDunFUK6cPSQ/s200/vss+Data.JPG&quot; id=&quot;BLOGGER_PHOTO_ID_5575164282768541154&quot; style=&quot;WIDTH: 185px; CURSOR: hand; HEIGHT: 150px&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;br /&gt;Then in your project folder, create the AnalysisSettings.xml and MigrationSettings.xml and should probably call them from a batch file. Your folder should look something like this&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;\&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirOOmfEi0MMcBYcN1wGVpkQFubKixddVR254Pqsh26yV-CdcAWdhtcYLa2xvD8IWdHvxOjlOoqi0GBLhPuM1uLoKlwjBnrhiVuFyDJufHNP_4zbqlEtDmTmXHz3Szyfq1_2ivoHA/s200/folder001.JPG&quot; id=&quot;BLOGGER_PHOTO_ID_5575182316891643890&quot; style=&quot;WIDTH: 200px; CURSOR: hand; HEIGHT: 102px&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7PSNv4PQTXoMBdrEFu5EYmOkZ4sKuXEab8tnirrOAqs0k1t9Q5fbdNnMNFUcV5n1Q3-t8uIJSztI3XCUprGLkESkhOX_EX4UP_g1A0CrCJDg4ndYtRZfy654ef_6nZRXwCjYWlA/s1600/blog_migrationstart.jpg&quot;&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Then you should be able to run your analyze.bat. The analysis will begin and will ask for administrator password as follows&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcta1MCprSX_vUCCtmDiNp2Uv8hI-TrWDZVLIq5DAGUDjaz11I0qB58izzpCML73fbuEbp9jEoFDb0G7E04NgS7JMW0odxfi-SN37rvXQM9vhJw3HwPU-vIXHstsMDi4RbQG_MlQ/s200/adminpass.JPG&quot; id=&quot;BLOGGER_PHOTO_ID_5575182231908932578&quot; style=&quot;WIDTH: 200px; CURSOR: hand; HEIGHT: 99px&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;it will then start the scanning and produce usermap.xml&lt;/div&gt;&lt;div&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSWVRaTvReBPppg0A1__63yIN_zuSiYT5Y2JaFspczeD5YCUmmeu3jnuVqbuPlRHIgIAuQy6tuaGw_yU5iYgoCGHYeIE8g6aBaffoXDpmpB9B5FEWck5tMDLDoeEvcR1-W9QwBiQ/s200/scanning.JPG&quot; id=&quot;BLOGGER_PHOTO_ID_5575182392584710562&quot; style=&quot;WIDTH: 200px; CURSOR: hand; HEIGHT: 99px&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;You can then run the Migrate.bat after modifying your usermap.xml. Migration will start&lt;/div&gt;&lt;div&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7PSNv4PQTXoMBdrEFu5EYmOkZ4sKuXEab8tnirrOAqs0k1t9Q5fbdNnMNFUcV5n1Q3-t8uIJSztI3XCUprGLkESkhOX_EX4UP_g1A0CrCJDg4ndYtRZfy654ef_6nZRXwCjYWlA/s1600/blog_migrationstart.jpg&quot;&gt;&lt;img style=&quot;cursor:pointer; cursor:hand;width: 200px; height: 99px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7PSNv4PQTXoMBdrEFu5EYmOkZ4sKuXEab8tnirrOAqs0k1t9Q5fbdNnMNFUcV5n1Q3-t8uIJSztI3XCUprGLkESkhOX_EX4UP_g1A0CrCJDg4ndYtRZfy654ef_6nZRXwCjYWlA/s200/blog_migrationstart.jpg&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5575706315210870258&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7PSNv4PQTXoMBdrEFu5EYmOkZ4sKuXEab8tnirrOAqs0k1t9Q5fbdNnMNFUcV5n1Q3-t8uIJSztI3XCUprGLkESkhOX_EX4UP_g1A0CrCJDg4ndYtRZfy654ef_6nZRXwCjYWlA/s1600/blog_migrationstart.jpg&quot;&gt;&lt;/a&gt;and then complete as follows.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuvAdXlq2mtnGW01wE_O6Y-AEijxDScEg-8OAzlcoF48FBmiVJGH4UWNxdqCdXQaAk68Le6rqL0G07LflQVxYXKT9cPQBWcbjTMf1E1fF_p1uh9qKlvA0cFloxaz5PPPAc0N3aag/s1600/endMigration.JPG&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5575098265163224370&quot; style=&quot;WIDTH: 200px; CURSOR: hand; HEIGHT: 99px&quot; alt=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuvAdXlq2mtnGW01wE_O6Y-AEijxDScEg-8OAzlcoF48FBmiVJGH4UWNxdqCdXQaAk68Le6rqL0G07LflQVxYXKT9cPQBWcbjTMf1E1fF_p1uh9qKlvA0cFloxaz5PPPAc0N3aag/s200/endMigration.JPG&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aliayman.blogspot.com/feeds/7490797500657305813/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/13014608/7490797500657305813' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/7490797500657305813'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/7490797500657305813'/><link rel='alternate' type='text/html' href='http://aliayman.blogspot.com/2011/02/vss2005-to-tfs2008-migration-steps.html' title='VSS2005 to TFS2008 Migration steps'/><author><name>Ayman Ali</name><uri>http://www.blogger.com/profile/04089520193997921426</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKvUKAMsijXeg19hAydX5kYx8jhwScaIJfKaek8nf0MQ7XRt6oJG70KDPbzhHw2IrHn0n4ZkSh98tNQyU25tEDAgr-dg0evqF3NQarfEvLxEPubltwW6jbETKlCRVkjw/s220/Pic314.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1r29DefifM9QcHMUQp-T43UwsX7Rn2OWlR-xBWTqYMS4D9k4xbLgi0k1P9P8ThHZKQgw02oIA68yDV7R5vkVUNHuLr9iQSiQ1E5aVgMDGoSFJkO2N-gbdjlaHYUcRIpiV8hS5Ow/s72-c/blog_userMap.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13014608.post-4558244414377203919</id><published>2011-02-03T16:31:00.000-08:00</published><updated>2011-02-03T16:35:44.283-08:00</updated><title type='text'>RFID operation</title><content type='html'>&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;http://www.forestindustries.vt.edu/Images/rfidworks3.gif&quot;&gt;&lt;img style=&quot;cursor:pointer; cursor:hand;width: 322px; height: 90px;&quot; src=&quot;http://www.forestindustries.vt.edu/Images/rfidworks3.gif&quot; border=&quot;0&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;It is very interesting to know how &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_0&quot;&gt;RFID&#39;s&lt;/span&gt; work. Those Id&#39;s you hold in your hand and they can be read remotely from a near distance.  For sometime I was not really excited about their operation but became super excited to learn that they transmit the information. Home come they transmit anything if they do not have batteries. Then comes the next part, they do not have batteries but they receive power from the reader which is another fascinating idea. Here is the full details of how the &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_1&quot;&gt;RFId&lt;/span&gt; work. RFID&#39;s are now used in many applications (ex. Passports, Credit Cards, Security Cards, Transponders, etc....)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;http://www.forestindustries.vt.edu/rfid/rfidworks.html&quot;&gt;http://www.forestindustries.vt.edu/rfid/rfidworks.html&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aliayman.blogspot.com/feeds/4558244414377203919/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/13014608/4558244414377203919' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/4558244414377203919'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/4558244414377203919'/><link rel='alternate' type='text/html' href='http://aliayman.blogspot.com/2011/02/rfid-operation.html' title='RFID operation'/><author><name>Ayman Ali</name><uri>http://www.blogger.com/profile/04089520193997921426</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKvUKAMsijXeg19hAydX5kYx8jhwScaIJfKaek8nf0MQ7XRt6oJG70KDPbzhHw2IrHn0n4ZkSh98tNQyU25tEDAgr-dg0evqF3NQarfEvLxEPubltwW6jbETKlCRVkjw/s220/Pic314.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13014608.post-5391697673392219675</id><published>2010-12-06T05:24:00.000-08:00</published><updated>2011-01-15T11:20:19.822-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="hajj haj الحج"/><title type='text'>تجربة الحج 2010 ونصائح للحج فى السنين المقبلة</title><content type='html'>&lt;div&gt;الحمد للة الذى اذن لى &lt;a href=&quot;http://en.wikipedia.org/wiki/Hajj&quot;&gt;بالحج &lt;/a&gt;هذا العام 2010 &lt;a href=&quot;http://www.islamicity.com/mosque/hajj/Adha/story_of_hajj.htm&quot;&gt;والحج &lt;/a&gt;هو فعلا رحلة تغير مجرى الحياة وتصلح الانسان. وقد احسست فعليا بالتغير اثناء وبعد الحج. يمكن للحج ان يجعلك لا تخشى شيئا وتعلم علم اليقين ان اللة موجود ويستجيب الدعاء. ويملا قلبك حب اللة ورغبة اكيدة فى معرفة المزيد عنة. سوف يؤثر فيك ان تكون من بين هؤلاء الذين اختارهم اللة ليأذن لهم بالحج.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;فعلا ترك الحج اثرا جميلا واحساسا رقيقا فى قلبى بعظمة اللة ورحمتة وحبة لنا وكرمة الغير محدود. وقد كانت تجربة روحانية عظيمة لم ينغصها على الا قوانين المملكة العربية السعودية كبلد ووزارة الحج كهيئة منظمة للحج.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;كان الحجاج دائمو الشكوى من طريقة ادارة المملكة للحج ورايت بنفسى واحسست ان طريقة ادارة المملكة للحج قد تكون سببا فى افساد الحج ذاتة على الحجاج.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;قد يذهب البعض الى حد الاعتقاد ان المملكة تحارب الحج وتكره على الحجاج ان يقوموا بة وذلك بوضع العراقيل امامهم لجعل الحج رحلة صعبة عليهم وافسادة على اكبر قدر منهم.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;قد تعانى من البيروقراطية اثناء الحج الى درجة تجعلك تجادل او تغضب غضبا شديدا تفقد بسببة الحج الذى اتيت من اجلة. قد تفقد الروحانيات المصاحبة للحج وتجعلك العراقيل تغادر المملكة بدون اتمام الحج. وكم ادهشنى ان اشاهد فى التليفزيون التقارير السعودية بان الحج هذا العام سهلا وميسرا فى حين اعيش الحقيقة والتى هى عكس ذلك تماما والتى هى اقرب ما يكون الى الصعب بل والمستحيل.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;لذا قررت ان اكتب تجربة الحج التى مررت بها حتى يستطيع من يقرأها ان يتجنب ان يقع فيما وقعت انا فية او على اقل تقدير يكون &lt;/span&gt;متوقعا لما سوف يلاقية فيستعد له نفسيا. اردت ان اكتب التجربة واملى ان يقرئها المسؤلون عن الحج فى المملكة ويعلمون كيف يصف احد الحجاج ما لاقاة ويتجهون الى حل هذه المشكلات او الاستعانة ببعض الاقتراحات التى سوف اكتبها.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;بدات رحلتى من الولايات المتحدة مستعدا لتكريس كل وقتى&lt;a href=&quot;http://www.youtube.com/watch?v=f6TkOVVLFL0&quot;&gt; للحج&lt;/a&gt; ودراسة &lt;a href=&quot;http://www.islamicity.com/mosque/hajj/stepbystep/_anyday.asp?StartWithLeft=_anyleft.asp?LeftReference=1_1b.jpg&amp;amp;StartWithRight=1_1_right.htm&amp;amp;IndexBottom=indexBottom_day1.htm&amp;amp;IndexScrollingBottom=indexScrollingBottom_day1.htm&quot;&gt;احكامة وخطواتة&lt;/a&gt; ولكن كادت ان تفسد على المملكة الروحانيات المصاحبة للحج لولا ان اراد اللة لى ان يتم حجى بدون جدال وان ينزل على وعلى اغلب الحجاج صبرا جميلا&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;بدات المعانة من مطار جدة وذلك عندما تم عزلنا فى صالة تسمى صالة الحجاج لفحص شهادات التطعيم. استغرق الفحص 45 دقيقة وكان يتم بشكل عشوائى وذلك بان قامت مجموعة من الاطباء بالتجول بيننا ونحن جالسون والتحقق من شهادة التطعيم وكانو يجوبون بيننا بشكل عشوائى لا يضمن ان كل واحد مننا قد تم التحقق من شهادتة. كنت انظر الى تلك العملية واتسائل الم تتحقق السفارة السعودية فى الولايات &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;المتحدة مسبقا من شهادة التطعيم &lt;/span&gt;هذه . الم تكن هذه الشهادة هى احد الاوراق المطلوبة لاصدار فيزة الحج هذه؟&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNp2jJDCdKyQuvJWWW9jHbymH6UrXzZxV5MK_KLjpPQYWgspEcSi3qZsCr5JZbFrsA6p66tyMJG607G56Kl_ue6xAkz6nCYPdIYnN_xONJ9wCBWy4-Xoe2LKAYP68dwD43fBYaEw/s320/2010-11-19+16.45.16.jpg&quot; style=&quot;cursor:pointer; cursor:hand;width: 320px; height: 240px;&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5547561925868325618&quot; /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4sthO5CztQOaOSBFG56Sni3kHFyXfjguoU_Bn0oVhhUKnBxiHP0fD0J9Vp9qIJNm4uBTNOnm2Td2pVCbz3q4L5ZYslS7Gu0vbov_j2FsD9N9PC0uVuQ8tmCkbpZeBqx7IKMoW0A/s320/2010-11-19+16.43.18.jpg&quot; style=&quot;cursor:pointer; cursor:hand;width: 320px; height: 240px;&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5547561884446251330&quot; /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt; . اوليس حصولى على فيزة الحج بمثابة دليل على انى امتلك شهادة التطعيم ؟ لماذا اذا تضييع ال 45 دقيقة علينا وهل التاكد بهذا الشكل العشوائى لهة معنى اساسا. اذا ارادت المملكة ان تتاكد مرة اخرى اليس من الافضل والاصح ان يتم هذا العمل لكل حاج اثناء ختم الجوازات حيث يوجد طبيب بجانب ضابط الجوازات يتاكد من التطعيم لكل حاج اثناء&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt; فحص الضابط للجوازات وبذلك يكون التحقق الثانى من التطعيم منظم ويضمن ان التاكد قد تم لكل حاج؟ اذا ادهشك ذلك الامر فستدهش اكثر حين يطلبون منك التقدم لظابط الجوازات. وعندها سوف تجد مجموعة من الظباط يضحكون فيما بينهم وتحس منهم التباطؤ فى العمل وعدم الاهتمام بك والتحدث فيما بينهم بشكل مستمر عن امور شخصية من داخل كبائنهم التى يجلسون فيها وستلاحظ انهم لا يهتمون بعملهم الذى يؤدونة وهو فحص الجواز وختمة والسماح لك بالدخول فكانت هذه العملية بطيئة جدا ومما زاد الطين بلة انهم امروا الحجاج بعمل 4 طوابير امام 4 كبائن. وكان حظى فى كابينة ليس بداخلها ضابط, فطبعا كانت كل الط&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;وابير تتحرك الا طابورنا نحن ومما اثار الدهشة ان هناك ضابط واقف مهمتة &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;انك تلتزم بطابورك ولا تغادرة الى طابور&lt;/span&gt; اخر حتى وان كان طابورك ليس لدية ضابط جوازات. وقفنا فى هذا الطابور الذى لا يتحرك لمدة 25 دقيقة حتى رائينا فوج اخر من الحجاج قد وصل ووقتها جاء ضابط الى طابورنا وكان هو الطابور الوحيد المتكدس الان وباقى الطوابير فارغة. فقام احد الضباط بتوزيعنا على الثلاث كبائن الاخرى  وكانت الاجراءات عبارة عن اخذ صورة لك ثم بصماتك ثم ختم الباسبور. ولما حدث التكدث نصح احد الضباط زميلة بعدم عمل البصمات لان طابورة قد اصبح طويلا. اليس من الاصح ان يتوفر عدد كبير من الضباط استعدادا لاستقبال الاعداد الهائلة التى ستصل الى المملكة. واليس من الواجب ان يؤدى كل ضابط عملة بهمة وجدية؟&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;اما اصعب شيئ ستواجههة هو الشيك. هذا الشيك وحدة اخذ 4 ساعات من الوقوف والانتظار والبيروقراطية. ما هى قصة هذا الشيك فى الصورة.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJggRqhEs8IE0doOmPnAZ2Haur5nyubaTFPQBzUOsxsZRvjEJmwzNC1jk4jN2t0Gaz1OVsFwm01svrk1eogn7xY77oFz-rtwpSLe0FdBsjIpWmHtQXhPnUyG-jy2rcL97hsTW2iQ/s320/Check.jpg&quot; style=&quot;cursor:pointer; cursor:hand;width: 320px; height: 154px;&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5547634523320871618&quot; /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt; قصة الشيك هى ان السفارة السعودية فى الولايات المتحدة تطلب منك شيك بمبلغ 275 دولار لاصدار فيزة الحج. هذا الشيك هو نظير الخيام والتنقلات باتوبيسات المملكة اثناء الحج. ولكن السفاره لا تصرف الشيك. هم فقط يتحققون من الشيك ويكتبون كلمة &quot;دقق&quot;علية والتى تفيد ان الشيك شيك مقبول لديهم  ويعيدونة اليك مرة اخرى ويطلبون منك ان تسلمة الى الموظف فى مطار جدة. الكارثة ان الموظف فى مطار جدة يرفض الشيك ويخبرك ان هذا الشيك لا يمكن صرفة وانة غير مقبول لديهم وان عليك ان تدفع المبلغ نقدا بالعملة السعودية. كان الشيك الخاص بى صادر من بنك تشيس وهو اكبر بنك فى العالم ومع ذلك اخبرنى الموظف انهم لن يقبلوة وحتى بعد ان اوضحت لة ان السفارة اشرت بكلمة دقق اخبرنى بانهم لن يقبلوة ويجب ان ادفع نقدا وان كل الحجاج ترفض شيكاتهم ويدفعون المبلغ نقدا والا لن يستطيعون مغادرة المطار. طبعا كان على وعلى كل&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt; الحجاج ان نوافق وبالفعل طلبوا منع اتباع شخص معين والذى سوف يا&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;تى معى لاتمام اجراءات الدفع الكاش. اخذت الاجراءات 4 ساعات من ضمنهم ساعة لا يعرف احد اين جواز السفر الخاص بى. تبدا الاجراءات بزيارة قسم الكمبيوتر&lt;/span&gt; ثم الاستاذ عبد اللة ثم التسجيل ثم الكمبيوتر مرة اخرى. فى قسم الكمبيوتر اخبرونا ان نبشر ونستبشر وننتظر بالاسفل لمدة ساعة. وسوف نجد الباسبور جاهز لندفع المبلغ. انتظرت ساعة ولم يات الباسبور ذهبت الى قسم الكمبيوتر قالو بعثنا الباسبور ذهبت الى الموظف قال لم يات الباسبور لم يكم هناك اى احتمال اخر سوى ان الباسبور فى الطريق. انتظرت ساعة اخرى ثم طلبت مقابلة المدير لان لا احد يعلم اين باسبورى. اخبرنى المدير ان الباسبور لن ياتى هنا ولكن سوف يذهب مباشرة الى المبنى رقم 3 واشار الى كيف اصل الى هذا المبنى ذهبت الى المبنى وبالفعل كان باسبورى هناك ولا يعلم ذلك الا هذا المدير.  اعطونى الباسبور ووصل لادفع المبلغ فى الخازينة. فى الخازينة طلبو منى الذهاب الى مكتب الصرافة لتغيير عملة والعودة مرة اخرى للدفع. غيرت العملة ودفعت وحصلت على وصل يفيد انى دفعت.&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;طلبوا منى الرجوع مرة اخرى الى الموظف المسؤل عن الاوتوبيسات ليعطينى هذا الملصق الدائم على الباسبو&lt;/span&gt;ر والذى يفيد انى دفعت وذلك بدل الوصل الذى يفيد انى دفعت.&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-F_u-I0bKvRXMUcrhkjF3s59WhxKumwE7HkupapCPLtOcyCFbbMpxr8l8xrho9_aXj-Q2Iz2o4outYjPQJUbo6iLyfPo5QXCQUiMREa3FjTGcL87u8L6ldCLc25fTajwmQR1t6A/s320/2010-11-19+16.45.32.jpg&quot; style=&quot;cursor:pointer; cursor:hand;width: 320px; height: 240px;&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5547561935696391170&quot; /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-2UPhc4WxZA6Ad0Wk6dScTWxYErMb109B4s47ZaDqOaAcoybjwZKAo341Uu5YP7L6kqfegNSA56TZuTnko1gKnKmlMrmy2wdy7z5O8Dw4cm6EBTSP45_IV2DDvpMl1oI4QPD8qA/s1600/2010-11-19+16.45.43.jpg&quot;&gt;&lt;img style=&quot;cursor:pointer; cursor:hand;width: 320px; height: 240px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-2UPhc4WxZA6Ad0Wk6dScTWxYErMb109B4s47ZaDqOaAcoybjwZKAo341Uu5YP7L6kqfegNSA56TZuTnko1gKnKmlMrmy2wdy7z5O8Dw4cm6EBTSP45_IV2DDvpMl1oI4QPD8qA/s320/2010-11-19+16.45.43.jpg&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5547561945445873410&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;اربع  ساعات من المشى من مكتب الى مكتب وانا بملابس الاحرام. لا اطوف حول الكعبة ولا اصلى فى الحرم ولا اسعى بين الصفا والمروة ولا حتى اشرب ماء زمزم. 4 ساعات من المعاناة . 4 ساعات كان يمكن ان اؤدى عمرة ولكن ضيعتها علينا المملكة&lt;/span&gt; بالروتين والخطوات وزيارة المكاتب التى لا تعنى شيئا. اليس من الاصح ان تقبل السفارة فى الولايات المتحدة الشيك وترسل المبالغ الى السعودية بدلا من بهدلة الحاج. اليس باللة عليكم. هل ياتى الحاج ليذوق تجربة التنقل من مكتب الى مكتب. هل هذا يفيد الحاج. هل هل هل هل. هل يسمعنى احد فى المملكة. هل هذه هى السعودية التى تعلن فى التليفزيون ان الحج كان سهلا وميسرا. بماذا نصف هذا. فعلا لا ادرى ماذا اقول ولكن كان هذا اصعب شئ على وعلى زملائى وشيئ مؤسف جدا جدا جدا&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;ثم كان لى حظ لاذوق استهتار الموظفين وهى قصة الاستكر. فهم يعطون كل حاج ستكر. هذا الاستكر يصنف الحاج حسب الدولة القادم منها. فمثلا القادمون من امريكا واوروبا وتركيا لهم استكر يفيد ذلك. وبموجب هذا الاستكر يعرف الحاج اى خيام سيبيت فيها. يوجد استكر اخر لافريقيا وعند الحصول على ملصق افريقيا سوف تجد نفسك دائما مع القادمون من افريقيا. كان حظى السيء ان تكلمت مع الموظف باللغة العربية وبالرغم من ان باسبورى كندى واننى قادم من الولايات المتحدة وفيزتى صادرة من الولايات المتحدة الا ان الموظف افترض نظرا لانى اتحدث العربية معة بطلاقة انى قادم من افريقيا وقام بلصق الاستكر الافريقي على باسبورى. وعند اتمام الاجراءات لاحظ احد الموظفين اننى يجب ان احصل على استكر امريكا واخبرنى بالرجوع الى الموظف الاول وتغيير الاستكر فقمت بعمل ذلك. كان لى صديق اخر يدعى اسامة حصل ايضا على الاستكر الخاطئ لانة يتحدث العربية ولم يتنبة لذلك احد الا بعد 5 ساعات وذلك قبل ركوبة الاتوبيس المتجة الى مكة. اليس من الافضل وضع هذا الاستكر بمعرفة السفارة حين اصدار الفيزا. او جعلة جزءا من الفيزا اذا كان ولابد من هذا الاستكر.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfuw133C49Qme1HyQVAsnbsy-emmpHEpyIs4wfeEvi7jYMzBXi4qJEfLs7H9IKZeYLDwJQVg4YJovAe05IDxA1P4aaA5yM0VTbwaijJonT79skIP275QFNiRh9wdD0lcsSo1ihWA/s1600/2010-11-19+16.44.51.jpg&quot;&gt;&lt;img style=&quot;cursor:pointer; cursor:hand;width: 320px; height: 240px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfuw133C49Qme1HyQVAsnbsy-emmpHEpyIs4wfeEvi7jYMzBXi4qJEfLs7H9IKZeYLDwJQVg4YJovAe05IDxA1P4aaA5yM0VTbwaijJonT79skIP275QFNiRh9wdD0lcsSo1ihWA/s320/2010-11-19+16.44.51.jpg&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5547561916610206050&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;ثم استمرت رحلتى مع الاستهتار داخل مطار جدة وذلك حينما طلبو منى التوجة الى الاوتوبيسات للركوب للذهاب الى مكة. كان هناك نوعين من الاوتوبيسات اوتوبيس جماعى واوتوبيس فردى. طبعا انا فردى لانى جاى لوحدى ولكن كل السعوديين المسئولين يريدوننى ان اركب مع مجموعة. اشرح لهم ان ليس لي مجموعة وبالرغم من ذلك يطلبون منى الانتظار الى ان يجدو لى مجموعة ولا يفهمونى ولا يدلونى على اوتوبيس الفرادى. شاهد موضوعى احد عمال النظافة وهو مصرى وشاهد انتظارى بالساعات فجاء الى وقال لى سوف اقول لك ماذا تفعل ولكن انتظر بعد مغادرة هذا الرجل السعودى علشان ما يضرنيش. وبالفعل &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;غادر السعودى فقال لى عامل النظافة اذهب الى هذا الموقف الذى امامك اسمة فرادى (ج) وسوف تتحرك الى مكة فى 5 دقائق. وبالفعل ذهبت الى الموقف وركبت وتحرك الباص فى 20 دقيقة الى مكة وكان هذا هو اسرع انجاز تم فى مطار جدة بالنسبة لى بسبب خبرة عامل النظافة وحسبى اللة ونعم الوكيل فى هذا العذاب الذى تحملتة بلا داعى فى مطار جدة. والتعب والارهاق الذى اصابنى من جراء الاستهتار وعدم الجدية وخبرة الموظفين او المتطوعين&lt;/span&gt; فى المطار. اليس حريا بالمملكة تدريب العاملين تدريبا جيدا على عملهم وان كان فيهم متطوعين اليس من الواجب تدريبهم جيدا. اذا افتقرت المملكة الى متطوعين جادين اليس من الاجدى اعطاء الفرصة لاشخاص اخرين حتى وان لم يكونو سعوديين اذا توفرت فيهم الجدية والقدرة على مساعدة الحجاج. كيف يساعدنى عامل نظافة ويعقدنى موظف او متطوع منوط بمسؤلية ركوبى الباص كيف يفهمنى عامل نظافة ويفشل فى ذلك المسؤل؟&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;الاوتوبيس كان قصة اخرى. الاوتوبيس يظهر علية القدم والاهمال وبدون تكييف. وقال لى سائق الاوتوبيس انة يعمل هو وزميلة 24 ساعة وينامون فى الاوتوبيس. المهم انطلق الاوتوبيس فى شوارع جدة متجها الى مكة فى شوارع رديئة ورخيصة ليس بها خدمات طبعا لا يمكن مقارنتها بشوارع امريكا. وكنت توقعت ان ارى شوارع السعودية على مستوى عالى من التكنولوجيا والهندسة ولكنى وجدتها مثل شوارع مصر تماما. بعد 10 دقائق استوقفتنا الشرطة لمدة نصف ساعة  لتتاكد اننا حجاج رغم اننا قادمين من طريق المطار ولا يمكن ان يدخل هذا الطريق اى احد غير من هو قادم من المطار من صالة الحج. اليس من الممكن تخصيص هذا الطريق للخارجين من صالة الحج والغاء هذا الموقف للشرطة؟وصل الباص الى مكان يدعى التفويج وذلك بعد ساعة كاملة وانتظرنا هناك ساعة اخرى وذلك كى يتم اخبار السائق بالاماكن التى يجب ان يذهب اليها للمطوف وكان المطوف المنوط بى هو مطوف 36. المطوف هو الشخص الذى سوف يستلم باسبورك وياخذك الى الفندق. عند وقوفنا فى التفويج اعطونا ماء زمزم ووجبة عشاء وكانت لفتة جميلة جعلتنى اتفائل خير باللى جاى.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;وصلت الى المطوف بعد ساعة اخرى استقبلنى احد الموظفين لدية فاعطانى طعام وانتظرت ساعة لياتى باص صغير&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;ياخذنى الى الفندق وواجهت استهتار اخر وهو ان الموظف اخذنى الى فندق معفن يدعى الرحابة المكية وبعيد عن الحرم. فقلت لة هل هذا هو الفندق الذى سوف ابقى فية قال نعم. قلت ولكن شركة السياحة اخبرتنى اننى سوف اقيم فى فندق 5 نجوم امام الحرم يدعى فندق الصفوة. وهذا الفندق ليس لة اى نجوم بل هو تقريبا بنسيون وليس قريبا من الحرم بل هو فى مدينة اخرى ويدعى الرحابة المكية. قال لى هذا هو الفندق.&lt;/span&gt; طلبت منة الاتصال بشركة السياحة لان هذا لايمكن ان يكون الفندق فاتصل بشخص اخر بدل شركة السياحة ثم قال لى هذا هو الفندق فصممت على ان يتصل بشركة السياحة واخيرا اتصل بمديرة شركة السياحة فقالت لة ان هذا ليس الفندق وان علية التوجة بى الى فندق &lt;a href=&quot;http://www.youtube.com/watch?v=Y6smNvQqQNk&quot;&gt;الصفوة &lt;/a&gt;امام &lt;a href=&quot;http://www.youtube.com/watch?v=0k_ujwPgQYw&quot;&gt;الحرم &lt;/a&gt;(فيديو &lt;a href=&quot;http://www.youtube.com/watch?v=Hlmh5D8ipRE&quot;&gt;1&lt;/a&gt; &lt;a href=&quot;http://www.youtube.com/watch?v=dPKRJKExkH4&quot;&gt;2&lt;/a&gt;  &lt;a href=&quot;http://www.youtube.com/watch?v=50nQaWUuHLo&quot;&gt;3&lt;/a&gt; ). اخيرا اقتنع ولكن قال لى انة لا يعلم اين هو. المهم قلت لة انة امام الحرم فقال للسائق يذهب الى الحرم وهناك نسأل.&lt;/div&gt;&lt;div&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOS-7EuAdE0GVb4BF1wrlsn2LAPxQQEZMvPWpNO8K2mgNDSTtXuITfhMqR_p2jLV3gwRPFIwStyZj03FoWNlwdRaxttoyNQLuK7IL7On-0kHsdlheL6sjuLp9J6CgR51gxviRXBA/s200/HajjMecca.jpg&quot; style=&quot;cursor:pointer; cursor:hand;width: 200px; height: 126px;&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5558034981010506626&quot; /&gt;&lt;/div&gt;&lt;div&gt; ذهبنا فى نصف ساعة وسألنا ووجدنا الفندق ودخلت الغرفة وانا فى غاية التعب والارهاق. استغرق هذا الامر منذ هبوط الطائرة فى مطار جدة الى دخولى الغرفة 12 ساعة. وجدت فى الغرفة شخص سوف يقيم معى استغرق نفس الموضوع معة 24 ساعة ومر بمما مررت انا بة من الشيك الى الاستكر الى الاوتوبيس الى الفندق الخطاء وحسبنا اللة ونعم الوكيل فعلا والحمد للة على اننا حافظنا على الهدوء والسكينة وتجنبنا الجدال. اليس من الاجدر بالمطوفين وموظفيهم معرفة اماكن الفنادق والتاكد من الفندق الذى سينزل بة كل حاج؟ اليس من الضرورى ان تهتم المملكة بالحجاج بدلا من وضع الصعاب والعراقيل امامهم لافساد حجهم وتضييع وقتهم وتشوية صورة الاسلام والمسلمين.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;ذهبت فورا وانا فى غاية الانهاك والتعب الى الحرم لابدأ العمرة. ذهبت الى الطواف ورأيت &lt;a href=&quot;http://www.youtube.com/watch?v=wToNUFswmnw&quot;&gt;الكعبة &lt;/a&gt;بيت اللة الاول لاول مرة فى حياتى وانتابنى شعور جميل لروئية البيت الذى عظمة اللة وشعرت فعلا انى ضيف عند اللة. قمت بالطواف ثم الصلاة فى مقام ابراهيم ثم شرب ماء زمزم ثم السعى والتقصير. واتممت العمرة والحمد للة وانا فى غاية التعب. ثم صعدت الى الغرفة لخلع ملابس الاحرام والتى اتسخت فى مطار جدة والرحلة من المطوف الى الفندق الى الانتظار فى التفويج الى الى الى ...... اكثر مما حدث لها اثناء العمرة.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;بعد ان انتهيت من العمرة صعدت الى الفندق ونمت متعبا جدا. سعيد بأداء العمرة ولكن فى غاية التعب والارهاق وكم كنت اتمنى ان يكون لدى بعض القوة لاقرأ بعضا من القران او الذهاب لعمل عمرة اخرى او البقاء فى الحرم والنظر لاول بيت وضع للناس او انتظر &lt;a href=&quot;http://www.youtube.com/watch?v=060ChfS-GrU&quot;&gt;لصلاة الفجر فى الحرم&lt;/a&gt; ولكن كان التعب شديدا فعلا.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;فى اليوم التالى نزلت استفسر من اين يمكننى الذهاب الى التنعيم للقيام بعمرة اخرى واذا بى افاجأ بان مكة تعتبر فعلا &lt;a href=&quot;http://www.youtube.com/watch?v=TMHGfq-ZJls&quot;&gt;مدينة فقيرة&lt;/a&gt; ماديا وحضاريا بكل اسف. &lt;a href=&quot;http://www.youtube.com/watch?v=5R0fMgzIrB4&quot;&gt;فالاوتوبيسات فى الشارع بلا مواقف ولا نظام&lt;/a&gt;. الشوارع تشبة العتبة فى مصر. هل تعمل المملكة على جعل هذا المكان الذى يزورة البلايين يظهر بمظهر جيد ام لا تهتم على الاطلاق. هل هذا هو مستوى الحب لاطهر مكان على وجة الارض؟ هذا فعلا غير مقبول. ما رائيت جعلنى اعرف فعلا ان المسلمين حقا متاخرين.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;قضيت فى مكة 6 ايام بدون مشاكل حيث انى انزل للصلاة فى اوقاتها وليس لدى اى مشكلة كانو 6 ايام فى منتهى الروعة والجمال (فيديو &lt;a href=&quot;http://www.youtube.com/watch?v=Ws15ySBfQKI&quot;&gt;1&lt;/a&gt; &lt;a href=&quot;http://www.youtube.com/watch?v=dMOmGuwbep8&quot;&gt;2&lt;/a&gt; &lt;a href=&quot;http://www.youtube.com/watch?v=kC-tuFflqx8&quot;&gt;3&lt;/a&gt; ) ثم كان يجب علينا السفر الى المدينة لزيارة المسجد النبوى فاتجهنا الى المطار. وفى المطار تحس انك فى مطار بنجلاديش او السودان او افقر دولة فى العالم. بشر على الارض وناس بتتخانق. وحين تسال احد الاشخاص كم لك من وقت منتظر هنا يقول لك 24 ساعة اخرين  ، يقولون 16 ساعة وهكذا. لايوجد نظام ولا تنظيم حياة سبهللا وزعيق وخناقات على كل حاجة الشنط ، الحجز ، المواعيد ، الدخول الخروج.... كل حاجة.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;بعد تجربة تعب بسيطة ماتستاهلش ذكرها لانها تعتبر عادية مقارنة باللى شفناة قبل كدة وصلنا المدينة. ونزلنا بفندق اسمة هارمونى وذهبنا  الى المسجد النبوى الجميل وقضينا 4 ايام من زيارة قبر الرسول محمد صلى اللة علية وسلم واكرمنا اللة بالصلاة فى الروضة كذا مرة وزيارة الاماكن التاريخية والاماكن المقدسة مثل &lt;/span&gt;&lt;a href=&quot;http://www.youtube.com/watch?v=OIy6fjTWqTg&quot;&gt;غار حراء&lt;/a&gt; (فيديو &lt;a href=&quot;http://www.youtube.com/watch?v=Ft1KimK8wy4&quot;&gt;1&lt;/a&gt; &lt;a href=&quot;http://www.youtube.com/watch?v=LCWP2s71zhE&quot;&gt;2&lt;/a&gt; &lt;a href=&quot;http://www.youtube.com/watch?v=Gko6Xjn0-Bg&quot;&gt;3&lt;/a&gt; &lt;a href=&quot;http://www.youtube.com/watch?v=wkAPzh3fQBs&quot;&gt;4&lt;/a&gt; &lt;a href=&quot;http://www.youtube.com/watch?v=IZSrW0_GUBk&quot;&gt;5&lt;/a&gt;  )وبعد 4 ايام توجب علينا العودة الى مكة لبدأ مناسك الحج.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;ارسلت لنا وزارة الحج اوتوبيس مكتوب علية اوتوبيس مدارس لنقل الطالبات. ليس بة تكييف فى هذا الحر الشديد وليس بة ايضا اماكن  لحقائبنا نظرا لانة اوتوبيس مدارس. ونظرا لاننا لسنا طلبة فشنطنا ليست شنط طلبة بل هى شنط مسافرين. رفضنا فى الاول الركوب لاننا ممكن نفطس وايضا عندما راى السائق شنطنا قال انة لن ياخذ الشنط وان الشنط يجب ان نشحنها على حسابنا فى اى وسيلة اخرى. &lt;/div&gt;&lt;div&gt;&lt;div&gt;ودة طبعا غير ان الاوتوبيس بدلا من ان ياتى الساعة 2 ظهرا جة الساعه 7 مساءا. تدخلت مندوبة شركة السياحة واشتكت للوزارة فاخبروها ان هذا هو الموجود اذا كان عاجبكم. فشرحت لنا الموقف وفى الاخير اضطررنا للركوب كما اضطر السائق الى قبول حقائبنا ووضعناها على كراسى الاوتوبيس لان الاوتوبيس ليس بة مكان للحقائب. وبدات رحلة العذاب التى استغرقت 16 ساعة من المدينة الى مكة فى طرق تعبانة رخيصة الثمن وزحام شديد جدا. هذه الرحلة التى كان يجب ان تستغرق 4 ساعات فقط.&lt;/div&gt;&lt;div&gt;ووصل الباص الى التفويج ثم ذهبنا الى فندق فى مدينة العزيزية وضعنا بة الشنط وبدانا الاستعداد للحج والذى اصبح غدا بدايتة.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt; اول يوم فى الحج يدعى يوم التروية ، وفى يوم التروية يجب ان ياتى اوتوبيس لنقل الحجاج الى خيام منى &lt;/div&gt;&lt;div&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIhjWJYiJBkCWZnCVYs9isroqMqmaWxxQt9wnkJlP3S3baQoZ62eMF-96hP3TX6YBcdkrPWuz2pTPNd9-HcBqzIhWE4GBEdohSsvmRd2MXe1Yn6duyamHuiqUZHfkisi2z8Px0GA/s200/HajjMinna.jpg&quot; style=&quot;cursor:pointer; cursor:hand;width: 200px; height: 132px;&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5558034878109698898&quot; /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;للمبيت هناك اخبرتنا شركة السياحة انهم ذاهبون للحصول على الاوتوبيس والرجوع لنا. ذهبوا الى المطوف للحصول على التصريح ثم الى الجراج للحصول على الاوتوبيس. انتظروا فى الجراج من الساعة 8 مساءا الى 7 صباح اليوم التالى للحصول على اوتوبيسهم. المهم اتى الاوتوبيس ومعة سائق ومرشد. المرشد هو شخص خبير بطرق مكة  يوفرة المطوف ويعرف ايضا اماكن الخيام الخاصة بمطوفة . المرشد الذى حصلنا علية هو هذا الباشا الكبير قوى اللى فى الصورة. &lt;/div&gt;&lt;div&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRJ0c35hn_D3GMwr15jRs0VMfq6XOUlfRCq6Ce3WLhGI4XpsRXxylqlhreFEQIB7PtfE2AVz8new9UDOaxzYWL-InQlemJsoQdfYhIo1KG0uIh-Jx1wVnnODIrx_c4nrZVmmy6bQ/s320/morshed.jpg&quot; style=&quot;cursor:pointer; cursor:hand;width: 320px; height: 240px;&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5548696473594054178&quot; /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;بعد ان ركب الحجاج طلبت شركة السياحة من هذا المرشد اخذنا الى الخيام المخصصة للمطوف الذى يعمل معة واذا بالطامة الكبرى. هذا المرشد الخبير لا يعرف اين مكان الخيام ولا منى ولا طرق مكة. وكمان طور اللة فى برسيمة والمشكلة انة ما بيقولش معرفش. ذهبنا الى مكان الخيام ولكن هيهات هيهات. مررنا بجميع الخيام فى عز زحمة المرور ولم يعرف بسلامتة خيامنا وطبعا من المستحيل النزول والسؤال وكان هذا الموقف فعلا يدعوا الى الغضب الشديد فقامت شركة السياحة بالاشارة للسائق بالذهاب فورا الى المطوف. قام السائق باخذنا الى المطوف ووصلنا بيننا العجائز والمرضى انا نفسى كدت انفجر ولكنى كظمت غيظى جدا. لماذا يعطينا المطوف شخص لايمكنة ارشادنا الى اماكن الخيام. لماذا الاستهتار لماذا تعرضوا الحاج لاحتمال ان يجادل او يغضب. فعلا هذا غير مقبول كنت احدث نفسى قائلا ان المملكة تدمر الحج ولا يمكن لاى شخص او حكومة ان يكون بهذا الاستهتار وقلة الامانة فى هذا الموقف. وقتها اتضح لى ان مشقة الحج الحقيقية هى فى التعامل مع القائمين على الحج ومع النظام الذى وضعتة المملكة بدون وعى وبدون تخطيط ولا حتى استعداد حقيقيين والذى يعرض الحاج لفقدان حجة ومالة بل ويعرضة لاكتساب ذنوب بدلا من مساعدتة على عمل اعمال يجزى بها. &lt;/div&gt;&lt;div&gt;تتسبب هذه التصرفات فى فقد الروحانيات وتاخذ الحاج الى اتجاة اخر وعالم اخر حيث تستفذ غضبة وتدفعة الى الاحساس بالظلم والاهمال وعدم الامانة. انا كحاج تسائلت اكثر من مرة هلى هؤلاء مسلمين؟ هل هذه الحكومة مسلمة. هل المطوفين والمسئولين مسلمين؟&lt;/div&gt;&lt;div&gt;على اى حال قام المطوف بعدما راى الحجاج امامة باستبدال الباص طبعا لان الباص حالتة مزرية واعطانا المساعد الخاص بة لياخذنا الى الخيام ونحن فى غاية الضيق نحاول ان نكظم غيظنا ونتسغفر ونسبح ونحافظ على حجنا ولا نجادل مع احد ولا نشتكى وحسبنا اللة ونعم الوكيل.&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;  ذهبنا الى &lt;a href=&quot;http://www.youtube.com/watch?v=wrgJpBVDHkM&quot;&gt;منى &lt;/a&gt;للمبيت ثم صلينا الفجر وتوجهنا الى عرفات( فيديوا  &lt;a href=&quot;http://www.youtube.com/watch?v=IBMGi1THYcI&quot;&gt;1&lt;/a&gt;  &lt;a href=&quot;http://www.youtube.com/watch?v=kf3QZ4IkHbQ&quot;&gt;2&lt;/a&gt; )ثم الى المزدلفة &lt;/div&gt;&lt;div&gt;وكان يوم المزدلفة هو يوم المذبحة البشرية بمعنى الكلمة. وعدد كبير من الحجاج قد فقد حجة فى هذا اليوم بعد الخناقات على الاوتوبيسات والتدافع الشديد وعدم النظام. الذى لا يتصورة عقل. يوجد فى المزدلفة ما يقرب من 3 مليون شخص وتاتى الاوتوبيسات لنقلهم بشكل عشوائى بدون ادنى تنظيم. اى حد بيركب فى اى اوتوبيس ومافيش بنى ادم بيقولوهم على حاجة ولا بينظمهم مافيش تواجد امنى ولا نظامى لاى مسئول هرجلة. انا رئيت بعينى اوتوبيس نصفة فارغ والادهى ان سائق الباص قرر انة يطلع نص حمولة فى هذا الموقف الرهيب بدلا من ان يملأ الاوتوبيس ورافض رفضا تاما ان يفتح الباب. ولا حتى ينظر الى الناس الواقفين فى الشارع الذين يطلبون منة فتح الباب وفى الاخير وجدت شيخ الجامع الذى معنا والذى هو قدوة يخبط على باب الاوتوبيس ويهدد  السائق بان يفتح الباب ولا حياة لمن تنادى. وبالاخير اضطر الى فتح الباب لاننا لم نتركة يستمر فى القيادة. &lt;/div&gt;&lt;div&gt;اشعرنى هذا الموقف ان القائمين على الحج ليس لديهم ادنى فكرة عن قدراتهم ولا عن عدد الحجاج ولا عن قدرة طرقهم ولا اى شئ. استهتار وتخلف للاسف وبدائية تدعوا للغضب. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;رجعنا الى منى وبعد كل هذا التعب والمشقة يتوجب علينا الذهاب الى الجمرات لالقاء جمرة العقبة. 3 مليون حاج يمشون 4 كيلو بدون اى تنظيم وفى الحر الشديد. كل ما فعلتة المملكة انها اغلقت الطريق امام السيارات حتى يستطيع الحجاج المشى. كنت اتوقع ان ارى سيور متحركة لتساعد الحجاج على هذه ال4 كيلو ولكن طبعا تبخل المملكة على الحج بمثل هذه الافكار.&lt;/div&gt;&lt;div&gt;ان المشى الى الجمرات فعلا يعرض الحياة للخطر ويعظم المشقة التى يتعرض لها الحجاج. وصلنا لجمرة العقبة والقيناها وطبعا تهنا عند الرجوع لان العلامات فى المنطقة غير موجودة فلا تعلم اين انت ولا كيف تعود من حيث اتيت. لا يوجد تنظيم بالمرة تجربة صعبة جدا جدا جدا . المهم عدنا الى الخيام وذهبنا فى اليوم التالى لالقاء الجمرات والقاء الجمرات بالرغم من كل التعديلات التى فعلتها المملكة فى السابق الا انة لايزال خطر. فان الناس لايعلمون ماذا يفعلون بعد القاء الجمرات. بعد القاء الجمرات يخرجون عن طريق دفع الناس مما يعرض اكثرهم للوقوع على الارض. او يلقون الحصى على بعضهم البعض بدون وعى او يخبطك واحد فى وشك وهو بيرمى وهكذا. كم كنت اتمنى ان تضع الوزارة علامات ارشادية تخبر الحاج كيف يلقى الجمرات وكيف يخرج. فان انسب الوسائل فى القاء الجمرات ان يلقى الجمرات ويستمر فى السير ولا يخرج من مكانة لانة سوف يجد نفسة قد خرج فعلا اذا استمر فى السير فى طريقة  ولا داعى للتدافع. كل المطلوب هو علامات ارشادية ولوحات مكتوب عليها باللغات الرئيسية مع بعض الرسومات  كيفية الدخول والخروج ويا حبذا لو كانت هذه اللوحات اثناء السير من &lt;a href=&quot;http://www.youtube.com/watch?v=UptOnA-gtMI&quot;&gt;الخيام &lt;/a&gt;الى الجمرات.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;بعد القاء الجمرات فى اليوم التالى واذا كنت من المتعجلين يتوجب عليك الذهاب الى مكة لعمل طواف الافاضة والوداع ثم التوجة الى جدة. للسفر.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;لتذهب الى مكة فى هذا اليوم سوف تجد انة ليس امامك غير المشى او لو كنت من المحظوظين تركب موتوسيكل. لم كن من المحظوظين فمشيت الى مكة فى ساعتين.  طواف الافاضة والوداع والسعى بين الصفا والمروة هايكون صعب جدا من المستحيلات لدرجة اثناء الطواف كان دعائى هو يارب قوينى لاتمام الطواف. تعب شديد جدا جدا جدا فوق الاحتمال. ومرة اخرى لا تدرى الناس كيف يخرجون من الطواف فيتدافعون للخروج وكنت اتمنى تعليمهم كيف يخرجون تدريجيا بدلا من التدافع كم كنت اتمنى ان يعطينى الفندق ورقة تخبرنى بانسب طريقة للخروج بعد انتهاء الطواف او وضع علامات ورسومات تخبر الحجاج كيفية الخروج. بعد ان اتممت الطواف قمت بالسعى بين الصفا والمروة. وبعد كام شوط بتنسى مين هوا الصفا ومين هوة المروة ولا يمكن تلاقى يافطة واحدة تقولك فين الصفا وفين المروة تقوم تسال الحجاج. واحد يقولك دة الصفا والتانى يقولك لا دا المروة. هو ماينفعش المملكة ووزارة الحج يحطوا يافطة واضحة عند الصفا وواحدة عند المروة؟ ما علينا بعد السعى كان يجب على العودة سريعا لاخذ حقائبى والتوجة لجدة ومرة اخرى اصطدم بالفقر فى مكة . فلا يوجد مواصلات . لا يوجد غير استغلال حيث عرض على سائق سيارة نصف نقل ان ياخذنى الى العزيزية مقابل 400 ريال طبعا مضطر توافق ولكن بعد ان انتظرت 10 دقائق لم ينطلق لانة يريد اكثر من راكب. نزلت وكنت محظوظا لارى موتوسيكل وافق على نقلى الى العزيزية مقابل 150 ريال. وصلت اخذت حقائبى واتجهت الى جدة احمد اللة على اتمام الحج وعندى سعادة شديدة بان الحج تم بنجاح ونسيت كل ما حدث واصبح كل الذى مريت بة ذكرى اخشى ان اقول انها ذكرى جميلة. اصبح تاخير الباص والمرشد الذى لايعلم اين الخيام والتاخر فى مطار جدة والشيك الذى لم يقبلوة مواقف اضحك منها واتذكرها العمر كلة ولكننى فعلا اريد للمسلمين ان يكونوا متقدمين. والحج هو اعظم مناسبة لذلك والحج هو اعظم فرصة ليعلم العالم عننا اذا نظمنا الحج واصبح الحج مناسبة راقية جدا من حيث النظام فسوف نكون فعلا تقدمنا فى شئ.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;اتمنى ان يستفيد حجاج السنة المقبلة من هذه الموضوع كما اتمنى ان يصل ما كتبت للمسؤلين عن الحج فى المملكة ويعلمون انهم السبب فى معاناة وكارثة فيقومون بصرف المال على دراسة سريعه لحل المشكلات التى اوردتها. ونصيحتى لهم الاستعانة بغير السعوديين والاستعانة باشخاص مشهود لهم بالكفاءة والسرعة وليس الجهل والبيروقراطية. اتمنى ان تكون هناك فائدة من هذه الموضوع الذى كتبتة ولا اريد بة سوى اللة وارجو منك ان كان لديك تعليق ان تضيفة لاستفيد منة ويستفيد من يقرا هذه المقال. وشكرا.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aliayman.blogspot.com/feeds/5391697673392219675/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/13014608/5391697673392219675' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/5391697673392219675'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/5391697673392219675'/><link rel='alternate' type='text/html' href='http://aliayman.blogspot.com/2010/12/2010.html' title='تجربة الحج 2010 ونصائح للحج فى السنين المقبلة'/><author><name>Ayman Ali</name><uri>http://www.blogger.com/profile/04089520193997921426</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKvUKAMsijXeg19hAydX5kYx8jhwScaIJfKaek8nf0MQ7XRt6oJG70KDPbzhHw2IrHn0n4ZkSh98tNQyU25tEDAgr-dg0evqF3NQarfEvLxEPubltwW6jbETKlCRVkjw/s220/Pic314.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNp2jJDCdKyQuvJWWW9jHbymH6UrXzZxV5MK_KLjpPQYWgspEcSi3qZsCr5JZbFrsA6p66tyMJG607G56Kl_ue6xAkz6nCYPdIYnN_xONJ9wCBWy4-Xoe2LKAYP68dwD43fBYaEw/s72-c/2010-11-19+16.45.16.jpg" height="72" width="72"/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13014608.post-4682240012149761745</id><published>2010-10-28T11:45:00.000-07:00</published><updated>2010-10-28T12:52:06.716-07:00</updated><title type='text'>Webfarm and Servername</title><content type='html'>If your &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_0&quot;&gt;WCf&lt;/span&gt; service is hosted with a commercial hosting provider which may or many not be using a &lt;span class=&quot;blsp-spelling-corrected&quot; id=&quot;SPELLING_ERROR_1&quot;&gt;web farm&lt;/span&gt;, you may find that when you browse to your service that it shows a different address for the &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_2&quot;&gt;svcutil&lt;/span&gt;.&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_3&quot;&gt;exe&lt;/span&gt; than the &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_4&quot;&gt;dns&lt;/span&gt; address and when you download the &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_5&quot;&gt;wsdl&lt;/span&gt;/&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_6&quot;&gt;svcutil&lt;/span&gt; that this &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_7&quot;&gt;wsdl&lt;/span&gt;/&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_8&quot;&gt;svcutil&lt;/span&gt; is referencing the internal server name instead of your domain name.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;For example, if you purchased a domain name called &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_9&quot;&gt;aliayman&lt;/span&gt;.com and your hosting company is storing and hosting your files on an internal server called &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_10&quot;&gt;HostingCompanyServer&lt;/span&gt;01. Now let&#39;s imagine you created a web service called &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_11&quot;&gt;MyService&lt;/span&gt;.&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_12&quot;&gt;svc&lt;/span&gt;. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now when you browse to http://aliayman.com/MyService.svc&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;you will see your service information but you will notice the line that contain the &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_13&quot;&gt;svcutil&lt;/span&gt;.&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_14&quot;&gt;exe&lt;/span&gt; is telling you to get the &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_15&quot;&gt;wsdl&lt;/span&gt; from &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_16&quot;&gt;svcutil&lt;/span&gt;.&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_17&quot;&gt;exe&lt;/span&gt; http://HostingCompanyServer01/Myservice.svc&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;this is a problem because you can not access this server name, you can access &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_18&quot;&gt;aliayman&lt;/span&gt;.com but you can not access this specific host name. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Also, when you try to reference this service in your code you will find that your reference is pointing to &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_19&quot;&gt;HostingCompanyServer&lt;/span&gt;01 instead of &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_20&quot;&gt;aliayman&lt;/span&gt;.com&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;You have to solutions to this problem.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Solution 1: after you create the reference search your code for &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_21&quot;&gt;HostingCompanyServer&lt;/span&gt;01 and change it to &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_22&quot;&gt;aliayman&lt;/span&gt;.com and at least your program will be able to deal with the web service. You will find &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_21&quot; style=&quot;background-color: rgb(255, 255, 0); &quot;&gt;HostingCompanyServer&lt;/span&gt;01  in *.wsdl and *.svcinfo files.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Solution 2: which is the best solution is to change the binding of the &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_23&quot;&gt;IIS&lt;/span&gt; installed on &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_24&quot;&gt;HostingCompanyServer&lt;/span&gt;01. This is off course if you have access to this &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_25&quot;&gt;IIS&lt;/span&gt;. to view the binding find your site identifier number (let&#39;s assume it is 1) and issue these commands to view your binding. (notice your site identifier 1 is used before &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_26&quot;&gt;ServerBinding&lt;/span&gt; and &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_27&quot;&gt;SecureBinding&lt;/span&gt; below)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_28&quot;&gt;cscript&lt;/span&gt;.&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_29&quot;&gt;exe&lt;/span&gt; //&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_30&quot;&gt;nologo&lt;/span&gt; %&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_31&quot;&gt;systemdrive&lt;/span&gt;%\&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_32&quot;&gt;inetpub&lt;/span&gt;\&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_33&quot;&gt;adminscripts&lt;/span&gt;\&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_34&quot;&gt;adsutil&lt;/span&gt;.&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_35&quot;&gt;vbs&lt;/span&gt; get W3&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_36&quot;&gt;SVC&lt;/span&gt;/1/&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_37&quot;&gt;ServerBindings&lt;/span&gt; &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_38&quot;&gt;cscript&lt;/span&gt;.&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_39&quot;&gt;exe&lt;/span&gt; //&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_40&quot;&gt;nologo&lt;/span&gt; %&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_41&quot;&gt;systemdrive&lt;/span&gt;%\&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_42&quot;&gt;inetpub&lt;/span&gt;\&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_43&quot;&gt;adminscripts&lt;/span&gt;\&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_44&quot;&gt;adsutil&lt;/span&gt;.&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_45&quot;&gt;vbs&lt;/span&gt; get W3&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_46&quot;&gt;SVC&lt;/span&gt;/1/&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_47&quot;&gt;SecureBindings&lt;/span&gt; &lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;then issue these commands to correct the binding&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_48&quot;&gt;cscript&lt;/span&gt;.&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_49&quot;&gt;exe&lt;/span&gt; //&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_50&quot;&gt;nologo&lt;/span&gt; %&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_51&quot;&gt;systemdrive&lt;/span&gt;%\&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_52&quot;&gt;inetpub&lt;/span&gt;\&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_53&quot;&gt;adminscripts&lt;/span&gt;\&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_54&quot;&gt;adsutil&lt;/span&gt;.&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_55&quot;&gt;vbs&lt;/span&gt; set W3&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_56&quot;&gt;SVC&lt;/span&gt;/1/&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_57&quot;&gt;ServerBindings&lt;/span&gt;  &quot;80:&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_58&quot;&gt;aliayman&lt;/span&gt;.com&quot;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_59&quot;&gt;cscript&lt;/span&gt;.&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_60&quot;&gt;exe&lt;/span&gt; //&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_61&quot;&gt;nologo&lt;/span&gt; %&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_62&quot;&gt;systemdrive&lt;/span&gt;%\&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_63&quot;&gt;inetpub&lt;/span&gt;\&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_64&quot;&gt;adminscripts&lt;/span&gt;\&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_65&quot;&gt;adsutil&lt;/span&gt;.&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_66&quot;&gt;vbs&lt;/span&gt; set W3&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_67&quot;&gt;SVC&lt;/span&gt;/1/&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_68&quot;&gt;SecureBindings&lt;/span&gt;  &quot;443:&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_69&quot;&gt;aliayman&lt;/span&gt;.com&quot;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Then restart your application pool&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I found these advices about the binding in this &lt;span class=&quot;blsp-spelling-corrected&quot; id=&quot;SPELLING_ERROR_70&quot;&gt;blog post&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;a href=&quot;http://gavinmckay.wordpress.com/2009/03/24/howto-fix-wcf-host-name-on-iis/&quot;&gt;http://gavinmckay.wordpress.com/2009/03/24/howto-fix-wcf-host-name-on-iis/&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aliayman.blogspot.com/feeds/4682240012149761745/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/13014608/4682240012149761745' title='12 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/4682240012149761745'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/4682240012149761745'/><link rel='alternate' type='text/html' href='http://aliayman.blogspot.com/2010/10/webfarm-and-servername.html' title='Webfarm and Servername'/><author><name>Ayman Ali</name><uri>http://www.blogger.com/profile/04089520193997921426</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKvUKAMsijXeg19hAydX5kYx8jhwScaIJfKaek8nf0MQ7XRt6oJG70KDPbzhHw2IrHn0n4ZkSh98tNQyU25tEDAgr-dg0evqF3NQarfEvLxEPubltwW6jbETKlCRVkjw/s220/Pic314.jpg'/></author><thr:total>12</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13014608.post-1275653198110489854</id><published>2010-10-13T15:05:00.000-07:00</published><updated>2011-03-14T11:36:49.562-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="WCF Security https authorization authentication"/><title type='text'>WCF over Https and User Name/Password</title><content type='html'>&lt;div&gt;Web services are mandatory nowadays and for a long time security has been a tough thing to do. Now with WCF you can just configure wsHttpBinding and you&#39;re done with a great deal of security. This binding will encrypt the communication between the web service and the client, however the client should be able to do the same encryption and decryption that the service understands. Hence, your client should be a .Net client which may not always the case. You may have a Java Client which will not be able to perform wsHttpBinding, or you may have a .Net client but you want to send Ajax requests to your WCF service which again Javascript will not be able to perform wsHttpBinding because you need a .Net to do it and .Net is not available to Javascript. At the end of the day you may find that wsHttpBinding is not that great if you are not totally in a Microsoft world.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In order to have your web service available to the entire world, including Ajax and Java then you will need to make your service available under https protocol. This way you guarantee the entire world can talk to your service securely and the parameters you are sending to the web service operations are encrypted by the client automatically and decrypted by the service. Also, the service response is encrypted for you automatically using the standards public/private key strong encryption and decrypted by the client automatically.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In order to enable SSL for your WCF follow the steps outlined in this &lt;a href=&quot;http://www.techrepublic.com/blog/howdoi/how-do-i-request-and-install-ssl-certificates-in-iis-70/159&quot;&gt;article&lt;/a&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;1- &lt;b&gt;Get SSL Certificate:&lt;/b&gt; You will need to purchase and &lt;a href=&quot;http://www.petri.co.il/configure_ssl_on_your_website_with_iis.htm&quot;&gt;configure&lt;/a&gt; an SSL certificate for your domain name. You can buy it from VeriSign starting from $99 or you can generate your own by &lt;a href=&quot;http://www.isaserver.org/img/upl/vpnkitbeta2/installenterpriseca.htm&quot;&gt;installing Windows 2003 Certificate Authority&lt;/a&gt; then request a certificate for your machine and issue it from that certificate authority. If you use your own certificate issued by certificate authority you will encounter a trust issue and you may need to write &lt;a href=&quot;http://brainof-dave.blogspot.com/2008/08/remote-certificate-is-invalid-according.html&quot;&gt;one line of code to avoid this trust issue&lt;/a&gt;. If you encounter this trust issue you will get the message&lt;span&gt;&lt;span&gt; &quot;The remote certificate is invalid according to the validation procedure&quot;, you can avoid this message by writing this line of code &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 19px; white-space: pre;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace; font-size: 13px; color: rgb(51, 51, 51); line-height: 19px; white-space: pre; &quot;&gt;ServicePointManager.ServerCertificateValidationCallback = &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace; font-size: 13px; color: rgb(51, 51, 51); line-height: 19px; white-space: pre; &quot;&gt;delegate(object sender, X509Certificate certificate, X509Chain chain,&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace; font-size: 13px; color: rgb(51, 51, 51); line-height: 19px; white-space: pre; &quot;&gt;SslPolicyErrors sslPolicyErrors) { return true; };&lt;/span&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif; font-size: 13px; color: rgb(51, 51, 51); line-height: 19px; &quot;&gt;&lt;pre&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(0, 0, 0); font-family: Georgia, serif; line-height: normal; white-space: normal; font-size: 16px; &quot;&gt;2- &lt;b&gt;Bind IIS:&lt;/b&gt; You will need to make sure that your IIS is bound to your domain name. usually when you host a WCF on an IIS server IIS will always recognize the local server name and does not recognize the domain name. In order to learn about this issue and find out what to do read this article &lt;a href=&quot;http://gavinmckay.wordpress.com/2009/03/24/howto-fix-wcf-host-name-on-iis/&quot;&gt;here&lt;/a&gt; But in a nutshell, you will need to issue two command&lt;/span&gt;&lt;/pre&gt;&lt;/span&gt;&lt;div&gt;cscript.exe //nologo %systemdrive%\inetpub\adminscripts\adsutil.vbs set W3SVC/1/ServerBindings &quot;:80:Your_Domain_Name&quot;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;cscript.exe //nologo %systemdrive%\inetpub\adminscripts\adsutil.vbs set  W3SVC/1/SecureBindings &quot;:443:Your_Domain_Name&quot;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;3- &lt;b&gt;Enable Secure Metadata:&lt;/b&gt; Then for the service metadata  set &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Consolas, &#39;Courier New&#39;, Courier, monospace; font-size: small; line-height: 18px; white-space: pre; &quot;&gt;httpsGetEnabled=&lt;span class=&quot;str&quot; style=&quot;color: rgb(0, 96, 128); &quot;&gt;&quot;True&quot;&lt;/span&gt; in your service config &lt;a href=&quot;http://cgeers.wordpress.com/2009/08/07/wcf-over-https/&quot;&gt;more info&lt;/a&gt;. &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Consolas, &#39;Courier New&#39;, Courier, monospace; font-size: small; line-height: 18px; white-space: pre; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, Times, serif; white-space: normal; font-size: 12px; color: rgb(85, 85, 85); &quot;&gt;&lt;pre style=&quot;font-size: small; color: black; font-family: Consolas, &#39;Courier New&#39;, Courier, monospace; background-color: rgb(255, 255, 255); margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot;&gt;&lt;blockquote&gt;&lt;servicebehaviors&gt;&lt;/servicebehaviors&gt;&lt;/blockquote&gt;&lt;/pre&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Consolas, &#39;Courier New&#39;, Courier, monospace; font-size: small; line-height: 18px; white-space: pre; &quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Check listing 7 &lt;a href=&quot;http://cgeers.wordpress.com/2009/08/07/wcf-over-https/&quot;&gt;here&lt;/a&gt; &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;4- &lt;b&gt;Set Binding Security Mode:&lt;/b&gt; Define binding properties for basicHttpBinding as per Listing 8 &lt;a href=&quot;http://cgeers.wordpress.com/2009/08/07/wcf-over-https/&quot;&gt;here&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;5- &lt;b&gt;Attach Binding configuration to EndPoint:&lt;/b&gt; Add this binding configuration to the service end point as per listing 9 &lt;a href=&quot;http://cgeers.wordpress.com/2009/08/07/wcf-over-https/&quot;&gt;here&lt;/a&gt; &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;6- &lt;b&gt;Set Mex endpoint to &lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Consolas, &#39;Courier New&#39;, Courier, monospace; font-size: small; color: rgb(0, 96, 128); line-height: 18px; white-space: pre; &quot;&gt;&lt;b&gt;mexHttpsBinding:&lt;/b&gt;  &lt;/span&gt;As per listing 9 &lt;a href=&quot;http://cgeers.wordpress.com/2009/08/07/wcf-over-https/&quot;&gt;here&lt;/a&gt; &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;7- &lt;b&gt;Set the baseAddress:&lt;/b&gt; You can set the base address optionally as per listing 9 &lt;a href=&quot;http://cgeers.wordpress.com/2009/08/07/wcf-over-https/&quot;&gt;here&lt;/a&gt; &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;You WCF Service is now secure and you can browse to it as follows. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDPLKFFG3dZ-Q7hVWlTWPjEeds3D34KRqTtCqil_FABs1c6KiSYfWtHsRpM4cLrWgnoee9OAHFBJfKO3V_1aLNFjDBPig_7rKavnDjBOC0fi6Ocr7OjusWCIus8i2BdOIsvXluOA/s320/Browse.JPG&quot; style=&quot;cursor:pointer; cursor:hand;width: 320px; height: 142px;&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5550248722685647458&quot; /&gt;&lt;/div&gt;&lt;div&gt;When you try to call your service you should see the following in fiddler. one connection on port 443 and the entire communication is encrypted.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxgQrTlV2CT071PtPtrC8k6tA3-MBJAAYfiu7SGPANm97pI1CmsKh9B6ecSJM9np3sSBpjw9NuQ0fJUvd0f-NI6A-tOUq6so2VVjOEu8ZjTamj91xKhUEweQZyqxIKC5rFmwFWeQ/s320/fiddler.JPG&quot; style=&quot;cursor:pointer; cursor:hand;width: 320px; height: 195px;&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5550249512067052402&quot; /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;8- &lt;b&gt;Require Secure Channel:&lt;/b&gt; Now, using IIS go to the Default web site or the site that has your service and go to Directory Security, Secure Communication, Edit and click Require Secure Channel (SSL). Now your service is not available under http. It is only available under https here is how to change the setting&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJk0q2wFBcLd64VgWNx0_29RGA80SUZDMz5Q5JHyWZ99-Vf2czhhrHnXpxzRZIIOCCL7wiH-MdOxvogChwfB_O4uXD7X-7XXZBntXKvHu1SrbK6PgNEVS71gw9UA-Ck4qgvz9Vug/s320/require.JPG&quot; style=&quot;cursor:pointer; cursor:hand;width: 306px; height: 320px;&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5550965829756406866&quot; /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now if you try to browse to the service using http you will get the error &quot;The page must be viewed over a secure channel as per the image below&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4-s0pI6QiJ7ZTM9Hde3P3v4l1fQEWz6d5WPYL5rAxOYC0XCIBIBTltCmvpZE4Zv8QbdHngc-C0ueBZ8q6Ud_FB6VYHfJir6VDddrExNXi_67RJ91afxFBOOK4yFjCQRuKj1YQjw/s320/mustbesecured.JPG&quot; style=&quot;cursor:pointer; cursor:hand;width: 320px; height: 124px;&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5550965836713079378&quot; /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;9- &lt;b&gt;Automatically redirect http to https: &lt;/b&gt;If you want to redirect http to https you can read the information in this &lt;a href=&quot;http://raoulpop.com/2007/08/07/automatic-redirect-from-http-to-https/&quot;&gt;post &lt;/a&gt;or this &lt;a href=&quot;http://kojiroh.wordpress.com/2006/09/06/hello-world/&quot;&gt;one&lt;/a&gt;. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Additional References for SSL&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;http://taciturndiscourse.com/services/ssl-for-webhttpbinding/&quot;&gt;http://taciturndiscourse.com/services/ssl-for-webhttpbinding/&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;http://www.codeproject.com/KB/WCF/WCFSSL.aspx&quot;&gt;http://www.codeproject.com/KB/WCF/WCFSSL.aspx&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;For the user name and password: You will need to do the following&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;1- &lt;b&gt;Send credentials at the client:&lt;/b&gt; In your client code make sure to send the credentials. If your client is a .Net client you can send the credentials as follows &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt; &lt;/span&gt;  var svc = new MySecureService.MySecureServiceClient();&lt;/div&gt;&lt;div&gt;&lt;b&gt;          var cred = new NetworkCredential(&quot;MyUserName&quot;,&quot;MyPassword&quot;);&lt;/b&gt;&lt;/div&gt;&lt;div&gt;          svc.ClientCredentials = cred;&lt;/div&gt;&lt;div&gt;          var result = svc.Operation1();&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;2- &lt;b&gt;Implement IHttpModule:&lt;/b&gt; Create a class and implement System.Web.IHttpModule, you can use the following code&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;   public class UserAuthentication : IHttpModule&lt;/div&gt;&lt;div&gt;    {&lt;/div&gt;&lt;div&gt;        public void Init(HttpApplication context)&lt;/div&gt;&lt;div&gt;        {&lt;/div&gt;&lt;div&gt;            context.AuthenticateRequest += new EventHandler(this.OnAuthenticateRequest);&lt;/div&gt;&lt;div&gt;            context.EndRequest += new EventHandler(this.OnEndRequest);&lt;/div&gt;&lt;div&gt;        }&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;        public void OnAuthenticateRequest(object sender, EventArgs e)&lt;/div&gt;&lt;div&gt;        {&lt;/div&gt;&lt;div&gt;            var application = (HttpApplication)sender;&lt;/div&gt;&lt;div&gt;            var header = application.Request.Headers[&quot;Authorization&quot;];&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;            try&lt;/div&gt;&lt;div&gt;            {&lt;/div&gt;&lt;div&gt;                if (!string.IsNullOrEmpty(header))&lt;/div&gt;&lt;div&gt;                {&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;                    header = header.Trim();&lt;/div&gt;&lt;div&gt;                    if (header.IndexOf(&quot;Basic&quot;, 0) != 0)&lt;/div&gt;&lt;div&gt;                    {&lt;/div&gt;&lt;div&gt;                        throw new Exception(&quot;Access Denied.&quot;);&lt;/div&gt;&lt;div&gt;                    }&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;                    var encodedCredentials = header.Substring(6);&lt;/div&gt;&lt;div&gt;                    var decodedBytes = Convert.FromBase64String(encodedCredentials);&lt;/div&gt;&lt;div&gt;                    var s = new ASCIIEncoding().GetString(decodedBytes);&lt;/div&gt;&lt;div&gt;                    var credentials = s.Split(new char[] { &#39;:&#39; });&lt;/div&gt;&lt;div&gt;                    var username = credentials[0];&lt;/div&gt;&lt;div&gt;                    var password = credentials[1];&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;                    if (!ValidateUser(username, password))&lt;/div&gt;&lt;div&gt;                    {&lt;/div&gt;&lt;div&gt;                        throw new Exception(&quot;Access Denied.&quot;);&lt;/div&gt;&lt;div&gt;                    }&lt;/div&gt;&lt;div&gt;                }&lt;/div&gt;&lt;div&gt;                else&lt;/div&gt;&lt;div&gt;                {&lt;/div&gt;&lt;div&gt;                    throw new Exception(&quot;Access Denied.&quot;);&lt;/div&gt;&lt;div&gt;                }&lt;/div&gt;&lt;div&gt;            }&lt;/div&gt;&lt;div&gt;            catch (Exception ex)&lt;/div&gt;&lt;div&gt;            {&lt;/div&gt;&lt;div&gt;                application.Response.StatusCode = 401;&lt;/div&gt;&lt;div&gt;                application.Response.StatusDescription = ex.Message;&lt;/div&gt;&lt;div&gt;                &lt;span&gt;&lt;span&gt;application.Response.Write(&quot;&quot; + ex.Message + &quot;&quot;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;                application.Response.End();&lt;/div&gt;&lt;div&gt;            }&lt;/div&gt;&lt;div&gt;        }&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;        public void OnEndRequest(object sender, EventArgs e)&lt;/div&gt;&lt;div&gt;        {&lt;/div&gt;&lt;div&gt;            if (HttpContext.Current.Response.StatusCode == 401)&lt;/div&gt;&lt;div&gt;            {&lt;/div&gt;&lt;div&gt;                var context = HttpContext.Current;&lt;/div&gt;&lt;div&gt;                context.Response.StatusCode = 401;&lt;/div&gt;&lt;div&gt;                context.Response.AddHeader(&quot;WWW-Authenticate&quot;, &quot;Basic Realm&quot;);&lt;/div&gt;&lt;div&gt;            }&lt;/div&gt;&lt;div&gt;        }&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;        public void Dispose()&lt;/div&gt;&lt;div&gt;        {&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;        }&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;        private bool ValidateUser(string username, string password)&lt;/div&gt;&lt;div&gt;        {&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;            // Insert Custom User Validation here&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;            var validUsername = &quot;MyUserName&quot;;&lt;/div&gt;&lt;div&gt;            var validPassword = &quot;MyPassword&quot;;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;            if (username == validUsername &amp;amp;&amp;amp;&lt;/div&gt;&lt;div&gt;                password == validPassword)&lt;/div&gt;&lt;div&gt;            {&lt;/div&gt;&lt;div&gt;                return true;&lt;/div&gt;&lt;div&gt;            }&lt;/div&gt;&lt;div&gt;            else&lt;/div&gt;&lt;div&gt;            {&lt;/div&gt;&lt;div&gt;                return false;&lt;/div&gt;&lt;div&gt;            }       &lt;/div&gt;&lt;div&gt;            &lt;/div&gt;&lt;div&gt;        }&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;3- &lt;b&gt;Add Module to your web.config:&lt;/b&gt; In the modules section add this module in your web.config as follows &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt; name=&quot;UserAuthentication&quot; type=&quot;MyNameSpace.UserAuthentication&quot;&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aliayman.blogspot.com/feeds/1275653198110489854/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/13014608/1275653198110489854' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/1275653198110489854'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/1275653198110489854'/><link rel='alternate' type='text/html' href='http://aliayman.blogspot.com/2010/10/wcf-over-https-and-user-namepassword.html' title='WCF over Https and User Name/Password'/><author><name>Ayman Ali</name><uri>http://www.blogger.com/profile/04089520193997921426</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKvUKAMsijXeg19hAydX5kYx8jhwScaIJfKaek8nf0MQ7XRt6oJG70KDPbzhHw2IrHn0n4ZkSh98tNQyU25tEDAgr-dg0evqF3NQarfEvLxEPubltwW6jbETKlCRVkjw/s220/Pic314.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDPLKFFG3dZ-Q7hVWlTWPjEeds3D34KRqTtCqil_FABs1c6KiSYfWtHsRpM4cLrWgnoee9OAHFBJfKO3V_1aLNFjDBPig_7rKavnDjBOC0fi6Ocr7OjusWCIus8i2BdOIsvXluOA/s72-c/Browse.JPG" height="72" width="72"/><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13014608.post-7800668889670536605</id><published>2010-09-09T13:32:00.001-07:00</published><updated>2010-09-09T13:35:53.130-07:00</updated><title type='text'>Sand Castle in two minutes</title><content type='html'>In order to generate documentation using sand castle here is what is needed&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;1- Install SandCastle 2.6 from &lt;a href=&quot;http://sandcastle.codeplex.com/releases/view/47665&quot;&gt;here&lt;/a&gt;&lt;/div&gt;&lt;div&gt;2- Install SandCastle Help File Builder &lt;a href=&quot;http://shfb.codeplex.com/&quot;&gt;here&lt;/a&gt;&lt;/div&gt;&lt;div&gt;3- Make sure you have Microsoft help compiler 1.x &lt;a href=&quot;http://www.innovasys.com/support/htmlhelpcompiler.aspx&quot;&gt;here&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Once you have the above, start the SandCastle Help File Builder, add your XML documentation and references and build your chm. if you want to build a website (which is MSDN like) just choose website in the HelpFile Format&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aliayman.blogspot.com/feeds/7800668889670536605/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/13014608/7800668889670536605' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/7800668889670536605'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/7800668889670536605'/><link rel='alternate' type='text/html' href='http://aliayman.blogspot.com/2010/09/sand-castle-in-two-minutes.html' title='Sand Castle in two minutes'/><author><name>Ayman Ali</name><uri>http://www.blogger.com/profile/04089520193997921426</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKvUKAMsijXeg19hAydX5kYx8jhwScaIJfKaek8nf0MQ7XRt6oJG70KDPbzhHw2IrHn0n4ZkSh98tNQyU25tEDAgr-dg0evqF3NQarfEvLxEPubltwW6jbETKlCRVkjw/s220/Pic314.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13014608.post-1288969330151225111</id><published>2010-08-27T14:40:00.001-07:00</published><updated>2010-08-27T15:21:41.696-07:00</updated><title type='text'>Tic Tac Toe Algorithm</title><content type='html'>If you are given a Tic &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_0&quot;&gt;Tac&lt;/span&gt; Toe board. How do you find if a specific player is a winner.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The straight forward algorithm is going to start from the first row and the first column. the algorithm will start by checking if this square is an X or if it is an O.&lt;/div&gt;&lt;div&gt;assume we are trying to find if X is the winner.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If this square is an X, then we will increment the number of X&#39;s found in row 1 and the number of X&#39;s found in column 1 and the number of X&#39;s found in the 270 degrees diagonal.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Because this first row and first column square is a member of all these three possibilities. in order to support this algorithm then we need a storage that will hold the number of X&#39;s found in Row 1, the number of X&#39;s found in row 2, the number of X&#39;s found in row 3, the number of X&#39;s found in column 1. the number of X&#39;s found in column 2. the number of X&#39;s found in column 3. the number of X&#39;s found in the 270 degrees diagonal and finally the number of X&#39;s found in 45 degrees diagonal.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;We can create a class called Tic &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_1&quot;&gt;Tac&lt;/span&gt; Toe as follows.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;    class &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_2&quot;&gt;TicTacToe&lt;/span&gt;&lt;/div&gt;&lt;div&gt;    {&lt;/div&gt;&lt;div&gt;        private &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_3&quot;&gt;readonly&lt;/span&gt; int[] _rows; //array to store the number of X&#39;s found in each row&lt;/div&gt;&lt;div&gt;        private &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_4&quot;&gt;readonly&lt;/span&gt; int[] _cols; //array to store the number of X&#39;s found in each column&lt;/div&gt;&lt;div&gt;        private int _270Diagonal; //one variable to store the number of X&#39;s found in the 270 degrees diagonal&lt;/div&gt;&lt;div&gt;        private int _45Diagonal;//one variable to store the number of X&#39;s found in the 45 degrees diagonal&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;        private &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_5&quot;&gt;readonly&lt;/span&gt; int _&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_6&quot;&gt;boardSize&lt;/span&gt;; //Caching the board size&lt;/div&gt;&lt;div&gt;        private &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_7&quot;&gt;readonly&lt;/span&gt; int _&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_8&quot;&gt;boardSizeMinusOne&lt;/span&gt;; //cashing the board size minus one in order to perform the subtraction only once&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;        public &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_9&quot;&gt;TicTacToe&lt;/span&gt;(int &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_10&quot;&gt;boardSize&lt;/span&gt;) // constructor will set the rows and columns array sizes, cash the board size and calculate the &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_11&quot;&gt;boardsize&lt;/span&gt; - 1&lt;/div&gt;&lt;div&gt;        {&lt;/div&gt;&lt;div&gt;            _rows = new int[&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_12&quot;&gt;boardSize&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;            _cols = new int[&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_13&quot;&gt;boardSize&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;            _&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_14&quot;&gt;boardSize&lt;/span&gt; = &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_15&quot;&gt;boardSize&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;            _&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_16&quot;&gt;boardSizeMinusOne&lt;/span&gt; = _&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_17&quot;&gt;boardSize&lt;/span&gt; - 1;&lt;/div&gt;&lt;div&gt;            &lt;/div&gt;&lt;div&gt;        }&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;        //Function to add a Square taken by player X and return true if X won due to this addition&lt;/div&gt;&lt;div&gt;        public &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_18&quot;&gt;bool&lt;/span&gt; &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_19&quot;&gt;AddSquare&lt;/span&gt;(int row, int col)&lt;/div&gt;&lt;div&gt;        {&lt;/div&gt;&lt;div&gt;                if (_rows[row] == _&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_20&quot;&gt;boardSizeMinusOne&lt;/span&gt;) return true; //Since X exist in this row, check if there were two more (or board -1). if so, adding this X will make X take all the squares in this row and hence win&lt;/div&gt;&lt;div&gt;                _rows[row] += 1; //otherwise increase the number of X&#39;s in this row&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;                if (_cols[col] == _&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_21&quot;&gt;boardSizeMinusOne&lt;/span&gt;) return true;&lt;/div&gt;&lt;div&gt;                _cols[col] += 1;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;                if (row == col) //this is the 270 degrees diagonal&lt;/div&gt;&lt;div&gt;                {&lt;/div&gt;&lt;div&gt;                    if (_270Diagonal == _&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_22&quot;&gt;boardSizeMinusOne&lt;/span&gt;) return true;&lt;/div&gt;&lt;div&gt;                    _270Diagonal += 1;&lt;/div&gt;&lt;div&gt;                }&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;                if (((row + col) == _&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_23&quot;&gt;boardSizeMinusOne&lt;/span&gt;)) //this is the 45 degrees diagonal&lt;/div&gt;&lt;div&gt;                {&lt;/div&gt;&lt;div&gt;                    if (_45Diagonal == _&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_24&quot;&gt;boardSizeMinusOne&lt;/span&gt;) return true;&lt;/div&gt;&lt;div&gt;                    _45Diagonal += 1;&lt;/div&gt;&lt;div&gt;                }&lt;/div&gt;&lt;div&gt;            return false; //No winner yet&lt;/div&gt;&lt;div&gt;        }&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This class contains the &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_25&quot;&gt;AddSquare&lt;/span&gt; function which will add a square taken by X and will let us know if X has won due to this addition.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This algorithm will visit every single square only in the worst case scenario and at this time the Big O will be n to the power of 2.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;in order to test this class we would create a sample board and use the class as follows&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;        static void Main(string[] &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_26&quot;&gt;args&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;        {&lt;/div&gt;&lt;div&gt;            var board = new int[3,3];&lt;/div&gt;&lt;div&gt;            board[0, 0] = 0;&lt;/div&gt;&lt;div&gt;            board[0, 1] = 0;&lt;/div&gt;&lt;div&gt;            board[0, 2] = 1;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;            board[1, 0] = 0;&lt;/div&gt;&lt;div&gt;            board[1, 1] = 0;&lt;/div&gt;&lt;div&gt;            board[1, 2] = 1;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;            board[2, 0] = 1;&lt;/div&gt;&lt;div&gt;            board[2, 1] = 0;&lt;/div&gt;&lt;div&gt;            board[2, 2] = 1;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;            var &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_27&quot;&gt;ticTacToe&lt;/span&gt; = new &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_28&quot;&gt;TicTacToe&lt;/span&gt;(3);&lt;/div&gt;&lt;div&gt;            for(var row = 0; row != 3; row++)&lt;/div&gt;&lt;div&gt;            {&lt;/div&gt;&lt;div&gt;                for (var col = 0; col != 3; col++)&lt;/div&gt;&lt;div&gt;                {&lt;/div&gt;&lt;div&gt;                    if (board[row,col] == 1)&lt;/div&gt;&lt;div&gt;                        if (&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_29&quot;&gt;ticTacToe&lt;/span&gt;.&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_30&quot;&gt;AddSquare&lt;/span&gt;(row, col))&lt;/div&gt;&lt;div&gt;                        {&lt;/div&gt;&lt;div&gt;                            Console.&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_31&quot;&gt;WriteLine&lt;/span&gt;(&quot;Player 1 has won the game.&quot;);&lt;/div&gt;&lt;div&gt;                            Console.&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_32&quot;&gt;ReadKey&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;                            return;&lt;/div&gt;&lt;div&gt;                        }&lt;/div&gt;&lt;div&gt;                }&lt;/div&gt;&lt;div&gt;            }&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;            Console.&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_33&quot;&gt;WriteLine&lt;/span&gt;(&quot;No one won&quot;);&lt;/div&gt;&lt;div&gt;            Console.&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_34&quot;&gt;ReadKey&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;        }&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;a better algorithm could select the squares to examine more carefully and improve the worst case scenario. If we look at the board, we find that the middle square is responsible  about 4 different possibilities of winning, and if this square does not contain X, then that means 4 different possibilities are eliminated. secondly the corner squares are responsible for 3 different possibilities and if a corner square does not contain X then 3 possibilities are eliminated. so, if we start with the middle square and then the corner squares the worst case scenario will indeed be improved.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Not only that, but if we can store the importance of every square and how many possibilities it is a member of, then during the examination of the board we will find that some squares will not affect the board and hence we should not check it. here is an illustration.&lt;/div&gt;&lt;div&gt;&lt;table class=&quot;MsoTableGrid&quot; border=&quot;1&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; style=&quot;border-collapse:collapse;border:none;mso-border-alt:solid black .5pt;  mso-border-themecolor:text1;mso-yfti-tbllook:1184;mso-padding-alt:0in 5.4pt 0in 5.4pt&quot;&gt;  &lt;tbody&gt;&lt;tr style=&quot;mso-yfti-irow:0;mso-yfti-firstrow:yes&quot;&gt;   &lt;td width=&quot;25&quot; valign=&quot;top&quot; style=&quot;width:18.9pt;border:solid black 1.0pt;   mso-border-themecolor:text1;mso-border-alt:solid black .5pt;mso-border-themecolor:   text1;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal&quot;&gt;3&lt;/p&gt;   &lt;/td&gt;   &lt;td width=&quot;24&quot; valign=&quot;top&quot; style=&quot;width:.25in;border:solid black 1.0pt;   mso-border-themecolor:text1;border-left:none;mso-border-left-alt:solid black .5pt;   mso-border-left-themecolor:text1;mso-border-alt:solid black .5pt;mso-border-themecolor:   text1;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal&quot;&gt;2&lt;/p&gt;   &lt;/td&gt;   &lt;td width=&quot;24&quot; valign=&quot;top&quot; style=&quot;width:.25in;border:solid black 1.0pt;   mso-border-themecolor:text1;border-left:none;mso-border-left-alt:solid black .5pt;   mso-border-left-themecolor:text1;mso-border-alt:solid black .5pt;mso-border-themecolor:   text1;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal&quot;&gt;3&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:1&quot;&gt;   &lt;td width=&quot;25&quot; valign=&quot;top&quot; style=&quot;width:18.9pt;border:solid black 1.0pt;   mso-border-themecolor:text1;border-top:none;mso-border-top-alt:solid black .5pt;   mso-border-top-themecolor:text1;mso-border-alt:solid black .5pt;mso-border-themecolor:   text1;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal&quot;&gt;2&lt;/p&gt;   &lt;/td&gt;   &lt;td width=&quot;24&quot; valign=&quot;top&quot; style=&quot;width:.25in;border-top:none;border-left:none;   border-bottom:solid black 1.0pt;mso-border-bottom-themecolor:text1;   border-right:solid black 1.0pt;mso-border-right-themecolor:text1;mso-border-top-alt:   solid black .5pt;mso-border-top-themecolor:text1;mso-border-left-alt:solid black .5pt;   mso-border-left-themecolor:text1;mso-border-alt:solid black .5pt;mso-border-themecolor:   text1;background:#BFBFBF;mso-shading:windowtext;mso-pattern:gray-25 auto;   padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal&quot;&gt;4&lt;/p&gt;   &lt;/td&gt;   &lt;td width=&quot;24&quot; valign=&quot;top&quot; style=&quot;width:.25in;border-top:none;border-left:none;   border-bottom:solid black 1.0pt;mso-border-bottom-themecolor:text1;   border-right:solid black 1.0pt;mso-border-right-themecolor:text1;mso-border-top-alt:   solid black .5pt;mso-border-top-themecolor:text1;mso-border-left-alt:solid black .5pt;   mso-border-left-themecolor:text1;mso-border-alt:solid black .5pt;mso-border-themecolor:   text1;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal&quot;&gt;2&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:2;mso-yfti-lastrow:yes&quot;&gt;   &lt;td width=&quot;25&quot; valign=&quot;top&quot; style=&quot;width:18.9pt;border:solid black 1.0pt;   mso-border-themecolor:text1;border-top:none;mso-border-top-alt:solid black .5pt;   mso-border-top-themecolor:text1;mso-border-alt:solid black .5pt;mso-border-themecolor:   text1;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal&quot;&gt;3&lt;/p&gt;   &lt;/td&gt;   &lt;td width=&quot;24&quot; valign=&quot;top&quot; style=&quot;width:.25in;border-top:none;border-left:none;   border-bottom:solid black 1.0pt;mso-border-bottom-themecolor:text1;   border-right:solid black 1.0pt;mso-border-right-themecolor:text1;mso-border-top-alt:   solid black .5pt;mso-border-top-themecolor:text1;mso-border-left-alt:solid black .5pt;   mso-border-left-themecolor:text1;mso-border-alt:solid black .5pt;mso-border-themecolor:   text1;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal&quot;&gt;2&lt;/p&gt;   &lt;/td&gt;   &lt;td width=&quot;24&quot; valign=&quot;top&quot; style=&quot;width:.25in;border-top:none;border-left:none;   border-bottom:solid black 1.0pt;mso-border-bottom-themecolor:text1;   border-right:solid black 1.0pt;mso-border-right-themecolor:text1;mso-border-top-alt:   solid black .5pt;mso-border-top-themecolor:text1;mso-border-left-alt:solid black .5pt;   mso-border-left-themecolor:text1;mso-border-alt:solid black .5pt;mso-border-themecolor:   text1;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal&quot;&gt;3&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;o:p&gt; In the board above, the center square has a weight of 4, and that means it is part of 4 possibilities to win the board. the possibilities are, row 2, column 2, and the diagonals. if we check this square first and it turns out it does not contain an X, then those 4 possibilities are eliminated and the weights of the affected squares can be decreased as per the diagram below&lt;/o:p&gt;&lt;/p&gt;  &lt;table class=&quot;MsoTableGrid&quot; border=&quot;1&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; style=&quot;border-collapse:collapse;border:none;mso-border-alt:solid black .5pt;  mso-border-themecolor:text1;mso-yfti-tbllook:1184;mso-padding-alt:0in 5.4pt 0in 5.4pt&quot;&gt;  &lt;tbody&gt;&lt;tr style=&quot;mso-yfti-irow:0;mso-yfti-firstrow:yes&quot;&gt;   &lt;td width=&quot;25&quot; valign=&quot;top&quot; style=&quot;width:18.9pt;border:solid black 1.0pt;   mso-border-themecolor:text1;mso-border-alt:solid black .5pt;mso-border-themecolor:   text1;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal&quot;&gt;2&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td width=&quot;24&quot; valign=&quot;top&quot; style=&quot;width:.25in;border:solid black 1.0pt;   mso-border-themecolor:text1;border-left:none;mso-border-left-alt:solid black .5pt;   mso-border-left-themecolor:text1;mso-border-alt:solid black .5pt;mso-border-themecolor:   text1;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal&quot;&gt;1&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td width=&quot;24&quot; valign=&quot;top&quot; style=&quot;width:.25in;border:solid black 1.0pt;   mso-border-themecolor:text1;border-left:none;mso-border-left-alt:solid black .5pt;   mso-border-left-themecolor:text1;mso-border-alt:solid black .5pt;mso-border-themecolor:   text1;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal&quot;&gt;2&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:1&quot;&gt;   &lt;td width=&quot;25&quot; valign=&quot;top&quot; style=&quot;width:18.9pt;border:solid black 1.0pt;   mso-border-themecolor:text1;border-top:none;mso-border-top-alt:solid black .5pt;   mso-border-top-themecolor:text1;mso-border-alt:solid black .5pt;mso-border-themecolor:   text1;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal&quot;&gt;1&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td width=&quot;24&quot; valign=&quot;top&quot; style=&quot;width:.25in;border-top:none;border-left:none;   border-bottom:solid black 1.0pt;mso-border-bottom-themecolor:text1;   border-right:solid black 1.0pt;mso-border-right-themecolor:text1;mso-border-top-alt:   solid black .5pt;mso-border-top-themecolor:text1;mso-border-left-alt:solid black .5pt;   mso-border-left-themecolor:text1;mso-border-alt:solid black .5pt;mso-border-themecolor:   text1;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal&quot;&gt;-&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td width=&quot;24&quot; valign=&quot;top&quot; style=&quot;width:.25in;border-top:none;border-left:none;   border-bottom:solid black 1.0pt;mso-border-bottom-themecolor:text1;   border-right:solid black 1.0pt;mso-border-right-themecolor:text1;mso-border-top-alt:   solid black .5pt;mso-border-top-themecolor:text1;mso-border-left-alt:solid black .5pt;   mso-border-left-themecolor:text1;mso-border-alt:solid black .5pt;mso-border-themecolor:   text1;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal&quot;&gt;1&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:2;mso-yfti-lastrow:yes&quot;&gt;   &lt;td width=&quot;25&quot; valign=&quot;top&quot; style=&quot;width:18.9pt;border:solid black 1.0pt;   mso-border-themecolor:text1;border-top:none;mso-border-top-alt:solid black .5pt;   mso-border-top-themecolor:text1;mso-border-alt:solid black .5pt;mso-border-themecolor:   text1;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal&quot;&gt;2&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td width=&quot;24&quot; valign=&quot;top&quot; style=&quot;width:.25in;border-top:none;border-left:none;   border-bottom:solid black 1.0pt;mso-border-bottom-themecolor:text1;   border-right:solid black 1.0pt;mso-border-right-themecolor:text1;mso-border-top-alt:   solid black .5pt;mso-border-top-themecolor:text1;mso-border-left-alt:solid black .5pt;   mso-border-left-themecolor:text1;mso-border-alt:solid black .5pt;mso-border-themecolor:   text1;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal&quot;&gt;1&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td width=&quot;24&quot; valign=&quot;top&quot; style=&quot;width:.25in;border-top:none;border-left:none;   border-bottom:solid black 1.0pt;mso-border-bottom-themecolor:text1;   border-right:solid black 1.0pt;mso-border-right-themecolor:text1;mso-border-top-alt:   solid black .5pt;mso-border-top-themecolor:text1;mso-border-left-alt:solid black .5pt;   mso-border-left-themecolor:text1;mso-border-alt:solid black .5pt;mso-border-themecolor:   text1;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal&quot;&gt;2&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;o:p&gt; in the board above, the center square is not an X and that means for example for the top left corner square, there is only two possibilities that this square can be part of. the two possibilities are row 1 and column 1, because the 270 degrees diagonal that it was part of has been eliminated. &lt;/o:p&gt;&lt;/p&gt;  &lt;table class=&quot;MsoTableGrid&quot; border=&quot;1&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; style=&quot;border-collapse:collapse;border:none;mso-border-alt:solid black .5pt;  mso-border-themecolor:text1;mso-yfti-tbllook:1184;mso-padding-alt:0in 5.4pt 0in 5.4pt&quot;&gt;  &lt;tbody&gt;&lt;tr style=&quot;mso-yfti-irow:0;mso-yfti-firstrow:yes&quot;&gt;   &lt;td width=&quot;25&quot; valign=&quot;top&quot; style=&quot;width:18.9pt;border:solid black 1.0pt;   mso-border-themecolor:text1;mso-border-alt:solid black .5pt;mso-border-themecolor:   text1;background:#BFBFBF;mso-shading:windowtext;mso-pattern:gray-25 auto;   padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal&quot;&gt;2&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td width=&quot;24&quot; valign=&quot;top&quot; style=&quot;width:.25in;border:solid black 1.0pt;   mso-border-themecolor:text1;border-left:none;mso-border-left-alt:solid black .5pt;   mso-border-left-themecolor:text1;mso-border-alt:solid black .5pt;mso-border-themecolor:   text1;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal&quot;&gt;1&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td width=&quot;24&quot; valign=&quot;top&quot; style=&quot;width:.25in;border:solid black 1.0pt;   mso-border-themecolor:text1;border-left:none;mso-border-left-alt:solid black .5pt;   mso-border-left-themecolor:text1;mso-border-alt:solid black .5pt;mso-border-themecolor:   text1;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal&quot;&gt;2&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:1&quot;&gt;   &lt;td width=&quot;25&quot; valign=&quot;top&quot; style=&quot;width:18.9pt;border:solid black 1.0pt;   mso-border-themecolor:text1;border-top:none;mso-border-top-alt:solid black .5pt;   mso-border-top-themecolor:text1;mso-border-alt:solid black .5pt;mso-border-themecolor:   text1;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal&quot;&gt;1&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td width=&quot;24&quot; valign=&quot;top&quot; style=&quot;width:.25in;border-top:none;border-left:none;   border-bottom:solid black 1.0pt;mso-border-bottom-themecolor:text1;   border-right:solid black 1.0pt;mso-border-right-themecolor:text1;mso-border-top-alt:   solid black .5pt;mso-border-top-themecolor:text1;mso-border-left-alt:solid black .5pt;   mso-border-left-themecolor:text1;mso-border-alt:solid black .5pt;mso-border-themecolor:   text1;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal&quot;&gt;-&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td width=&quot;24&quot; valign=&quot;top&quot; style=&quot;width:.25in;border-top:none;border-left:none;   border-bottom:solid black 1.0pt;mso-border-bottom-themecolor:text1;   border-right:solid black 1.0pt;mso-border-right-themecolor:text1;mso-border-top-alt:   solid black .5pt;mso-border-top-themecolor:text1;mso-border-left-alt:solid black .5pt;   mso-border-left-themecolor:text1;mso-border-alt:solid black .5pt;mso-border-themecolor:   text1;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal&quot;&gt;1&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:2;mso-yfti-lastrow:yes&quot;&gt;   &lt;td width=&quot;25&quot; valign=&quot;top&quot; style=&quot;width:18.9pt;border:solid black 1.0pt;   mso-border-themecolor:text1;border-top:none;mso-border-top-alt:solid black .5pt;   mso-border-top-themecolor:text1;mso-border-alt:solid black .5pt;mso-border-themecolor:   text1;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal&quot;&gt;2&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td width=&quot;24&quot; valign=&quot;top&quot; style=&quot;width:.25in;border-top:none;border-left:none;   border-bottom:solid black 1.0pt;mso-border-bottom-themecolor:text1;   border-right:solid black 1.0pt;mso-border-right-themecolor:text1;mso-border-top-alt:   solid black .5pt;mso-border-top-themecolor:text1;mso-border-left-alt:solid black .5pt;   mso-border-left-themecolor:text1;mso-border-alt:solid black .5pt;mso-border-themecolor:   text1;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal&quot;&gt;1&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td width=&quot;24&quot; valign=&quot;top&quot; style=&quot;width:.25in;border-top:none;border-left:none;   border-bottom:solid black 1.0pt;mso-border-bottom-themecolor:text1;   border-right:solid black 1.0pt;mso-border-right-themecolor:text1;mso-border-top-alt:   solid black .5pt;mso-border-top-themecolor:text1;mso-border-left-alt:solid black .5pt;   mso-border-left-themecolor:text1;mso-border-alt:solid black .5pt;mso-border-themecolor:   text1;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal&quot;&gt;2&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;Now can can go ahead and pick the square which the highest weight, in case there are more than one, we can pick anyone, let&#39;s pick the top left corner and check it. let&#39;s assume we did not find an X in it. that means row 1 and column 1 has been eliminated as follows&lt;/p&gt;  &lt;table class=&quot;MsoTableGrid&quot; border=&quot;1&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; style=&quot;border-collapse:collapse;border:none;mso-border-alt:solid black .5pt;  mso-border-themecolor:text1;mso-yfti-tbllook:1184;mso-padding-alt:0in 5.4pt 0in 5.4pt&quot;&gt;  &lt;tbody&gt;&lt;tr style=&quot;mso-yfti-irow:0;mso-yfti-firstrow:yes&quot;&gt;   &lt;td width=&quot;25&quot; valign=&quot;top&quot; style=&quot;width:18.9pt;border:solid black 1.0pt;   mso-border-themecolor:text1;mso-border-alt:solid black .5pt;mso-border-themecolor:   text1;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal&quot;&gt;-&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td width=&quot;24&quot; valign=&quot;top&quot; style=&quot;width:.25in;border:solid black 1.0pt;   mso-border-themecolor:text1;border-left:none;mso-border-left-alt:solid black .5pt;   mso-border-left-themecolor:text1;mso-border-alt:solid black .5pt;mso-border-themecolor:   text1;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal&quot;&gt;0&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td width=&quot;24&quot; valign=&quot;top&quot; style=&quot;width:.25in;border:solid black 1.0pt;   mso-border-themecolor:text1;border-left:none;mso-border-left-alt:solid black .5pt;   mso-border-left-themecolor:text1;mso-border-alt:solid black .5pt;mso-border-themecolor:   text1;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal&quot;&gt;1&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:1&quot;&gt;   &lt;td width=&quot;25&quot; valign=&quot;top&quot; style=&quot;width:18.9pt;border:solid black 1.0pt;   mso-border-themecolor:text1;border-top:none;mso-border-top-alt:solid black .5pt;   mso-border-top-themecolor:text1;mso-border-alt:solid black .5pt;mso-border-themecolor:   text1;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal&quot;&gt;0&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td width=&quot;24&quot; valign=&quot;top&quot; style=&quot;width:.25in;border-top:none;border-left:none;   border-bottom:solid black 1.0pt;mso-border-bottom-themecolor:text1;   border-right:solid black 1.0pt;mso-border-right-themecolor:text1;mso-border-top-alt:   solid black .5pt;mso-border-top-themecolor:text1;mso-border-left-alt:solid black .5pt;   mso-border-left-themecolor:text1;mso-border-alt:solid black .5pt;mso-border-themecolor:   text1;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal&quot;&gt;-&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td width=&quot;24&quot; valign=&quot;top&quot; style=&quot;width:.25in;border-top:none;border-left:none;   border-bottom:solid black 1.0pt;mso-border-bottom-themecolor:text1;   border-right:solid black 1.0pt;mso-border-right-themecolor:text1;mso-border-top-alt:   solid black .5pt;mso-border-top-themecolor:text1;mso-border-left-alt:solid black .5pt;   mso-border-left-themecolor:text1;mso-border-alt:solid black .5pt;mso-border-themecolor:   text1;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal&quot;&gt;1&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:2;mso-yfti-lastrow:yes&quot;&gt;   &lt;td width=&quot;25&quot; valign=&quot;top&quot; style=&quot;width:18.9pt;border:solid black 1.0pt;   mso-border-themecolor:text1;border-top:none;mso-border-top-alt:solid black .5pt;   mso-border-top-themecolor:text1;mso-border-alt:solid black .5pt;mso-border-themecolor:   text1;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal&quot;&gt;1&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td width=&quot;24&quot; valign=&quot;top&quot; style=&quot;width:.25in;border-top:none;border-left:none;   border-bottom:solid black 1.0pt;mso-border-bottom-themecolor:text1;   border-right:solid black 1.0pt;mso-border-right-themecolor:text1;mso-border-top-alt:   solid black .5pt;mso-border-top-themecolor:text1;mso-border-left-alt:solid black .5pt;   mso-border-left-themecolor:text1;mso-border-alt:solid black .5pt;mso-border-themecolor:   text1;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal&quot;&gt;1&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td width=&quot;24&quot; valign=&quot;top&quot; style=&quot;width:.25in;border-top:none;border-left:none;   border-bottom:solid black 1.0pt;mso-border-bottom-themecolor:text1;   border-right:solid black 1.0pt;mso-border-right-themecolor:text1;mso-border-top-alt:   solid black .5pt;mso-border-top-themecolor:text1;mso-border-left-alt:solid black .5pt;   mso-border-left-themecolor:text1;mso-border-alt:solid black .5pt;mso-border-themecolor:   text1;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal&quot;&gt;1&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;if the top left corner is not an X, then we can go ahead and reduce the weights of all the squares that can make a winning situation jointly with the top left square. in this case we will decrease 1 from the weights of all the squares in row 1, all the squares in column 1 and the 270 degrees diagonal. in this case we will notice that row 1 column 1 now has a weight of zero. and that means the value of this square does not matter, whether it is an X or an O it does not matter, because row 1 can never be a row fully occupied by X, and column 2 can never be fully occupied by X. It does not matter what the value of this square is (row 1, column 2). using this technique we will be able to prune the board and eliminate a number of squares that we do not need to check. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This will affect the Big O calculated for this board since it will not be n square. I still need to calculate how exactly it will be and I should expect to see some log n in the calculation.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I will post the C# program here soon. &lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aliayman.blogspot.com/feeds/1288969330151225111/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/13014608/1288969330151225111' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/1288969330151225111'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/1288969330151225111'/><link rel='alternate' type='text/html' href='http://aliayman.blogspot.com/2010/08/tic-tac-toe-algorithm.html' title='Tic Tac Toe Algorithm'/><author><name>Ayman Ali</name><uri>http://www.blogger.com/profile/04089520193997921426</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKvUKAMsijXeg19hAydX5kYx8jhwScaIJfKaek8nf0MQ7XRt6oJG70KDPbzhHw2IrHn0n4ZkSh98tNQyU25tEDAgr-dg0evqF3NQarfEvLxEPubltwW6jbETKlCRVkjw/s220/Pic314.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-13014608.post-2258568409592748202</id><published>2010-05-26T10:57:00.000-07:00</published><updated>2010-05-26T11:34:14.390-07:00</updated><title type='text'>MSMQ load balancing</title><content type='html'>&lt;div&gt;&lt;div&gt;&lt;b&gt;Microsoft does not recommend load balancing MSMQ&lt;/b&gt;, the reason has to do with the level of security demanded via the &lt;a href=&quot;http://en.wikipedia.org/wiki/Remote_procedure_call&quot;&gt;RPC protocol&lt;/a&gt; with MSMQ. The read operation will not be able to make the connection to MSMQ and will be dropped by the receiver. There are no workarounds since this would compromise the security of the connection. However, If you are really desperate to load balance the MSMQ here is one possible architecture.&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In order to perform load balancing you will need to distribute the write load among the MSMQ&#39;s you have. in order to do this you will need to use a hardware load balancer like &lt;a href=&quot;http://www.f5.com/products/big-ip/&quot;&gt;F5-BigIp&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;If you have two MSMQ machines then your writer application will write half of the messages to the first MSMQ and the other half to the second MSMQ. your reader application however can not use the load balancer to do the read. since this read will be a remote read which will be stopped by RPC protocol, your reader applications should be local to the MSMQ. In the diagram below&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2i6msNO00ucAHFlPcHmn0U_6j3STMO606MpvIAJ6hd2xW9n9mBKuGUMaJf1BoFJsaudGxlLi9OcQmyTU2leGsj5_atrl5TNxiTQaEtwTDdioDKIrde-vJYi16gkHfpxydQ2PpqA/s1600/ms1.JPG&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5475645596616564002&quot; style=&quot;WIDTH: 400px; CURSOR: hand; HEIGHT: 189px&quot; alt=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2i6msNO00ucAHFlPcHmn0U_6j3STMO606MpvIAJ6hd2xW9n9mBKuGUMaJf1BoFJsaudGxlLi9OcQmyTU2leGsj5_atrl5TNxiTQaEtwTDdioDKIrde-vJYi16gkHfpxydQ2PpqA/s400/ms1.JPG&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;The writer application writes to the load balancer, the load balancer distributes the messages and check the health of the MSMQ server before sending a message to it. In case one of the MSMQ servers is taken down the load balancer will only forward the traffic to the active MSMQ. which should achieve your load balance and fail-over requirement. You can also add a third or fourth MSMQ to the cluster if you encounter higher load and you want to scale your architecture up. you can also take MSMQ down and your application will not be aware since it always communicate with the load balaner.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;For the read operation; Typically MSMQ reading is most efficient when done locally. Having multiple readers on each local machine would provide fault-tolerance along with higher performance. That said, you should have the reader application installed directly on the MSMQ machines. This way the reader applications are performing a local read which will not compromise the RPC security. Your reader application can then process the MSMQ message do whatever it needs to do like sending the contents in email or saving to a database or whatever it is supposed to do.&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aliayman.blogspot.com/feeds/2258568409592748202/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/13014608/2258568409592748202' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/2258568409592748202'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13014608/posts/default/2258568409592748202'/><link rel='alternate' type='text/html' href='http://aliayman.blogspot.com/2010/05/msmq-load-balancing.html' title='MSMQ load balancing'/><author><name>Ayman Ali</name><uri>http://www.blogger.com/profile/04089520193997921426</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKvUKAMsijXeg19hAydX5kYx8jhwScaIJfKaek8nf0MQ7XRt6oJG70KDPbzhHw2IrHn0n4ZkSh98tNQyU25tEDAgr-dg0evqF3NQarfEvLxEPubltwW6jbETKlCRVkjw/s220/Pic314.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2i6msNO00ucAHFlPcHmn0U_6j3STMO606MpvIAJ6hd2xW9n9mBKuGUMaJf1BoFJsaudGxlLi9OcQmyTU2leGsj5_atrl5TNxiTQaEtwTDdioDKIrde-vJYi16gkHfpxydQ2PpqA/s72-c/ms1.JPG" height="72" width="72"/><thr:total>4</thr:total></entry></feed>