Skip to content

Instantly share code, notes, and snippets.

@manishsat
manishsat / aks-large-cluster.sh
Created January 18, 2023 18:42 — forked from jackfrancis/aks-large-cluster.sh
Build large AKS cluster
#!/bin/bash
if [ -z "$RESOURCE_GROUP" ]; then
echo "must provide a RESOURCE_GROUP env var"
exit 1;
fi
if [ -z "$REGION" ]; then
echo "must provide a REGION env var"
exit 1;
@manishsat
manishsat / README.md
Created November 4, 2020 22:27 — forked from tommct/README.md
FreeTDS and pyodbc on Mac OS X 10.8 via Homebrew

After spending many hours trying to get FreeTDS and unixodbc to run on a Mac OS X 10.8 system with the python module, pyodbc, I eventually came to this recipe, which is remarkably simple thanks to homebrew. I also found unixodbc was unnecessary and I couldn't get it to play well with FreeTDS, so this install does not include unixodbc. See also http://www.acloudtree.com/how-to-install-freetds-and-unixodbc-on-osx-using-homebrew-for-use-with-ruby-php-and-perl/ and http://www.cerebralmastication.com/2013/01/installing-debugging-odbc-on-mac-os-x/.

Prerequisites: Be sure you have XCode and the Commandline Tools for XCode installed from Apple. Also install homebrew followed with brew update and brew doctor.

Install FreeTDS:

brew install freetds

Test your install:

@manishsat
manishsat / azuredeploy.json
Created August 30, 2019 23:15 — forked from dazfuller/azuredeploy.json
Azure Data Lake Gen 2 - ARM template
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "0.0.0.1",
"parameters": {
"resourcePrefix": {
"type": "string",
"minLength": 3,
"maxLength": 10,
"metadata": {
"description": "The prefix to use for resources within the resource group"
@manishsat
manishsat / gist:49683fdae5daeb441e44731385777401
Created December 9, 2016 07:08 — forked from bittib/gist:5449327
N Queen Problem. Print all solutions for N queen based on either row first order or column first. http://poj.grids.cn/practice/2698/
import java.io.*;
public class Main{
static PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
static int N = 8;
static int cnt = 0;
public static void main(String[] args){
int[] array = new int[N];
cnt = 0;
@manishsat
manishsat / KthSmallestOfTwoSortedArrays.java
Created December 9, 2016 07:07 — forked from bittib/KthSmallestOfTwoSortedArrays.java
Find the k-th Smallest Element in the Union of Two Sorted Arrays
/**
* http://leetcode.com/2011/01/find-k-th-smallest-element-in-union-of.html
* O(lgm + lgn) Solution
*/
static final int MIN = Integer.MIN_VALUE;
static final int MAX = Integer.MAX_VALUE;
public static int kthSmallest(int[] A, int[] B, int k){
if (A == null || B == null || k > A.length + B.length)
@manishsat
manishsat / gist:8f33b7102a60cde7088673664d02b4ee
Created December 9, 2016 07:06 — forked from bittib/gist:5567049
find the minimum and maximum element from an array with minimum time of comparision
/**
* Time Complexity : Comparision time : 3 * n/2 + 1
*/
public int[] findMinMax(int[] A){
int n = A.length;
if (n == 0) return null;
int min = Integer.MAX_VALUE, max = Integer.MIN_VALUE;
for (int i=0; i < n-1; i+=2){
int smaller = A[i], bigger = A[i+1];
if (A[i] > A[i+1){
@manishsat
manishsat / AddBinary.java
Created December 9, 2016 07:06 — forked from bittib/AddBinary.java
Add binary string
/**
* LeetCode Add Binary Probem
Given two binary strings, return their sum (also a binary string).
For example,
a = "11"
b = "1"
Return "100".
*/
@manishsat
manishsat / FlattenBinaryTreeToLinkedList.java
Created December 9, 2016 07:05 — forked from bittib/FlattenBinaryTreeToLinkedList.java
Flatten Binary Tree to Linked List. Time Complexity : O(n). Don't use extral space.
class TreeNode{
int val;
TreeNode left, right;
TreeNode(int val){
this.val = val;
}
}
public void flatten(TreeNode root){
root = flatten(root, null);
@manishsat
manishsat / SerializingBinaryTree.java
Created December 9, 2016 07:05 — forked from bittib/SerializingBinaryTree.java
Serialize and Deserialize a Binary Tree (pre order).
class TreeNode{
int val;
TreeNode left, right;
TreeNode(int val){
this.val = val;
}
}
public String serialize(TreeNode root){
StringBuilder sb = new StringBuilder();
@manishsat
manishsat / TrappingRainWater.java
Created December 9, 2016 07:04 — forked from bittib/TrappingRainWater.java
Trapping Rain Water Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. For example, Given [0,1,0,2,1,0,1,3,2,1,2,1], return 6
public int trap(int[] A){
int n = A.length, sum = 0;
if (n < 3) return 0;
int[] leftBar = new int[n], rightBar = new int[n];
for (int i=1; i<n; i++)
leftBar[i] = Math.max(leftBar[i-1], A[i-1]);
for (int i=n-2; i>=0; i--)
rightBar[i] = Math.max(rightBar[i+1], A[i+1]);
for (int i=0; i<n; i++)
sum += Math.max(0, Math.min(leftBar[i], rightBar[i]) - A[i]);