Skip to content

Instantly share code, notes, and snippets.

View kyle-mccarthy's full-sized avatar

Kyle McCarthy kyle-mccarthy

  • St. Louis, United States
View GitHub Profile
@kyle-mccarthy
kyle-mccarthy / min
Last active August 29, 2015 14:12
find min pivot value
## https://oj.leetcode.com/problems/find-minimum-in-rotated-sorted-array/
class Solution:
def findMin(self, nums):
mem = list()
mem.append(nums[0])
mem = self.findMinRecur(nums, mem)
return mem[0]
library(ggplot2)
library(rworldmap)
library(ggmap)
cd = read.csv("NA-1990-2002-Monthly.csv")
year = cd$YEAR
month = cd$MONTH
time = paste(year, month, sep="_")
temp = cd$TMP
@kyle-mccarthy
kyle-mccarthy / gulpfile.js
Created June 19, 2017 14:26
gulpfile.js for yii2
const gulp = require('gulp'), sass = require('gulp-sass'), browserify = require('browserify'),
concat = require('gulp-concat'), glob = require('glob'), uglify = require('gulp-uglify'),
source = require('vinyl-source-stream'), buffer = require('vinyl-buffer'), sourcemaps = require('gulp-sourcemaps'),
gutil = require('gulp-util'), babelify = require('babelify'), rename = require("gulp-rename"),
watch = require('gulp-watch'), yargs = require('yargs'), gulpif = require('gulp-if');
let args = yargs.argv;
let isProd = !!(args.prod);
let _compileScripts = () => {
@kyle-mccarthy
kyle-mccarthy / gtm-config.py
Created August 17, 2017 20:02
Py class for configuring GTM for container based on JSON
import argparse
import sys
import httplib2
import re
import json
from googleapiclient.discovery import build
from oauth2client import client
from oauth2client import file
from oauth2client import tools
@kyle-mccarthy
kyle-mccarthy / callrailGoogleMaps.js
Last active February 7, 2018 17:35
Modify Google Maps with Callrail numbers
var callrailGoogleMaps = {
getNumbers: function() {
var self = this;
window.CallTrk.getSwapNumbers(null, function(nums) {
self.swapNumbers(nums);
});
},
getMapPoints: function() {
if (mapping !== undefined) {
return mapping.mapPoint.alllocmap.points;
@kyle-mccarthy
kyle-mccarthy / GsappedComponent.jsx
Last active February 7, 2018 17:40
GSAP HOC React
import React from 'react';
import { TimelineLite, TweenLite } from 'gsap';
const asGsapped = (WrappedComponent) => {
return class GsappedComponent extends React.PureComponent {
constructor(props) {
super(props);
}
@kyle-mccarthy
kyle-mccarthy / ScrolllockComponent.jsx
Created February 7, 2018 17:45
React locking of body scroll for desktop and touch devices
import React from 'react';
const withScrolllock = (WrappedComponent) => {
return class ScrolllockComponent extends React.Component {
constructor(props) {
super(props);
this.y = null;
this.ref = null;
}
@kyle-mccarthy
kyle-mccarthy / gaLinkDecorator.js
Created January 17, 2019 20:04
Decorate outbound link for cross domain tracking
const decorateLink = (destinationUrl) => {
if (ga !== undefined && typeof ga.getAll === 'function') {
const trackers = ga.getAll();
if (trackers.length > 0) {
const linker = new window.gaplugins.Linker(trackers[0]);
return linker.decorate(destinationUrl);
}
}
return destinationUrl;
}
@kyle-mccarthy
kyle-mccarthy / cache-config.service.ts
Created February 20, 2020 20:48
nest.js cache config for redis
import {
CacheModuleOptions,
CacheOptionsFactory,
Injectable,
} from '@nestjs/common';
import { LoggerService } from '@src/common/logger.service';
import { ConfigOptions, ConfigService } from '@src/config/config.service';
import * as redisCacheStore from 'cache-manager-redis-store';
@Injectable()
@kyle-mccarthy
kyle-mccarthy / compound3.sdf
Created January 20, 2021 17:03
SDF file example (Chemical table file) from pubchem
3
-OEChem-01172103382D
19 19 0 1 0 0 0 0 0999 V2000
5.1350 1.3450 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
6.8671 0.3450 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
2.5369 -0.1550 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
3.4030 1.3450 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
5.1350 0.3450 0.0000 C 0 0 3 0 0 0 0 0 0 0 0 0
6.0010 -0.1550 0.0000 C 0 0 3 0 0 0 0 0 0 0 0 0