Skip to content

Instantly share code, notes, and snippets.

@Lbatson
Lbatson / Table.js
Last active February 1, 2021 18:45
Simple generic table using React
import _ from 'lodash';
import React, { Component } from 'react';
class Table extends Component {
render() {
const { columns, data } = this.props;
// spread two-dimensional array to arguments for zip
// destructure resulting array elements from zip
let [names, props] = _.zip(...columns);
// build column headers with name values
func setTimeForDate (date: NSDate, hour: Int, minute: Int, second: Int) -> NSDate {
let unitFlags = [.Year, .Month, .Day, .Hour, .Minute, .Second] as NSCalendarUnit
// calendar here is NSCalendar.currentCalendar()
let dateComponents = calendar.components(unitFlags, fromDate: date)
dateComponents.hour = hour
dateComponents.minute = minute
dateComponents.second = second
let newDate = calendar.dateFromComponents(dateComponents)
print(newDate)
return newDate!
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet(),
sheet = SpreadsheetApp.getActiveSheet(),
rows = sheet.getDataRange(),
numRows = rows.getNumRows(),
values = rows.getValues(),
endDate = new Date(),
endDateCell = sheet.getRange("J2"),
archiveCounter = sheet.getRange("K2").getValue(),
archiveFolder = '',
emailCell = sheet.getRange("L2").getValue(),
var sheet = SpreadsheetApp.getActiveSheet(),
rows = sheet.getDataRange(),
numRows = rows.getNumRows(),
values = rows.getValues(),
startTimeCol = 3,
endTimeCol = 4,
re = ' at';
/**
* Retrieves all the rows in the active spreadsheet that contain data and converts Date/Time if necessary
@Lbatson
Lbatson / fileutils.py
Created February 13, 2014 23:59
file and directory utilities
import sys
import getopt
import os
import string as str
def findDuplicateFilenames(dir):
unique, dupes = [], []
try:
for filename in os.listdir(dir):
name = str.split(filename, '.')[0]
@Lbatson
Lbatson / csv-mysql-inserts.py
Last active November 20, 2021 00:55
Converts csv data to mysql insert statements
#converts csv data to mysql insert statements
import csv
#prompt user for file name
filename = raw_input("Enter the csv file name: ")
tablename = raw_input("Enter db table name for insert statements: ")
# open csv file
with open(filename + '.csv', 'rb') as csvfile:
# store in dict