Skip to content

Instantly share code, notes, and snippets.


Sarath C sharat

View GitHub Profile
sharat /
Created Jul 2, 2015
Brew dependencies
brew list | while read cask; do echo -n "\e[1;34m$cask ->\e[0m"; brew deps $cask | awk '{printf(" %s ", $0)}'; echo ""; done
sharat / apns-check-openssl
Created Oct 9, 2014
How to check APNS Connectivity?
View apns-check-openssl
openssl s_client -connect -cert <your.pem> -key <your.pem>
sharat / git-revert-sample
Created Sep 9, 2014
How to use git revert?
View git-revert-sample
git-revert $ git init
git-revert (master) $ touch 1.txt
git-revert (master) $ touch 2.txt
git-revert (master) $ git add .
git-revert (master) $ git commit -am "wanted commit 1"
[master (root-commit) 80395aa] wanted commit 1
2 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 1.txt
create mode 100644 2.txt
sharat /
Created Dec 13, 2012
convert the line endings of multiple files in a directory with the help of vi editor.
#Convert from dos/unix to unix
#To convert from any mixture of CRLF endings and LF-only endings, to LF-only endings:[C 1]
:set hidden #Allow modified buffers to be hidden.
:set ffs=dos #Assume dos line endings (CRLF or LF-only) when reading files.
:args *.c *.h #Specify the files to convert.
:argdo set ff=unix|w #For each argument, set unix file format for the buffer, and write the file.[C 2]
#Convert from dos/unix to dos
sharat / ipaddrescheck.cpp
Created Dec 12, 2012
Check the given IP address is in IPv6 or v4 format (windows version)
View ipaddrescheck.cpp
// 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)
sharat /
Created Dec 7, 2012
Useful git commands
# 1. Reset the modifications
git checkout -- <filename>
sharat / MemoryInfo.cs
Created Oct 23, 2012
Memory Info in C#
View MemoryInfo.cs
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);
public struct PerformanceInformation
public int Size;
View radix-sort.cpp
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 / SysInfoHelper.cs
Created Oct 17, 2012
Get the operating system information using C#
View SysInfoHelper.cs
using System.Management;
using System.Security.Principal;
using Microsoft.Win32;
public class SysInfoHelper
public static void LogSystemInfo(int messageID)
sharat / SQLServerDataSources.cs
Created Oct 17, 2012
Function to check SQLServer Data Sources and version
View SQLServerDataSources.cs
private static void PrintSQLServerInfo()
SqlDataSourceEnumerator dataSourceEnumarator = SqlDataSourceEnumerator.Instance;
DataTable dataTable = dataSourceEnumarator.GetDataSources();
foreach (DataRow row in dataTable.Rows)
Console.WriteLine("Server Name:" + row["ServerName"]);
Console.WriteLine("Instance Name:" + row["InstanceName"]);
Console.WriteLine("Is Clustered:" + row["IsClustered"]);
You can’t perform that action at this time.