<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Coffee Cup</title>
	<atom:link href="http://inullable.in/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>https://inullable.in/blog</link>
	<description>Coding with a cup of coffee</description>
	<lastBuildDate>Mon, 06 Jan 2014 05:46:32 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.9.3</generator>
	<item>
		<title>PowerShell &#8211; Global variables and Constant sharing between PowerShell and C#</title>
		<link>https://inullable.in/blog/?p=167</link>
					<comments>https://inullable.in/blog/?p=167#comments</comments>
		
		<dc:creator><![CDATA[sanil]]></dc:creator>
		<pubDate>Mon, 06 Jan 2014 05:46:32 +0000</pubDate>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Powershell]]></category>
		<guid isPermaLink="false">http://thewiredguy.com/wordpress/?p=167</guid>

					<description><![CDATA[Recently I came across this situation where I wanted a variable to be available in C# context and as well as in the PowerShell runspace. This was important as it would make the solution way more simpler. I used two features to make this possible Global Variables from PowerShell Static classes in .Net You can [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Recently I came across this situation where I wanted a variable to be available in C# context and as well as in the PowerShell runspace. This was important as it would make the solution way more simpler.</p>
<p>I used two features to make this possible</p>
<ol>
<li>Global Variables from PowerShell</li>
<li>Static classes in .Net</li>
<li>You can compile the .net code at runtime in PowerShell and use the compiled type directly or put it in a dll and load it to use it</li>
</ol>
<p>The 3rd point allowed me to have scriptable c# code that we can alter by just opening the PS1 file and that&#8217;s it the PowerShell will take care of the compilation at the runtime so we had almost no build issues, although sometimes it becomes tricky to debug the issues. We avoided this by having many Unit test to check for any bugs/inconsistencies in the code.</p>
<p>Other problem I faced was the UI, the solution required a Win Form UI that was complex, in order to do that I created the WinForm code in a dll, then loaded the dll into PowerShell runspace and used the object to create the WinForm UI, so the UI logic was in C# while the automation logic was in PowerShell. I exposed the Event Handlers and data variables as properties in the WinForm code so there was no plumbing required in the PowerShell code making it cleaner. Letting the event handlers created in PowerShell allowed me to have complete control of the WinForm UI in the most abstract way.</p>
<p>I am not putting the code here as of now as &#8220;I am too lazy to remove the confidential code&#8221; and more importantly the methods described here can be done very easily without seeing actual code, but <span style="text-decoration: underline;">I will put up some code by tomorrow.</span></p>
]]></content:encoded>
					
					<wfw:commentRss>https://inullable.in/blog/?feed=rss2&#038;p=167</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Give user access to remote file share via Powershell</title>
		<link>https://inullable.in/blog/?p=176</link>
					<comments>https://inullable.in/blog/?p=176#respond</comments>
		
		<dc:creator><![CDATA[sanil]]></dc:creator>
		<pubDate>Fri, 18 Jan 2013 04:35:17 +0000</pubDate>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Windows Internals]]></category>
		<guid isPermaLink="false">http://thewiredguy.com/wordpress/?p=176</guid>

					<description><![CDATA[In a hurry to write this post, so will add explanation later Recently a fellow colleague asked me to help him in doing this in PowerShell, as usual I went to google, much to my disappointment I couldn&#8217;t find a single solution anywhere on web (TechNet, Script Center, Powershell,com etc.) So, I decided to sit in [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>In a hurry to write this post, so will add explanation later</p>
<p>Recently a fellow colleague asked me to help him in doing this in PowerShell, as usual I went to google, much to my disappointment I couldn&#8217;t find a single solution anywhere on web (TechNet, Script Center, Powershell,com etc.)<br />
So, I decided to sit in the early morning and forge it out myself, by the time to go to office I had this working solution <img src="https://s.w.org/images/core/emoji/13.1.0/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>Let me know if you guys need any help</p>
<pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee; font-size: 12px; border: 1px dashed #999999; line-height: 14px; padding: 5px; overflow: auto; width: 100%;"><code>$Computer = "sanil"
$user = "guest"
$domain = "BUILTIN"

cls
$s = Get-WmiObject -Class "Win32_LogicalShareSecuritySetting" -Filter "Name='Music'"
$sd = $s.GetSecurityDescriptor()

# List all users having access
$sd.Descriptor.DACL | ForEach-Object {$_.Trustee.Name}

$ACE = ([WMIClass] "\$Computerrootcimv2:Win32_ACE").CreateInstance()
$Trustee = ([WMIClass] "\$Computerrootcimv2:Win32_Trustee").CreateInstance()

$Trustee.Name = $user
$Trustee.Domain = $domain
$Trustee.SIDString =  (new-object security.principal.ntaccount $user).translate([security.principal.securityidentifier]) 

$ace.AccessMask = 2032127
$ace.AceFlags = 3
$ace.AceType = 0
$ace.Trustee = $Trustee

# New Secuity Descriptor
$nsd = ([WMIClass] "\$Computerrootcimv2:Win32_SecurityDescriptor").CreateInstance()

#Copy all except DACLs
$nsd.Properties["ControlFlags"].Value = $sd.Descriptor.Properties["ControlFlags"].Value
$nsd.Properties["Group"].Value = $sd.Descriptor.Properties["Group"].Value
$nsd.Properties["Owner"].Value = $sd.Descriptor.Properties["Owner"].Value
$nsd.Properties["SACL"].Value = $sd.Descriptor.Properties["SACL"].Value
$nsd.Properties["TIME_CREATED"].Value = $sd.Descriptor.Properties["TIME_CREATED"].Value

for($i=0; $i -lt $sd.Descriptor.DACL.Count; $i++)
{
    $nsd.DACL += $sd.Descriptor.DACL[$i]
}

$nsd.DACL += $ACE
# List all users having access
$nsd.DACL | ForEach-Object {$_.Trustee.Name}

$s.SetSecurityDescriptor($nsd) #Should return 0

</code></pre>
]]></content:encoded>
					
					<wfw:commentRss>https://inullable.in/blog/?feed=rss2&#038;p=176</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Cloak (A Console wrapper library)</title>
		<link>https://inullable.in/blog/?p=156</link>
					<comments>https://inullable.in/blog/?p=156#respond</comments>
		
		<dc:creator><![CDATA[sanil]]></dc:creator>
		<pubDate>Tue, 12 Jul 2011 21:50:48 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<guid isPermaLink="false">http://thewiredguy.com/wordpress/?p=156</guid>

					<description><![CDATA[Cloak is a Windows Command Line wrapper library written in .Net that supports executing your commands while completely hiding the underlying console and providing output back to your application. It also provides access to last error happened while the commands got executed. Also included a demo console GUI : A GUI Application is also included [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Cloak is a Windows Command Line wrapper library written in .Net that supports  executing your commands while completely hiding the underlying console and  providing output back to your application. It also provides access to last error  happened while the commands got executed.</p>
<p>Also included a demo console GUI : A GUI Application is also included that  you can use to see for knowing how to interface your application to Cloak  library.</p>
<p><strong>Features:</strong></p>
<div class="wikidoc">
<ul>
<li>Provides an interface to the console</li>
<li>Executes the command without ever showing the underlying the Console process.</li>
<li>Also gives you the last error during execution</li>
</ul>
</div>
<p><strong>Proposed Features for future releases</strong></p>
<ol>
<li>To preserve the environment state between execution of different commands sets</li>
<li>Validate the compatibility of powershell commands/scripts</li>
</ol>
<p><a style="text-decoration: none; font-weight: bold; border: outset 3px  #317200; background: #7ABB1A; margin: 2px; padding: 2px; color: #fcfcfc;" href="http://cloak.codeplex.com/releases">Download Cloak</a><a style="text-decoration: none; font-weight: bold; border: outset 3px  #317200; background: #7ABB1A; margin: 2px; padding: 2px; color: #fcfcfc;" href="http://cloak.codeplex.com/SourceControl/list/changesets">Download Cloak source</a></p>
<p><img loading="lazy" style="margin: 5px;" src="http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=cloak&amp;DownloadId=258280" alt="" width="884" height="516" /></p>
<p><strong>Usage:</strong></p>
<pre><code>
string commands = "dir c: n"
                       + "del c:bootscan.log";
ConsoleHelper CH = new ConsoleHelper();
string Results = CH.ExecuteCommands(commands);
string Errors = CH.LastError;
</code></pre>
<p>Know more about this project and follow it on Codeplex @ <a href="http://cloak.codeplex.com">Cloak.CodePlex.com</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://inullable.in/blog/?feed=rss2&#038;p=156</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Stuck! No API, rip data off the page</title>
		<link>https://inullable.in/blog/?p=136</link>
					<comments>https://inullable.in/blog/?p=136#comments</comments>
		
		<dc:creator><![CDATA[sanil]]></dc:creator>
		<pubDate>Fri, 01 Jul 2011 14:17:28 +0000</pubDate>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Jaavscript]]></category>
		<category><![CDATA[Social Apps]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[Web]]></category>
		<guid isPermaLink="false">http://thewiredguy.com/wordpress/?p=136</guid>

					<description><![CDATA[You want to use some data that is provided by some site, but they doesn’t expose any API to get that data. Well, a possible (and a very dirty) trick is to get the page HTML and rip data off it for our use. Not so easy dude&#8230; there are many hurdles: First one is [&#8230;]]]></description>
										<content:encoded><![CDATA[<p style="text-align: justify;">You want to use some data that is provided by some site, but they doesn’t expose any API to get that data. Well, a possible (and a very dirty) trick is to get the page HTML and rip data off it for our use.</p>
<p>Not so easy dude&#8230; there are many hurdles:</p>
<li>First one is the “<a href="http://en.wikipedia.org/wiki/Same_origin_policy">Same origin policy</a>” security restriction that prevents your site’s page to request any data(in our case HTML) from a remote site. <a href="http://en.wikipedia.org/wiki/Same_origin_policy">Here is a wiki page</a> that explains this issue and possible <a href="http://en.wikipedia.org/wiki/Same_origin_policy#Workarounds">workarounds</a></li>
<p><img class="alignright" style="width: 106px; height: 106px;" src="http://t0.gstatic.com/images?q=tbn:ANd9GcQdBo0aQ8luCwrIEum76p2Fm4rOHbqo-1qWiaHihhNec1aGebPO" alt="bag of garbage" /></p>
<li>The (X)HTML page can appear like a bag full of garbage. I would suggest that you <a href="http://www.codinghorror.com/blog/2009/11/parsing-html-the-cthulhu-way.html">never parse HTML</a>&#8230;it will FAIL soon, and you will have to fix it which will FAIL again, its a vicious circle</li>
<h3 style="text-align: center;"><span style="color: #333399;">HTML page is full of Garbage</span></h3>
<p style="text-align: center;"><img loading="lazy" class="aligncenter" src="http://thewiredguy.com/wordpress/wp-content/uploads/2011/07/html-page1.png" alt="" width="658" height="385" /></p>
<p>So, let us assume somehow you<a href="http://en.wikipedia.org/wiki/Same_origin_policy#Workarounds"> get the page HTML</a> within your page through plain Javascript/AJAX/jQuery or any other way, then how your page will get the data it wants&#8230;</p>
<p>Well, most of the pages has similar construct:</p>
<pre>&lt;doctype....
&lt;html&gt;
&lt;head&gt;
..
..
&lt;script&gt;..&lt;/script&gt;
.
&lt;/head&gt;
&lt;body ....&gt;
...
..
&lt;&lt;&lt;&lt;&lt;Tags jungle&gt;&gt;&gt;&gt;
..
&lt;some sweet tag&gt; &lt;3 Your Data &lt;3 &lt;/some tag&gt;
..
.&lt;more tags&gt;

&lt;/body&gt;
&lt;/html&gt;</pre>
<p>What we will do is to load this page HTML into a javascript varible, then simply chop all the content section from the start up to  tag, also trim any &lt;script&gt;<br />
tags. Then we will run a wild replace using regular expression that will make any tag &lt;* into &lt;div tag</p>
<p>You can further continue this chopping and transformation of data to get closer to pure data. Once we have the HTML gone through the above process, we will have something that will look like this:</p>
<pre>&lt;div&gt;
&lt;div&gt;
.
.
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt; &lt;3 Your Data &lt;3 &lt;/div&gt;
&lt;div&gt;
..
.</pre>
<p>which we will host(assign to innerHTML property) into an <span style="text-decoration: underline;">invisible div</span>, which will force the browser to parse and render the HTML and make this HTML part of your DOM object.</p>
<p>Later you can query this data, using something like&#8230;<br />
<code>var data = docuemnt.getElementById("someId").innerText;</code></p>
<p>where someID is the parent element, containing required data.</p>
<p>Lets take an example of NewYork weather data page from AccuWeather.com:<br />
<strong><code style="border: black solid 1px; padding: 2px;">URL: http://www.accuweather.com/us/ny/new-york/10017/city-weather-forecast.asp</code></strong></p>
<p><img src="http://thewiredguy.com/wordpress/wp-content/uploads/2011/07/AccuWeather.png" alt="" /></p>
<p>if you inspect the page in IE developer tools, we will observe following:</p>
<p><a href="http://thewiredguy.com/wordpress/wp-content/uploads/2011/07/IEDevTools.png" target="_blank"><img loading="lazy" src="http://thewiredguy.com/wordpress/wp-content/uploads/2011/07/IEDevTools.png" alt="" width="1008" height="756" /></a></p>
<p>now assuming that you have managed to load this HTML into your page JavaScript,and its assigned to the src variable, thus src should look something like this:</p>
<p><img src="http://thewiredguy.com/wordpress/wp-content/uploads/2011/07/message_src.png" alt="" /></p>
<p>lets execute following JavaScript statements:</p>
<p><code><br />
if(src === "")<br />
return;<br />
var i = src.indexOf(" 	src = src.substr(i);		// chopped the Head part</code></p>
<p><code> </code></p>
<p><code> tag = src.replace(/&lt;[a-z]+/gi,"<br />
tag<br />
alert(tag);<br />
</code></p>
<p>this should give us the output as shown below:</p>
<p><img src="http://thewiredguy.com/wordpress/wp-content/uploads/2011/07/div_src.png" alt="" /></p>
<p>Further executing some more JavaScript statements provided below, we can reach to our data:<br />
<code><br />
document.getElementById("host").innerHTML = tag;<br />
data = $(".info").find(".cond").find(".temp")[0].innerText;</code></p>
<p><code>data = data.substr(0,3);<br />
alert("Today's Temp: "+data);<br />
// host here is a div element<br />
document.getElementById("host").innerHTML = "Today's Temp: "+data+"°";<br />
$("#host").show();<br />
</code></p>
<p>Result will give us the temperature.</p>
<p>Here is the full source code:</p>
<p><a style="border: outset 3px blue; background: #3A93F3; color: #000061; text-decoration: none; padding:2px;" href="http://thewiredguy.com/wordpress/wp-content/uploads/2011/07/Weather.zip" target="_blank">download source code</a></p>
<pre><code>
&lt;html
&lt;head&gt;
&lt;title&gt;Page rip demo&lt;/title&gt;
&lt;script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.1.min.js"&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;script type="text/javascript" &gt;
var url = "weather.htm";
var src = "";
onload = function()
		{
			$.ajax({'url':url,'success':function(source)								{
								{	src = source;
									alert(src);
								},
								'error':function(r,s,x)
								{
									alert("Error while trying to get data :(");
								}});
		}

function GetTemperature()
{
	if(src === "")
		return;

	var i = src.indexOf("&lt;body");
	src = src.substr(i);		// chopped the Head part

	tag = src.replace(/&lt;[a-z]+/gi,"&lt;div");
	alert(tag);

	document.getElementById("host").innerHTML = tag;
	data = $(".info").find(".cond").find(".temp")[0].innerText;

	data = data.substr(0,3);
	alert("Today's Temp: "+data);
	document.getElementById("host").innerHTML = "&lt;h2&gt;Today's Temp: "+data+"° C";
	$("#host").show();
}
&lt;/script&gt;
&lt;input type="button" onclick="GetTemperature()" value="Show Temp"&gt;

&lt;div id="host" style="display:none;"&gt;&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
<p>Which will give us the following result:</p>
<p><img src="http://thewiredguy.com/wordpress/wp-content/uploads/2011/07/temp_show.png" alt="" /></p>
<p><strong>Pros: </strong>This approach is better than trying to parse the whole HTML yourself, which is more error prone and bound to fail frequently. Here we are letting the browser parse and include our HTML into the DOM, so we can run some simple JavaScript statements to get required data</p>
<p><strong>Cons: </strong>this approach is way dirty itself and will fail someday, as soon as the page layout changes or somebody alters the source page HTML layout. Not to mention the browser compatibility as different browser treats things differently.</p>
<p>With the recent and continuing revolution going around on the web, things are getting easy with sites exposing their data through APIs or at least through Microdata/Microformats</p>
]]></content:encoded>
					
					<wfw:commentRss>https://inullable.in/blog/?feed=rss2&#038;p=136</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Skipping cross-site AJAX restrictions</title>
		<link>https://inullable.in/blog/?p=132</link>
					<comments>https://inullable.in/blog/?p=132#respond</comments>
		
		<dc:creator><![CDATA[sanil]]></dc:creator>
		<pubDate>Wed, 29 Jun 2011 14:22:34 +0000</pubDate>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[Social Apps]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[Web]]></category>
		<guid isPermaLink="false">http://thewiredguy.com/wordpress/?p=132</guid>

					<description><![CDATA[Recently, I came across an issue, where I cannot do an AJAX call to my web service from my web page because they were hosted on different domains. This is a restriction put up by the browsers in accordance to the Same Origin Policy. A possible work around is to implement a server side proxy [&#8230;]]]></description>
										<content:encoded><![CDATA[<p style="text-align: justify;">Recently, I came across an issue, where I cannot do an AJAX call to my web service from my web page because they were hosted on different domains. This is a restriction put up by the browsers in accordance to the <a href="http://en.wikipedia.org/wiki/Same_origin_policy">Same Origin Policy</a>. A possible work around is to implement a server side proxy to interact with the remote site right from the server and then passing the response to AJAX requests.</p>
<p style="text-align: justify;">I had worked with this earlier, but this time I was not in the mood to do it again. I wanted something within the page itself as implementing a proxy will increase the complexity of the whole system. So, I did some &#8220;Search&#8221; and found this awesome solution that utilizes this neat approach of referencing script src to remote site. Basically, This means the page JavaScript has to dynamically create a &lt;script&gt; and set its source(src) attribute to the service URL, which in turn provide the data in JSON format that is natively supported in JavaScript. Thus, we will have our response data right inside our page in JSON.</p>
<p>Here is a possible implementation:</p>
<pre><code>
function JSONData()
{
	this.serviceURL = "http://somesite.com/services/json.php";
	this.scriptEle;
	this.IdName = "script_id00";
	this.getData = function()
	{
		this.scriptEle = document.createElement("script");
		var oType = document.createAttribute("type");
		var oSrc = document.createAttribute("src");
		var oId = document.createAttribute("id");
		oType.nodeValue = "text/javascript";
		oSrc.nodeValue = this.serviceURL;
		oId.nodeValue = this.IdName;
		this.scriptEle.setAttributeNode(oType);
		this.scriptEle.setAttributeNode(oSrc);
		this.scriptEle.setAttributeNode(oId);
		this.scriptEle.src = this.serviceURL;
		document.body.appendChild(this.scriptEle);
	}

	// Use this function to reload/refresh the JSON data from the server
	this.reload= function()
	{
		this.scriptEle = document.getElementById(this.IdName);
		document.body.removeChild(this.scriptEle);
		this.getData();
	}
}

var jsonData = new JSONData();
jsonData.getData();

//change this delay according to your requirements
var delay = 10000; // let the JSON data arrive from the server

setTimeout("ShowData()",delay); //wait and let the JSON data arrive and get parsed

function ShowData()
{
	if(typeof(data)!= "undefined") //if the JSON data has been received and parsed
	{
		alert(data.FirstName + " " + data.LastName);
	}
	else
	{
		setTimeout("ShowData()",30000); // wait some more time
	}
}
</code></pre>
<p>in our example the JSON sent from the server will be in this form</p>
<pre><code>
var data = {
	FirstName : 'Sanil',
	Age : 24,
	Role: 'Software Developer',
	LastName : 'Tomar'
};
</code></pre>
<p>There are well defined methods that does this in jQuery. You can use the <a href="http://api.jquery.com/jQuery.getJSON/">jQuery.getJSON</a> to achieve same thing in a lot cleaner way.</p>
<p>Hope, this technique helps you in getting around this hurdle to access cross-site data.</p>
<p><img src="https://s.w.org/images/core/emoji/13.1.0/72x72/2665.png" alt="♥" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Happy Coding!! <img src="https://s.w.org/images/core/emoji/13.1.0/72x72/2665.png" alt="♥" class="wp-smiley" style="height: 1em; max-height: 1em;" />  <img src="https://s.w.org/images/core/emoji/13.1.0/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>&lt;digression&gt;<br />
<strong>Geek News:</strong> Pi (∏) to be replaced by Tau (τ)<a href="http://tauday.com/"> Link1</a> , <a href="http://www.google.co.in/search?q=pi+to+be+replaced+by+tau" target="_blank">Link2</a><br />
&lt;/digression&gt;</p>
]]></content:encoded>
					
					<wfw:commentRss>https://inullable.in/blog/?feed=rss2&#038;p=132</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Classes in Python</title>
		<link>https://inullable.in/blog/?p=124</link>
					<comments>https://inullable.in/blog/?p=124#respond</comments>
		
		<dc:creator><![CDATA[sanil]]></dc:creator>
		<pubDate>Tue, 28 Jun 2011 08:41:35 +0000</pubDate>
				<category><![CDATA[python]]></category>
		<guid isPermaLink="false">http://thewiredguy.com/wordpress/?p=124</guid>

					<description><![CDATA[Python is a super-duper cool language, I like it&#8230;everybody loves it. It is also popular as the &#124;-&#124;4x0r5 language. It is dynamic and has a clear syntax, most of all fun to use. But so many books and manuals underplay classes in python that it mostly lives in early programmers as plain scripting language having [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><img loading="lazy" class="alignnone" src="http://www.python.org/images/python-logo.gif" alt="" width="180" height="49" /><a href="http://www.python.org">Python</a> is a super-duper cool language, I like it&#8230;everybody loves it. It is also popular as the <a title="hacker language" href="http://oss.coresecurity.com/" target="_blank">|-|4x0r5</a> language. It is dynamic and has a clear syntax, most of all fun to use.</p>
<p>But so many books and manuals underplay classes in python that it mostly lives in early programmers as plain scripting language having support for procedures/methods. In reality, Python supports object-oriented programming with classes and multiple inheritance.</p>
<p>Here is an approximate syntactical comparison beween class declaration in C# and python:</p>
<p><strong>C# Version:</strong></p>
<pre>public class Person
{
	int Age;
	public string Name;
	float Height;
	float Weight;

	public Person(int age,float height,float weight)
	{
		Age = age;
		Height = height;
		Weight = weight;
		Name = "No Name"
	}

	public void GetInfo()
	{
		system.console.WriteLine("Name: {0}",Name);
		system.console.WriteLine("Weight: {0}",Weight);
		system.console.WriteLine("Height: {0}",Height);
		system.console.WriteLine("Age: {0}",Age);
	}
}</pre>
<p><strong>Python Version</strong></p>
<pre>class Person:
	Name = "No Name"
	def __init__(self,age,height,weight):
		self.Age = age
		self.Height = height
		self.Weight = weight

	def GetInfo(self):
		print "Name: ", self.Name
		print "Weight: ", self.Weight
		print "Height: ", self.Height
		print "Age: ", self.Age

------------------------------------------------------------------------------------
Usage:

p = Person(20,5.11,70)
p.GetInfo()
print("nn")
p.Name = "Chuck Norris"
p.GetInfo()

------------------------------------------------------------------------------------
Output:
Name:  No Name
Weight:  70
Height:  5.11
Age:  20

Name:  Chuck Norris
Weight:  70
Height:  5.11
Age:  20</pre>
<p>Learn more about classes and objects oriented programming in python <a title="here" href="http://www.freenetpages.co.uk/hp/alan.gauld/tutclass.htm" target="_blank">here</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://inullable.in/blog/?feed=rss2&#038;p=124</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Generate CruiseControl.Net Build Report in Powershell</title>
		<link>https://inullable.in/blog/?p=112</link>
					<comments>https://inullable.in/blog/?p=112#respond</comments>
		
		<dc:creator><![CDATA[sanil]]></dc:creator>
		<pubDate>Sun, 30 Jan 2011 03:19:31 +0000</pubDate>
				<category><![CDATA[Cruisecontrol.Net]]></category>
		<category><![CDATA[Powershell]]></category>
		<guid isPermaLink="false">http://thewiredguy.com/wordpress/?p=112</guid>

					<description><![CDATA[Recently, I wanted to generate report of all the builds happening on my system. I came up with a very simple solution using Powershell script. If you look at the CC.Net directory structure, you can find that all the project specific logs are kept at &#60;CC.Net&#62;server&#60;project-name&#62;ArtifactsBuildLogs (in Default config) So, if you have a project [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Recently, I wanted to generate report of all the builds happening on my system. I came up with a very simple solution using Powershell script.</p>
<p>If you look at the CC.Net directory structure, you can find that all the project specific logs are kept at &lt;CC.Net&gt;server&lt;project-name&gt;ArtifactsBuildLogs (in Default config)</p>
<p>So, if you have a project named MyFirstProject&#8230;</p>
<p>it will be in the &lt;CC.Net&gt;serverMyFirstProjectArtifactsBuildLogs</p>
<p><span style="font-size: 13px; font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; line-height: 19px;"><img loading="lazy" class="alignnone size-full wp-image-115" title="dir" src="http://thewiredguy.com/wordpress/wp-content/uploads/2011/01/dir.gif" alt="" width="247" height="322" /></span></p>
<p><span style="font-size: 13px; font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; line-height: 19px;"> </span>further the log files names also follow a pattern</p>
<p>for example, take this:</p>
<p>log20101125115243Lbuild.4.xml</p>
<p>this consists of log+&lt;year&gt;+&lt;month&gt;+&lt;day&gt;+&lt;hour&gt;+&lt;min&gt;+&lt;sec&gt;+LBuild.&lt;build-label&gt;.xml, so from the file name above, we can know that:</p>
<p>Year = 2010, month = 11, day= 25; hour = 11, min = 52, sec = 43.</p>
<p>If build had failed, then the file name changes to :</p>
<p>log+&lt;year&gt;+&lt;month&gt;+&lt;day&gt;+&lt;hour&gt;+&lt;min&gt;+&lt;sec&gt;.xml, that is the Build-Label is missing.</p>
<p>So I quickly wrote this powershell script, which spits out results as CSV.</p>
<p>Project Name, Date of Build, Build-Label, Status</p>
<p><strong>_____________________________________________________________</strong></p>
<pre style="color: black; background: #ffffff; width: 600px; margin: 0px; padding: 5px; border: 2px;"><code><label>
$Currentdate = get-date -uformat  "%m"
if( $Currentdate -contains "01") # first month of Year
{
      $Currentdate = get-date -uformat  "%Y%m"
      $date = $Currentdate -89   #go to last month of previous year
}
else # not first month of Year
{
      $Currentdate = get-date -uformat  "%Y%m"
      $date = $Currentdate -1
}
write("Project,date,label,status") &gt; D:file.csv
cls
D:        # ---- CruiseControl.NET Installation drive ----
cd  "D:CruiseControl.netserver"
cls

$proj = get-childitem
foreach( $file in $proj)
{
    if($file.length -lt 0)
    {
        $file.Name
        push-location
        if($file.Name -ne "xsl" )
        {
                                 #$file.Name: This is the project name
                                 cd $file.name
                                 cd Artifacts
                                 cd buildlogs

				$xmls = get-childitem #-Include log$date*build.*.xml
				foreach($xmlfile in $xmls)
				{
				            $pattern = "log.*LBuild.(?<label>.*).xml"
				                                             $success = $xmlfile -match $pattern
				                                             if($matches -and $matches['label'])
                                       				            {
				                                                 write($file.Name + " , "+ $file.LastWriteTime + " , "+ $matches["label"] +" , Success")&gt;&gt; D:file.csv
				                                                 del variable:matches
                                 				            }
				                                           else
							                   {
                                                                                 write($file.Name + " , "+ $file.LastWriteTime + " , NA , Failed") &gt;&gt; D:file.csv
						                           }

                                              				cmd /c pause
        		                              }
                                                     pop-location
		}
	}
}
</label></label></code></pre>
<p><strong>___________________________________________________________</strong></p>
<p>Hmm&#8230; Powershell is really powerful <img src="https://s.w.org/images/core/emoji/13.1.0/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://inullable.in/blog/?feed=rss2&#038;p=112</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>CMD on the web</title>
		<link>https://inullable.in/blog/?p=86</link>
					<comments>https://inullable.in/blog/?p=86#respond</comments>
		
		<dc:creator><![CDATA[sanil]]></dc:creator>
		<pubDate>Fri, 14 Jan 2011 23:49:58 +0000</pubDate>
				<category><![CDATA[Web]]></category>
		<guid isPermaLink="false">http://thewiredguy.com/wordpress/?p=86</guid>

					<description><![CDATA[Yesterday, while sitting at my desk doing my usual work &#60;digression&#62;actually computer was doing that. I was only telling him what to do &#60;/digression&#62;. So I was pretty much free to do other things and at that time I miss my home computer where I want to do things, like I want to see the [&#8230;]]]></description>
										<content:encoded><![CDATA[<p style="text-align: center"><img align="left" src="http://thewiredguy.com/wordpress/wp-content/uploads/2011/01/011411_2336_CMDontheweb1.jpg" alt=""/></p>
<p style="text-align: justify"><img align="right" src="http://thewiredguy.com/wordpress/wp-content/uploads/2011/01/011411_2336_CMDontheweb2.png" alt=""/>Yesterday, while sitting at my desk doing my usual work <strong>&lt;digression&gt;</strong>actually computer was doing that. I was only telling him what to do <strong>&lt;/digression&gt;</strong>.
</p>
<p style="text-align: justify">So I was pretty much free to do other things and at that time I miss my home computer where I want to do things, like I want to see the status of my computer remotely, is it up or not and system uptime and the Intranet Apache server is running or not which is critical for some stuff.
</p>
<p style="text-align: justify">So I came back to home, it was Friday night and wrote a python script to fetch commands from a web URL and run them in console and POST the results back to server. I set it up in task scheduler to run at specified intervals.
</p>
<p style="text-align: justify">Unfortunately, the results were not at all up to what I wanted. The whole activity from sending commands from web page to actually execute them and display the results took quite a long time. The average round-trip time including execution was ~ 3 minutes. <strong>That&#8217;s really too slow.<br />
</strong></p>
<p style="text-align: justify">There were bottlenecks in the solutions.
</p>
<ol style="margin-left: 54pt">
<li>
<div style="text-align: justify">The task scheduler won&#8217;t allow you to specify less than 1 min interval for your scripts, limiting the execution time &gt; 1 min
</div>
</li>
<li>
<div style="text-align: justify">Even if I do something to set the scheduler to something like 5 sec intervals, that would be inefficient and overkill.
</div>
</li>
</ol>
<p style="text-align: justify"><strong>Solution<br />
</strong></p>
<p style="text-align: justify">I realized there was a Cruisecontrol.net server that was performing some tasks like performing builds etc. I tried setting up a project on it to run the script in 5 sec intervals still the results were not up to the mark, but still there was significant reduction in round-trip = 1 minutes – 30 secs.
</p>
<p style="text-align: justify">Later, I setup the Cruisecontrol to regularly ping the server to execute the task only if there is a command waiting to be executed at the server. This brought down the time to 10-40 seconds.
</p>
<p style="text-align: justify">I loved it.
</p>
<p style="text-align: justify">
 </p>
<p style="text-align: justify">Following is the Project entry in the Cruisecontrol:</p>
<pre>
	&lt;project name="RCProcessor" &gt;
	    &lt;triggers&gt;
    		&lt;urlTrigger url="&lt;URL&gt;/command.txt" /&gt;
    	&lt;/triggers&gt;
		&lt;sourcecontrol type="nullSourceControl" /&gt;
	      &lt;tasks&gt;
	      	&lt;exec&gt;
	  		    &lt;executable&gt;cmd.exe&lt;/executable&gt;
	  		    &lt;buildArgs&gt;"/c &lt;Path-To-Script&gt;process.py &gt;&gt; commands.txt"&lt;/buildArgs&gt;
	  		    &lt;buildTimeoutSeconds&gt;10&lt;/buildTimeoutSeconds&gt;
	  	    &lt;/exec&gt;	  	    
	      &lt;/tasks&gt;
	      &lt;publishers&gt;
		   	&lt;xmllogger /&gt;
	      &lt;/publishers&gt;	     
	&lt;/project&gt;
</pre>
<p> </p>
<p style="text-align: justify">And here comes the python script…</p>
<pre>
import os
from re import split
import string
import urllib
import urllib2
import datetime
baseurl = '<strong> &lt; Base-URL &gt; /</strong>'
url = baseurl + 'command.txt'
user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'
now = datetime.datetime.now().strftime("%m-%d-%y %H:%M")
headers = { 'User-Agent' : user_agent }

def SubmitData(url,data):
	user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'
	values = {'data' : data}
	headers = { 'User-Agent' : user_agent }
	encdata = urllib.urlencode(values)
	req = urllib2.Request(url, encdata)
	response = urllib2.urlopen(req)
	the_page = response.read()
	return the_page
#END SubmitData

print("Get URL: "+url)
req = urllib2.Request(url)
response = urllib2.urlopen(req)
the_page = response.read()
the_page = string.replace(the_page,"\\","\")
print("Command: "+ the_page)

if (the_page != ""):
	list = "<strong>"+"cmd /c " + the_page+"</strong>"
	for line in os.popen("cmd.exe /c" + the_page):
		line = string.replace(line,"<","&lt;")
		line = string.replace(line,">","&gt;")
		list += "rn<br />" + line
		
	print(":: OUTPUT ::nn")
	print(list)
	print("nn")
	print("SEND URL: "+baseurl + "output.php")
	print(SubmitData(baseurl + "output.php","rn<br />"+ list))
#END IF

</pre>
</p>
<p style="text-align: justify">
 </p>
<p style="text-align: justify">That&#8217;s all folks <span style="font-family:Wingdings; font-size:20pt"><strong>J</strong></span>
	</p>
<p style="text-align: justify">Hope you like it, play around and try out new things and post it back here.
</p>
<p style="text-align: justify">And do leave comments <span style="font-family:Wingdings; font-size:18pt"><strong>J</strong></span>
	</p>
]]></content:encoded>
					
					<wfw:commentRss>https://inullable.in/blog/?feed=rss2&#038;p=86</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Cross-Domain requests in Silverlight and using Yahoo Pipes as a proxy</title>
		<link>https://inullable.in/blog/?p=65</link>
					<comments>https://inullable.in/blog/?p=65#respond</comments>
		
		<dc:creator><![CDATA[sanil]]></dc:creator>
		<pubDate>Sat, 28 Nov 2009 23:11:12 +0000</pubDate>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Social Apps]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[Web]]></category>
		<guid isPermaLink="false">http://www.thewiredguy.com/wordpress/?p=65</guid>

					<description><![CDATA[Last week, I have been developing this silverlight twitter application and was struck at a point, where I needed to pull RSS feeds from twitter. The code will always throw a Security Exception again and again. After digging a bit, I found out that silverlight doesn&#8217;t allow cross-domain calls to any domain you want. This [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Last week, I have been developing this silverlight twitter application and was struck at a point, where I needed to pull RSS feeds from twitter. The code will always throw a <a href="http://forums.silverlight.net/forums/t/11099.aspx" target="_blank">Security Exception</a> again and again. After digging a bit, I found out that silverlight doesn&#8217;t allow cross-domain calls to any domain you want.</p>
<p>This policy has been enforced to prevent <a href="http://en.wikipedia.org/wiki/Cross-site_request_forgery" target="_blank">session riding</a>, for further details look this Karen Corby&#8217;s <a href="http://scorbs.com/2008/04/15/silverlight-http-networking-stack-part-2-cross-domain-communication-overview/" target="_blank">blog post</a> on cross domain requests.</p>
<p>Turns out that in silverlight, HTTP requests to non-original domains are allowed if the server has exclusively allowed to accept requests. The primary way of enabling cross domain calls is through a policy file placed at the root of the server.&nbsp; Two types of policy files are supported:</p>
<ol>
<li>Silverlight Cross Domain Policy File (clientaccesspolicy.xml) </li>
<li>(A subset of the) Flash Cross Domain Policy File (crossdomain.xml)</li>
</ol>
<p>Now, the problem is that twitter don&#8217;t have policy files placed in the server root. Possible way to get around this is to use a proxy for requests. you can make a proxy on your server, that can on application request, fetch the RSS data from twitter and send it back to your application. EASY!</p>
<p>but what if, you don&#8217;t want your own server proxy&#8230; </p>
<p><strong>reasons</strong>:</p>
<ul>
<li>you will have to add a policy file to your server root
<li>that will cause increase in the server bandwidth usage and server stress
<li>it&#8217;s hell lot of work</li>
</ul>
<p>simple! use <a href="http://pipes.yahoo.com" target="_blank">Yahoo Pipes</a>, why?</p>
<ul>
<li>Its easy
<li>because, they allow you to request RSS feeds from other sites (multiple sites in one request)
<li>they have cross-domain policy files placed on there server roots, that means your silverlight application will be able to fetch the Twitter data via a yahoo pipe</li>
</ul>
<p><u>What is a yahoo pipe?</u></p>
<blockquote>
<p><strong>Content-source</strong>: <a title="http://pipes.yahoo.com/pipes/" href="http://pipes.yahoo.com/pipes/">http://pipes.yahoo.com/pipes/</a> </p>
<p>Pipes is a powerful composition tool to aggregate, manipulate, and mashup content from around the web.  </p>
<p>Like Unix pipes, simple commands can be combined together to create output that meets your needs:  </p>
<ul>
<li>combine many feeds into one, then sort, filter and translate it.
<li>geocode your favorite feeds and browse the items on an interactive map.
<li>power widgets/badges on your web site.
<li>grab the output of any Pipes as RSS, JSON, KML, and other formats. </li>
</ul>
<p>simply speaking, a yahoo pipe is url like this:</p>
</blockquote>
<p><a title="http://pipes.yahoo.com/pipes/pipe.info?_id=f0cf1b0851bd8243dbf8bd63c07b8d11" href="http://pipes.yahooapis.com/pipes/pipe.info?_id=bas782j290jq9dd2nmaklfhj93ji9d3j">http://pipes.<strong>yahooapis</strong>.com/pipes/pipe.info?_id=bas782j290jq9dd2nmaklfhj93ji9d3j</a></p>
<p>you design its behaviour on a design surface </p>
<p><a href="http://thewiredguy.com/BlogImages/CrossDomainrequestsinSilverlight_3CE1/image.png"><img loading="lazy" border="0" alt="image" src="http://thewiredguy.com/BlogImages/CrossDomainrequestsinSilverlight_3CE1/image_thumb.png" width="752" height="454"></a> </p>
<p>So, a yahoo pipe can be designed to take single/multiple feed URLs, fetch the feeds and provide an aggregated feed which can be consumed by your silverlight application under cross domain policy.</p>
<p>further, you can provide test data and see results right there.</p>
<p>Run it and get the aggregated RSS URL from the run screen.</p>
<p>The pipe, I used looks like this</p>
<p>http://pipes.yahooapis.com/pipes/pipe.run?_id=f0cf1b0851bd8243dbf8bd63c07b8d11&#038;_render=rss&#038;feedUrl=&lt;some_feed_url&gt;</p>
<p><a href="http://thewiredguy.com/BlogImages/CrossDomainrequestsinSilverlight_3CE1/image_3.png"><img loading="lazy" border="0" alt="image" src="http://thewiredguy.com/BlogImages/CrossDomainrequestsinSilverlight_3CE1/image_thumb_3.png" width="452" height="310"></a> </p>
<p>Now fetching the data in your silverlight application is damn easy&#8230;</p>
<p>&nbsp;</p>
<pre class="csharpcode"><span class="kwrd">private</span> <span class="kwrd">string</span> proxy = <span class="str">"http://pipes.yahooapis.com/pipes/pipe.run?_id=f0cf1b0851bd8243dbf8bd63c07b8d11&amp;_render=rss&amp;feedUrl="</span>;
<span class="kwrd">private</span> <span class="kwrd">string</span> feedUrl = <span class="str">"http://twitter.com/statuses/user_timeline/22100709.rss"</span>;

<span class="kwrd">void</span> DownloadFeed()
{
            <span class="kwrd">string</span> url = proxy + feedUrl;
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(<span class="kwrd">new</span> Uri(url));
            request.Method = <span class="str">"GET"</span>;
            request.BeginGetResponse(<span class="kwrd">new</span> AsyncCallback(ResponseHandler), request);
}

<span class="kwrd">void</span> ResponseHandler(IAsyncResult asyncResult)
{
            <span class="kwrd">try</span>
            {
                HttpWebRequest request = (HttpWebRequest)asyncResult.AsyncState;
                HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asyncResult);
                
                <span class="kwrd">if</span> (response.StatusCode == HttpStatusCode.OK)
                {
                    Stream stream = response.GetResponseStream();
                    <span class="kwrd">int</span> len = 1024;
                    <span class="kwrd">byte</span>[] buf = <span class="kwrd">new</span> <span class="kwrd">byte</span>[len];
                    <span class="kwrd">int</span> read = 0;
                    xml = <span class="str">""</span>;
                    <span class="kwrd">do</span>
                    {
                        read = stream.Read(buf, 0, len);
                        xml += Encoding.UTF8.GetString(buf, 0, read);

                    }<span class="kwrd">while</span> (read &gt; 0);
                    stream.Close();

                    ParseRSSFeed(xml);
                }
            }
            <span class="kwrd">catch</span> (System.Security.SecurityException ex)
            {
                <span class="rem">// Do Something</span>
            }
 }</pre>
<pre class="csharpcode">&nbsp;</pre>
<pre class="csharpcode">Next, you can include Linq to Xml (add System.Xml.Linq to References) to easily and quickly parse the xml to fetch the user tweets. </pre>
<pre class="csharpcode">You can read more about that on Scott Gu's blog post: <a href="http://weblogs.asp.net/scottgu/pages/silverlight-tutorial-part-3-using-networking-to-retrieve-data-and-populate-a-datagrid.aspx" target="_blank">Silverlight Tutorial Part 3: Using Networking to Retrieve Data and Populate a DataGrid</a></pre>
<pre class="csharpcode">Here is, how I have done it:</pre>
<pre class="csharpcode">The feed  you get from twitter will look like this:</pre>
<pre class="csharpcode"><span class="kwrd">&lt;?</span><span class="html">xml</span> <span class="attr">version</span><span class="kwrd">="1.0"</span> <span class="attr">encoding</span><span class="kwrd">="utf-16"</span>?<span class="kwrd">&gt;</span>
<span class="kwrd">&lt;</span><span class="html">rss</span> <span class="attr">xmlns:atom</span><span class="kwrd">="http://www.w3.org/2005/Atom"</span> <span class="attr">version</span><span class="kwrd">="2.0"</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">channel</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">title</span><span class="kwrd">&gt;</span>Twitter / LON3WOLF<span class="kwrd">&lt;/</span><span class="html">title</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">link</span><span class="kwrd">&gt;</span>http://twitter.com/LON3WOLF<span class="kwrd">&lt;/</span><span class="html">link</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">atom:link</span> <span class="attr">type</span><span class="kwrd">="application/rss+xml"</span> <span class="attr">href</span><span class="kwrd">="http://twitter.com/statuses/user_timeline/22100709.rss"</span> <span class="attr">rel</span><span class="kwrd">="self"</span> <span class="kwrd">/&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">description</span><span class="kwrd">&gt;</span>Twitter updates from Sanil Singh Tomar / LON3WOLF.<span class="kwrd">&lt;/</span><span class="html">description</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">language</span><span class="kwrd">&gt;</span>en-us<span class="kwrd">&lt;/</span><span class="html">language</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">ttl</span><span class="kwrd">&gt;</span>40<span class="kwrd">&lt;/</span><span class="html">ttl</span><span class="kwrd">&gt;</span>
           <span class="kwrd">&lt;</span><span class="html">title</span><span class="kwrd">&gt;</span>LON3WOLF: ehem... RT @Zee: awww man...RT @patrick Best toilet ever! http://twitpic.com/rcvp2 #fb<span class="kwrd">&lt;/</span><span class="html">title</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">item</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">title</span><span class="kwrd">&gt;</span>LON3WOLF: @anilbpai you mean one that looks like xkcd, if you find any tool 4 that, then please RT :)<span class="kwrd">&lt;/</span><span class="html">title</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">description</span><span class="kwrd">&gt;</span>LON3WOLF: @anilbpai you mean one that looks like xkcd<span class="kwrd">&lt;/</span><span class="html">description</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">pubDate</span><span class="kwrd">&gt;</span>Sat, 28 Nov 2009 16:40:22 +0000<span class="kwrd">&lt;/</span><span class="html">pubDate</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">guid</span><span class="kwrd">&gt;</span>http://twitter.com/LON3WOLF/statuses/6144843401<span class="kwrd">&lt;/</span><span class="html">guid</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">link</span><span class="kwrd">&gt;</span>http://twitter.com/LON3WOLF/statuses/6144843401<span class="kwrd">&lt;/</span><span class="html">link</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;/</span><span class="html">item</span><span class="kwrd">&gt;</span>        
        <span class="kwrd">&lt;</span><span class="html">item</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">title</span><span class="kwrd">&gt;</span>LON3WOLF: @anilbpai Go to ' Block ' button-<span class="attr">&amp;amp;</span>gt; Click! Click! :)<span class="kwrd">&lt;/</span><span class="html">title</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">description</span><span class="kwrd">&gt;</span>LON3WOLF: @anilbpai Go to ' Block ' button-<span class="attr">&amp;amp;</span>gt; Click! Click! :)<span class="kwrd">&lt;/</span><span class="html">description</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">pubDate</span><span class="kwrd">&gt;</span>Fri, 27 Nov 2009 18:38:03 +0000<span class="kwrd">&lt;/</span><span class="html">pubDate</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">guid</span><span class="kwrd">&gt;</span>http://twitter.com/LON3WOLF/statuses/6119125496<span class="kwrd">&lt;/</span><span class="html">guid</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">link</span><span class="kwrd">&gt;</span>http://twitter.com/LON3WOLF/statuses/6119125496<span class="kwrd">&lt;/</span><span class="html">link</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;/</span><span class="html">item</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">channel</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">rss</span><span class="kwrd">&gt;</span></pre>
<pre class="csharpcode"><span class="kwrd"><font color="#000000">You can use Linq to XML in following way:</font></span></pre>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> item
{
        <span class="kwrd">public</span> <span class="kwrd">string</span> title;
        <span class="kwrd">public</span> <span class="kwrd">string</span> description;
        <span class="kwrd">public</span> <span class="kwrd">string</span> pubDate;
        <span class="kwrd">public</span> <span class="kwrd">string</span> guid;
        <span class="kwrd">public</span> <span class="kwrd">string</span> link;
}

<span class="kwrd">public</span> <span class="kwrd">void</span> ParseRSSFeed(<span class="kwrd">string</span> xmlContent)
 {

            XDocument rss = XDocument.Parse(xmlContent);
            
            var tweets = from feed <span class="kwrd">in</span> rss.Descendants(<span class="str">"channel"</span>).Descendants(<span class="str">"item"</span>)
                        select <span class="kwrd">new</span> item
                        {
                            guid = (<span class="kwrd">string</span>) feed.Element(<span class="str">"guid"</span>),
                            pubDate = (<span class="kwrd">string</span>)feed.Element(<span class="str">"pubDate"</span>),
                            title = (<span class="kwrd">string</span>)feed.Element(<span class="str">"title"</span>),
                            description = (<span class="kwrd">string</span>)feed.Element(<span class="str">"description"</span>),
                            link = (<span class="kwrd">string</span>)feed.Element(<span class="str">"link"</span>)
                        };

            Status = <span class="kwrd">new</span> item[tweets.Count()];

            <span class="rem">//Copy description to status</span>
            <span class="kwrd">int</span> count = 0;
            <span class="kwrd">foreach</span> (var tweet <span class="kwrd">in</span> tweets)
            {
                Status[count] = tweet;
                count++;
            }
 }</pre>
<pre class="csharpcode"><strong>Links:</strong></pre>
<p><a href="http://thewiredguy.com/Codegarage/wp-content/uploads/2009/10/page_white_swoosh.png"><img loading="lazy" border="0" alt="page_white_swoosh" src="http://thewiredguy.com/Codegarage/wp-content/uploads/2009/10/page_white_swoosh_thumb.png" width="16" height="16"></a> Source Code: <a href="http://thewiredguy.com/Codegarage/?p=109">Download</a></p>
<p><a href="http://thewiredguy.com/Codegarage/wp-content/uploads/2009/10/application_link.png"><img loading="lazy" border="0" alt="application_link" src="http://thewiredguy.com/Codegarage/wp-content/uploads/2009/10/application_link_thumb.png" width="16" height="16"></a> Application: <a href="http://thewiredguy.com/Codegarage/?p=109">Download</a></p>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
]]></content:encoded>
					
					<wfw:commentRss>https://inullable.in/blog/?feed=rss2&#038;p=65</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Presenting Code Garage</title>
		<link>https://inullable.in/blog/?p=63</link>
					<comments>https://inullable.in/blog/?p=63#comments</comments>
		
		<dc:creator><![CDATA[sanil]]></dc:creator>
		<pubDate>Sun, 15 Nov 2009 04:37:04 +0000</pubDate>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Fun, April Fool, Prank]]></category>
		<category><![CDATA[Open Source]]></category>
		<guid isPermaLink="false">http://www.thewiredguy.com/wordpress/?p=63</guid>

					<description><![CDATA[&#160; Presenting Code Garage &#160; &#160; We all (The Programmers) write handy tools and other hell things that can make our life easier (or harder). We don&#8217;t mind it sharing it with others. They are tiny apps/utilities created just for fun or some serious job, made in free time when some idea strikes you. &#160; [&#8230;]]]></description>
										<content:encoded><![CDATA[<h1><a href="http://www.thewiredguy.com/codegarage"><img loading="lazy" style="margin: 5px" align="left" src="http://thewiredguy.com/Codegarage/wp-content/themes/inanis-glass/images/blogicon.png" width="127" height="136"></a></h1>
<h1>&nbsp;</h1>
<h1>Presenting Code Garage</h1>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>We all (The Programmers) write handy tools and other hell things that can make our life easier (or harder). We don&#8217;t mind it sharing it with others. They are tiny apps/utilities created just for fun or some serious job, made in free time when some idea strikes you.</p>
<p><a href="http://www.thewiredguy.com/codegarage"><img loading="lazy" style="margin: 5px" border="0" alt="image" align="left" src="http://thewiredguy.com/BlogImages/PresentingCodeGarage_8D99/image_thumb.png" width="319" height="202"></a>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>With the idea of sharing those utilities and source code, here I am presenting <a href="http://www.thewiredguy.com/codegarage"><strong>Code Garage</strong></a>. Here you can download the applications or use the Source Code, in a way you want.</p>
<p><strong><u>License??</u></strong></p>
<p>Oh! yes it does comes with a license, its WTFPL.</p>
<p><strong><u>What is that??</u></strong></p>
<p><u><a href="http://thewiredguy.com/Codegarage/License.txt" target="_blank">WTFPL</a></u> : Do What The Fuck You Want Public License. (here is <a href="http://sam.zoy.org/wtfpl/" target="_blank">original link</a> )</p>
<p><strong><u>Seriously, What&#8217;s that?</u></strong></p>
<p>Well, here is how it&nbsp; binds you:</p>
<blockquote>
<pre>  DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
                    Version 2, December 2004

 Copyright (C) 2004 Sam Hocevar
  14 rue de Plaisance, 75014 Paris, France
 Everyone is permitted to copy and distribute verbatim or modified
 copies of this license document, and changing it is allowed as long
 as the name is changed.

            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  0. You just DO WHAT THE FUCK YOU WANT TO.</pre>
</blockquote>
<p>In Summary: You can do whatever you want, you are <strong><u>FREE!</u></strong></p>
<p><strong>Q: <u>Can I do that?</u></strong></p>
<p>A: yes, you can</p>
<p><strong>Q: <u>And that?</u></strong></p>
<p>A: duh! Yes <img src="https://s.w.org/images/core/emoji/13.1.0/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /> </p>
<p><strong>Q: <u>Can I add my code here?</u></strong></p>
<p>A: Yes you can, though I would like to see an entire your own blog dedicated to that. but, still if you want you are welcome, just send me an <a href="mailto:sanil.sun@gmail.com" target="_blank">email</a></p>
<p><strong>Last Word</strong>: I hold no liabilities, if you happen to use any code/utilities from here and something bad happens to you, including any loss incurred in any form. That means I am free too from any liabilities, you can&#8217;t sue me in anyway.</p>
<p>Said that, here is a list of the utilities/source code etc that I have uploaded and published plus those that I plan to upload:</p>
<ul>
<li>SMTP</li>
<li>Alarm</li>
<li>Processviewer</li>
<li>BookStore</li>
<li>CDStore</li>
<li>VinkrIt gadget</li>
<li>BSoD</li>
<li>A-Z</li>
<li>Search Plugin</li>
<li>DNS Query</li>
<li>Desktop Shock </li>
<li>batch &amp; Regs</li>
<li>Desktop Draw</li>
<li>Chronometer</li>
<li>Search Gadget</li>
<li>Pagination Extension</li>
<li>Crazy drive</li>
<li>MOaB</li>
<li>Keyboard logger</li>
<li>xKernel</li>
<li>TCP Socket demo for unix</li>
<li>basic java car anim</li>
<li>Expense Reporter</li>
</ul>
<p>Yeah! it covers lamest things, I happen to write.</p>
<p>Still have questions?</p>
]]></content:encoded>
					
					<wfw:commentRss>https://inullable.in/blog/?feed=rss2&#038;p=63</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
	</channel>
</rss>
