Skip to content

Instantly share code, notes, and snippets.

View abhilash0001's full-sized avatar

Abhilash Shamsunder abhilash0001

View GitHub Profile
public static string reverseString(string str)
{
return !string.IsNullOrEmpty(str) ? reverse(str) : string.Empty;
}
private static string reverse(string str)
{
var stk = new Stack();
for (int i = 0; i < str.Length; i++)
{
// input: Welcome to Csharp corner
// output: corner Csharp to Welcome
internal static void ReverseWordOrder(string str)
{
int i;
StringBuilder reverseSentence = new StringBuilder();
int Start = str.Length - 1;
int End = str.Length - 1;
public class ParenthesisBalancing
{
public bool checkIfParanthesisIsBalanced(string str)
{
return !string.IsNullOrEmpty(str) ? check(str) : false;
}
private bool check(string str)
{
var s = new Stack();
internal string isPalindrome(string str)
{
bool flag = false;
if (!string.IsNullOrEmpty(str))
{
for (int i = 0, j = str.Length -1; i < str.Length /2; i++, j--)
{
if (str[i] != str[j])
{
flag = false;
@abhilash0001
abhilash0001 / ParenthesisBalancing.cs
Created July 19, 2017 20:27
Parenthesis Balancing
// Stack Implementation
const char leftParenthesis = '(';
const char rightParenthesis = ')';
const string inputStr = "((())())()()";
public bool checkIfBalanced(){
var items = new Stack<int>(inputStr.Length);
for(int i = 0; i < inputStr.Length; i++){
@abhilash0001
abhilash0001 / MoveAllZeros.cs
Created July 19, 2017 20:11
Move all zeros to end
// C# implementation with node traversing
public static int[] arr = {9, 1, 9, 0, 7, 0, 3, 5, 0};
public int[] pushZerosToEnd(){
var arrCount = arr.Count();
var count = 0;
for (int i = 0; i < arrCount; i++){
if (arr[i] != 0){
arr[count++] = arr[i];
}
public int GetDescendantsCount(Item item)
{
using (SqlConnection conn = new SqlConnection(Sitecore.Configuration.Settings.GetConnectionString(Sitecore.Context.Database.ConnectionStringName)))
{
try
{
conn.Open();
Assert.IsNotNull(item, "A valid Sitecore item must be provided to this method");
string query = @"with cteChildren as
{
"Version":"2008-10-17",
"Statement":[{
"Sid":"AllowPublicRead",
"Effect":"Allow",
"Principal": {
"AWS": "*"
},
"Action":["s3:GetObject"],
"Resource":["arn:aws:s3:::bucket/*"
@abhilash0001
abhilash0001 / gist:1e8b65766c6c2468e42c
Created January 29, 2016 20:20
Wordpress JSON API Controller
<?php
/*
Controller name: Layouts & Components
Controller description: Custom layouts and components controller
*/
class JSON_API_Custom_JSON_API_Controller {
// Get all components
public function get_components() {
@abhilash0001
abhilash0001 / gist:2e8127714b6eb635a056
Created August 11, 2014 21:57
Allow SVG uploads to wordpress
/*
Place this code within functions.php file.
(Or) to your plugins folder if you are building a custom plugin
*/
function cc_mime_types( $mimes ){
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter( 'upload_mimes', 'cc_mime_types' );