Skip to content

Instantly share code, notes, and snippets.

View anujku's full-sized avatar

Anuj Kulkarni anujku

View GitHub Profile
@anujku
anujku / ExportSchema.ps1
Created October 5, 2016 19:57 — forked from cheynewallace/ExportSchema.ps1
Export MSSQL schema with PowerShell. This script will export your schema definitions for tables, stored procs, triggers, functions and views to .sql files
# Usage: powershell ExportSchema.ps1 "SERVERNAME" "DATABASE" "C:\<YourOutputPath>"
# Start Script
Set-ExecutionPolicy RemoteSigned
# Set-ExecutionPolicy -ExecutionPolicy:Unrestricted -Scope:LocalMachine
function GenerateDBScript([string]$serverName, [string]$dbname, [string]$scriptpath)
{
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | Out-Null
@anujku
anujku / rational.scala
Last active May 31, 2016 05:50
Scala Functions and Data
class Rational(x: Int, y: Int) {
require(y != 0, "denominator must be non zero")
def this(x: Int) = this(x, 1)
private def gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b)
private val g = gcd(x, y)
// sqrt(x) = y = x / y
// sqrt(x) -> fixed point of function (y => x/y)
// with damping => sqrt(x) = ( y = (((y + x) / y) / 2) (1.0)
// def sqrt(x : Double) = fixedPoint(y => ((y + x) / 2)) (1.0)
import math.abs
val tolerance = 0.0001
def isCloseEnough(a: Double, b: Double): Boolean = {
abs((a - b) / a) / a < tolerance
@anujku
anujku / currying.scala
Created May 31, 2016 01:05
Scala Currying Examples
def product(func: Int => Int)(a: Int, b: Int): Int = {
if (a > b)
1
else
func(a) * product(func)(a + 1, b)
}
product((x) => (x + x))(1, 3)
def fact(a: Int): Int = {
@anujku
anujku / huluAssesment.groovy
Last active August 29, 2015 14:23
HULU Test
def inputFile = new File("org_chart.in")
def outputFile = new File("org_chart_.out")
outputFile.delete()
int lineCount = 0
def orgCharts = []
inputFile.eachLine { line ->
def orgChart = [:]
def employees = [:]
@anujku
anujku / README.md
Created June 5, 2015 20:13
Running Groovy from Sublime Text Editor

Running Groovy from Sublime Text Editor

  • Open the editor and go to menu Tools->Build System
  • This will open a new file named untitled.sublime-build
  • Add the path to your Groovy installation directory as show below.
{
  "cmd": ["C:/Users/kulkan02/.gvm/groovy/2.3.0/bin/groovy.bat", "$file"]
}
@anujku
anujku / arithmetic.pegjs
Created June 2, 2015 04:00
Simple Arithmetics Grammar
/*
* Simple Arithmetics Grammar
* ==========================
*
* Accepts expressions like "2 * (3 + 4)" and computes their value.
*/
{
function combine(first, rest, combiners) {
var result = first, i;
// Node.js CheatSheet.
// Download the Node.js source code or a pre-built installer for your platform, and start developing today.
// Download: http://nodejs.org/download/
// More: http://nodejs.org/api/all.html
// 0. Synopsis.
// http://nodejs.org/api/synopsis.html
@anujku
anujku / calc.pegjs.js
Last active October 19, 2022 23:48
Calculator Peg JS
start
= any
any
= multiplicative
/ divisive
/ power
/ additive
/ subtractive
/ primary

Movies Recommendation:

Music Recommendation: