Skip to content

Instantly share code, notes, and snippets.

View sharat's full-sized avatar

Sarath C sharat

View GitHub Profile
@sharat
sharat / LICENSE.txt
Created September 29, 2011 06:01 — forked from p01/LICENSE.txt
Sudoku Solver in 140bytes
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Mathieu 'p01' Henri <http://www.p01.org/releases/>
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
@sharat
sharat / gist:3239478
Created August 2, 2012 18:32
How to use Gist.io

Create a public gist on Github with one or more Markdown-syntax files. Note the gist ID number. It’s usually a longish number like 29388372. View your writing presented nicely at gist.io/gist-id-here

@sharat
sharat / ListViewColumnHeaderSample.cs
Created October 12, 2012 12:44
Drawing CheckBox in the ListView Column Header
public partial class Form1 : Form
{
bool clicked = false;
CheckBoxState state;
public Form1()
{
InitializeComponent();
listView1.View = View.Details;
listView1.Columns.Add("Col1", 150);
listView1.Columns.Add("Col2", 150);
@sharat
sharat / svnhelpers.sh
Created October 15, 2012 12:40
Useful SVN commands
## Get the modified file list
svn status | grep '^M '
@sharat
sharat / SQLServerDataSources.cs
Created October 17, 2012 06:12
Function to check SQLServer Data Sources and version
private static void PrintSQLServerInfo()
{
SqlDataSourceEnumerator dataSourceEnumarator = SqlDataSourceEnumerator.Instance;
DataTable dataTable = dataSourceEnumarator.GetDataSources();
foreach (DataRow row in dataTable.Rows)
{
Console.WriteLine("----------------------------Sources----------------------------");
Console.WriteLine("Server Name:" + row["ServerName"]);
Console.WriteLine("Instance Name:" + row["InstanceName"]);
Console.WriteLine("Is Clustered:" + row["IsClustered"]);
@sharat
sharat / SysInfoHelper.cs
Created October 17, 2012 10:31
Get the operating system information using C#
using System.Management;
using System.Security.Principal;
using Microsoft.Win32;
public class SysInfoHelper
{
public static void LogSystemInfo(int messageID)
{
LogOSVersionInfo(messageID);
LogUserInfo(messageID);
@sharat
sharat / radix-sort.cpp
Created October 19, 2012 06:34
radi sort
void radix_sort(unsigned *begin, unsigned *end)
{
unsigned *begin1 = new unsigned[end - begin];
unsigned *end1 = begin1 + (end - begin);
for (unsigned shift = 0; shift < 32; shift += 8) {
size_t count[0x100] = {};
for (unsigned *p = begin; p != end; p++)
count[(*p >> shift) & 0xFF]++;
@sharat
sharat / MemoryInfo.cs
Created October 23, 2012 11:14
Memory Info in C#
public static class MemoryInfo
{
[DllImport("psapi.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetPerformanceInfo([Out] out PerformanceInformation PerformanceInformation, [In] int Size);
[StructLayout(LayoutKind.Sequential)]
public struct PerformanceInformation
{
public int Size;
@sharat
sharat / gitsnippets.sh
Created December 7, 2012 15:02
Useful git commands
# 1. Reset the modifications
git checkout -- <filename>
@sharat
sharat / ipaddrescheck.cpp
Created December 12, 2012 04:20
Check the given IP address is in IPv6 or v4 format (windows version)
// Change the headefile for Windows
#include <memory>
#include <winsock2.h>
#include <ws2tcpip.h>
#pragma comment(lib,"Ws2_32.lib");
#include <string>
using namespace std;
// This is compatible with old version of Windows.
bool IsIPAddress(const string& value)