Skip to content

Instantly share code, notes, and snippets.

View kissmygritts's full-sized avatar
🚀

Mitchell Gritts kissmygritts

🚀
  • Reno, NV
View GitHub Profile
@kissmygritts
kissmygritts / ConcatenationJoin.sql
Created May 12, 2015 19:59
Join two tables on a concatenated field using Microsoft Access SQL
SELECT [dc].[WHno] & "." & [dc].[CapDate] AS j1, [lw].[WHno] & "." & [lw].[CapDate] AS j2
FROM data_Capture AS dc INNER JOIN lab_Waddl AS lw ON ([dc].[WHno] & "." & [dc].[CapDate]) = ([lw].[WHno] & "." & [lw].[CapDate]);
@kissmygritts
kissmygritts / R_utm.R
Last active August 29, 2015 14:21
LatLong to UTM, NAD83
to_utm <- function(x, y){
E <- 0.00669438
R <- 6378137
K0 <- 0.9996
E2 <- E * E
E3 <- E2 * E
E_P2 <- E / (1.0 - E)
@kissmygritts
kissmygritts / to_utm.vba
Created May 20, 2015 18:52
VBA lat long to UTM conversion
Function to_utm(x, y) As Collection
Dim coordinates As Collection
Set coordinates = New Collection
E = 0.00669438
R = 6378137
K0 = 0.9996
E2 = E * E
@kissmygritts
kissmygritts / CSV_output.vba
Created May 29, 2015 21:45
Write CSV file from recordset. Used this because N(records) > what access can handle.
Sub data_output()
Dim rs As DAO.Recordset
Dim sql As String
Dim fso As Object, csv As Object
Dim l As String
sql = "SELECT z_dev_collars.Diagnoses, tbl_gps_locations.timestamp, tbl_gps_locations.long_x AS geox, tbl_gps_locations.lat_y AS geoy FROM z_dev_collars LEFT JOIN tbl_gps_locations ON z_dev_collars.Collar_Current_ID = tbl_gps_locations.deviceid WHERE (((tbl_gps_locations.timestamp) Is Not Null));"
Set rs = CurrentDb.OpenRecordset(sql)
Set fso = CreateObject("Scripting.FileSystemObject")
@kissmygritts
kissmygritts / RecordNavigation.vba
Created June 4, 2015 18:22
Navigate through the records of a recordset.
Sub fill_for_validate(action As String, currentwhno As Integer)
Dim rs As DAO.Recordset
Dim qdef As DAO.QueryDef
Set rs = CurrentDb.OpenRecordset("trans_validate")
Debug.Print currentwhno
If action = "first" Then
rs.MoveFirst
@kissmygritts
kissmygritts / InCollection.vba
Created June 23, 2015 22:56
Checks if value is in a collection. True if in collection, False if not in collection
Function InCollection(ByVal ctl As String, col As Collection) As Boolean
For Each c In col
If c = ctl Then
InCollection = True
Exit Function
End If
Next c
InCollection = False
@kissmygritts
kissmygritts / movies.R
Created August 6, 2015 02:43
plotting actor/actress age data
library(ggplot2)
library(ggmap)
library(wesanderson)
dat <- read.csv("Movies - AgeGap (3).csv")
g <- ggplot(data = dat, aes(x = Actress, y = Actor)) +
geom_point(aes(color = factor(Genre)), size = 2.1) +
geom_smooth(method = "lm", se = F, aes(group = factor(Genre), color = factor(Genre)), size = 1) +
#geom_abline(intercept = 0, slope = 1, color = "#227186", size = 1) + ## age equality line
@kissmygritts
kissmygritts / vitals.R
Created August 6, 2015 20:33
Generating plots of vitals for capture reports. Decent for capture reports.
library(readxl)
library(dplyr)
library(ggplot2)
library(gridExtra)
dat <- read_excel("CalebTest.xlsx", "temp_Vitals")
## Adding color factor for temperature plot
dat$temp[dat$Metric >= 105 & dat$VitalSign == "TR"] <- "high"
dat$temp[dat$Metric < 105 & dat$VitalSign == "TR"] <- "low"
@kissmygritts
kissmygritts / data_entry.vba
Last active September 8, 2015 21:07
Useful vba routines for data entry forms
'------------------------------------------------------------------------------
' Purpose: sample comment
' Args:
' Created:
' Modified:
' Author:
'-------------------------------------------------------------------------------
'===============================================================================
Sub MoveFirst()
'------------------------------------------------------------------------------
@kissmygritts
kissmygritts / SampleYear.SQL
Created September 4, 2015 19:27
Calculate sample year in SQL query. If month >= 6, SY = Current Year, Else SY = CY - 1
SampleYear: IIf(Month([data_Capture].[CapDate])>=6,Year([data_Capture].[CapDate]),(Year([data_Capture].[CapDate])-1))