Skip to content

Instantly share code, notes, and snippets.

View kitmenke's full-sized avatar

Kit Menke kitmenke

View GitHub Profile
@kitmenke
kitmenke / MakeNegative.js
Created October 7, 2021 03:01
Google Apps Script: Make Negative
function MakeNegative() {
var spreadsheet = SpreadsheetApp.getActive();
var activeRange = spreadsheet.getActiveRange();
var values = activeRange.getValues();
values.forEach(function(row, rowId) {
row.forEach(function(col, colId) {
values[rowId][colId] = Math.abs(values[rowId][colId]) * -1;
});
});
# Profile setup instructions: http://www.howtogeek.com/50236/customizing-your-powershell-profile/
# Create inside WindowsPowerShell folder
echo "Profile loaded from $profile"
#cd C:\git
# Set environment variables
#$env:MAVEN_OPTS = "-Xmx512m"
#$env:MAVEN_VERSION = "3.3.9"
#$env:JAVA_HOME = "C:\Program Files\Java\jdk1.8.0_92"
#$env:M2_HOME = "C:\Apps\apache-maven-$($env:MAVEN_VERSION)"
FNR > 6 {
print $1
}
#!/bin/bash
PARENT_DIR=$1
if [ -z "${PARENT_DIR}" ]; then
echo Missing 1 parameter for HDFS parent directory
exit 1
fi
hdfs dfs -ls ${PARENT_DIR} | awk '{ print $8}' | sed '/^\s*$/d' > dirs.txt
echo ' DIR_COUNT FILE_COUNT CONTENT_SIZE PATHNAME'
while read dir; do
hdfs dfs -count -h $dir
@kitmenke
kitmenke / readme.md
Last active August 8, 2016 22:24
Example Python scripts which parse some arguments and log to console/file.

Python 2.6 example

Program runs using 2.6.9 without any dependencies:

#!/user/bin/env python
"""
An example python 2.6 script which takes arguments and logs to console/file.
"""
import logging
@kitmenke
kitmenke / finderrors.ps1
Created August 1, 2016 02:45
Working in progress: powershell script to automatically fix DCOM errors which show up in the event log
# Get-EvengLog doesn't quite work I guess:
# https://stackoverflow.com/questions/31396903/get-eventlog-valid-message-missing-for-some-event-log-sources#
# Get-EventLog Application -EntryType Error -Source "DistributedCOM"
# The application-specific permission settings do not grant Local Activation permission for the COM Server application with CLSID
#$logs = Get-EventLog -LogName "System" -EntryType Error -Source "DCOM" -Newest 1 -Message "The application-specific permission settings do not grant Local Activation permission for the COM Server application with CLSID*"
# 2 is error
# 3 is warning
$EVT_MSG = "The application-specific permission settings do not grant Local Activation permission for the COM Server application with CLSID"
# Search for System event log ERROR entries starting with the specified EVT_MSG
$logEntry = Get-WinEvent -FilterHashTable @{LogName='System'; Level=2} | Where-Object { $_.Message -like "$EVT_MSG*" } | Select-Object -First 1
@kitmenke
kitmenke / .bashrc
Created July 19, 2016 13:35
Start ssh agent
SSH_ENV="$HOME/.ssh/environment"
function start_agent {
echo "Initialising new SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
echo succeeded
chmod 600 "${SSH_ENV}"
. "${SSH_ENV}" > /dev/null
/usr/bin/ssh-add;
}
@kitmenke
kitmenke / groovy.sh
Created July 15, 2016 02:09
Groovy script which uses log4j, runs the list command, and gets the output
#!/bin/bash
# Run a groovy script
# argument should be path to .groovy file
HIVEDIR="/usr/hdp/current/hive-client/lib"
# Include log4j properties in the classpath so we can do logging
JAVACP="log4j.properties"
# Need groovy-all jar to run groovy scripts
JAVACP="$JAVACP:$HIVEDIR/groovy-all-2.1.6.jar"
JAVACP="$JAVACP:$HIVEDIR/log4j-1.2.16.jar"
java -cp $JAVACP groovy.ui.GroovyMain $1
@kitmenke
kitmenke / createPartitions.ps1
Created July 8, 2016 13:46
Script to create SSAS partions for a table in a tabular model, refresh all of the partitions, and/or print all partitions.
# ------------------------------------------------------------------------
#
# NAME: CreatePartitions.ps1
# AUTHOR: Kit Menke
# DATE: 2016-05-13
#
# COMMENTS:
# Create SSAS partions for a table in a tabular model.
# Must be run with sqlps.
#
/*
Author: Kit Menke (@kitmenke)
Description:
Put the script on the EditForm of a list. When editing an item, the script will query
the tasks list in the site for any associated Workflow Items.
SharePoint functions used:
JavaScript Client Object Model
String.format
byid