Instantly share code, notes, and snippets.

View Table.js
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
View setTimeForDate.swift
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!
View timetrackingpart2.js
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(),
View timetrackingpart1.js
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
View fileutils.py
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]
View csv-mysql-inserts.py
#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