Skip to content

Instantly share code, notes, and snippets.

View ramnov's full-sized avatar

Ramkumar Chandrasekaran ramnov

View GitHub Profile
@ramnov
ramnov / rxExecBySpark.R
Last active April 26, 2017 17:32
rxExecBy() example on Spark Compute Context
# start Spark app
sparkCC <- rxSparkConnect()
# upload data to hdfs
rxHadoopMakeDir("/share/SampleData")
rxHadoopCopyFromLocal(file.path(dataPath = rxGetOption("sampleDataDir"), "*"), "/share/SampleData")
# define a user function that builds a linear model
".linMod" <- function(keys, data)
{
@ramnov
ramnov / rxExecBySql.R
Last active April 26, 2017 17:04
rxExecBy() example on SQL Compute Context
# SQL SERVER COMPUTE CONTEXT
sqlServerConnString <- "SERVER=hostname;DATABASE=RevoTestDB;UID=DBUser;PWD=Password;"
inTable <- paste0("airlinedemosmall")
sqlServerDataDS <- RxSqlServerData(table = inTable, connectionString = sqlServerConnString)
# user function
".Count" <- function(keys, data, params)
{
myDF <- rxImport(inData = data)
return (nrow(myDF))
@ramnov
ramnov / rxExecByLocal.R
Last active April 19, 2017 18:13
rxExecBy() examples for Local Compute Context
# Set Compute Context
rxSetComputeContext("localpar")
# use all the cores available
rxOptions(numCoresToUse = -1)
# Data Sources
sampleDataDir <- rxGetOption("sampleDataDir")
XdfDataSource <- RxXdfData(file.path(sampleDataDir, "claims.xdf"))
TextDataSource <- RxTextData(file.path(sampleDataDir, "claims.txt"))
SasDataSource <- RxSasData(file.path(sampleDataDir, "claims.sas7bdat"))
@ramnov
ramnov / rVersion.sql
Last active March 25, 2017 00:01
SQL script to check R version
exec sp_execute_external_script
@language = N'R' ,
@script = N'print(R.Version()$version)'
@ramnov
ramnov / azuresmr.R
Created March 23, 2017 01:29
Create HDI R Server cluster in R Session using AzureSMR package
# Fill in the blanks with appropriate values
library(AzureSMR)
client_id <- "---------------------"
app_key <- "---------------------"
tenant_id <- "---------------------"
sc <- createAzureContext(tenantID = tenant_id, clientID = client_id, authKey = app_key)
rgs <- azureListRG(sc)
rgs
@ramnov
ramnov / loadMicrosoftML.sql
Last active July 19, 2017 10:22
SQL script to check if MicrosoftML package can be loaded
exec sp_execute_external_script
@language = N'R' ,
@script = N'library(MicrosoftML)'
@ramnov
ramnov / DeploymentHelper.cs
Created March 21, 2017 00:42
C# program to deploy ARM Template
// Requires the following Azure NuGet packages and related dependencies:
// package id="Microsoft.Azure.Management.Authorization" version="2.0.0"
// package id="Microsoft.Azure.Management.ResourceManager" version="1.4.0-preview"
// package id="Microsoft.Rest.ClientRuntime.Azure.Authentication" version="2.2.8-preview"
using Microsoft.Azure.Management.ResourceManager;
using Microsoft.Azure.Management.ResourceManager.Models;
using Microsoft.Rest.Azure.Authentication;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
@ramnov
ramnov / deployer.rb
Created March 21, 2017 00:42
Ruby script to deploy ARM Template
require 'azure_mgmt_resources'
class Deployer
# Initialize the deployer class with subscription, resource group and resource group location. The class will raise an
# ArgumentError if there are empty values for Tenant Id, Client Id or Client Secret environment variables.
#
# @param [String] subscription_id the subscription to deploy the template
# @param [String] resource_group the resource group to create or update and then deploy the template
# @param [String] resource_group_location the location of the resource group
@ramnov
ramnov / deploy-preview.sh
Created March 21, 2017 00:41
Azure CLI v2.0 preview script to deploy ARM Template to a Resource Group
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
# -e: immediately exit if any command has a non-zero exit status
# -o: prevents errors in a pipeline from being masked
# IFS new value is less likely to cause confusing bugs when looping arrays or arguments (e.g. $@)
usage() { echo "Usage: $0 -i <subscriptionId> -g <resourceGroupName> -n <deploymentName> -l <resourceGroupLocation>" 1>&2; exit 1; }
@ramnov
ramnov / deploy.sh
Created March 21, 2017 00:40
azure cli bash script to deploy ARM Template to a Resource Group
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
# -e: immediately exit if any command has a non-zero exit status
# -o: prevents errors in a pipeline from being masked
# IFS new value is less likely to cause confusing bugs when looping arrays or arguments (e.g. $@)
usage() { echo "Usage: $0 -i <subscriptionId> -g <resourceGroupName> -n <deploymentName> -l <resourceGroupLocation>" 1>&2; exit 1; }