Skip to content

Instantly share code, notes, and snippets.

@aturgarg
aturgarg / fibonacci_without_condition_or_recursion.go
Last active September 19, 2020 09:54
fibonacci without condition or recursion (in golang)
package main
import "fmt"
func fibonacci() func() int {
sum := 0
x := 0
y := 1
return func() int {
sum = sum + x
@aturgarg
aturgarg / C#
Created September 8, 2014 09:28
sample demo 1
using System;
public class Program
{
public static void Main()
{
Console.WriteLine("Hello World");
@aturgarg
aturgarg / todo_test.md
Created January 9, 2014 06:59
todo list in github

Create a sample todo using gist ( github style markdown)

  • a task list item
  • list syntax required
  • normal formatting, @mentions, #1234 refs
  • incomplete
  • completed
@aturgarg
aturgarg / dictionary-from-querystring.cs
Created July 29, 2012 08:59
Dictionary from querystring
/// <summary>
/// Parses a query string into a dictionary collection
/// </summary>
/// <param name="queryString">the query string to parse</param>
/// <returns>a dictionary collection of querystring items</returns>
public static Dictionary<string, string> ParseQueryString(string queryString)
{
Dictionary<string, string> nameValueCollection = new Dictionary<string, string>();
string[] items = queryString.Split('&');
@aturgarg
aturgarg / datagrid-dynamic-checkbox.txt
Created July 29, 2012 08:59
Datagrid dynamic checkbox
There is no click event in datagrid's checkcolumn, but the checkbox control has a click event, so you can try to use the datagrid's template column and place a checkbox in template, and add code to checkbox click event code block.
You can try to pre-define the checkbox in the a datatemplate in the usercontro.resource tags, and register the checkbox event, like below:
<UserControl.Resources>
<DataTemplate x:Key="myCellTemplate">
<CheckBox Click="CheckBox_Click"></CheckBox>
</DataTemplate>
</UserControl.Resources>
@aturgarg
aturgarg / file-listing-in-directory.rb
Created July 29, 2012 08:56
file listing in directory
#files listing in a directory and write it to a file
ARGV.each do|a|
puts "Directory: #{a}"
dir_contents = Dir.entries(a)
puts dir_contents
end
#usage
@aturgarg
aturgarg / xmldocument-xdocument-conversion.cs
Created July 29, 2012 08:54
XmlDocument <-> XDocument conversion
private XDocument ConvertXmlDocumentToXDocument(XmlDocument xmlDoc)
{
return XDocument.Load(xmlDoc.CreateNavigator().ReadSubtree());
}
private XmlDocument ConvertXDocumentToXmlDocument(XDocument xDoc)
{
var xmldoc = new XmlDocument();
xmldoc.Load(xDoc.CreateReader());
return xmldoc;
@aturgarg
aturgarg / linq-xml-string-list.cs
Created July 29, 2012 08:54
Linq XML ( string list)
class Program
{
static void Main(string[] args)
{
Program p = new Program();
Console.WriteLine(p.linqStringList());
Console.ReadLine();
}
@aturgarg
aturgarg / linq-xml-object-list.cs
Created July 29, 2012 08:53
Linq XML ( object[] list)
class Program
{
static void Main(string[] args)
{
Program p = new Program();
//Console.WriteLine(p.linqStringList());
Console.WriteLine(p.linqObjectArrayList());
Console.ReadLine();
}
@aturgarg
aturgarg / json-to-xml-and-vice-versa.cs
Created July 29, 2012 08:52
Json to xml and vice-versa
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
/*
* download NewtonSoft josn library from
* http://www.codeplex.com/json/Release/ProjectReleases.aspx
* */