Skip to content

Instantly share code, notes, and snippets.

View gtracy's full-sized avatar

Greg Tracy gtracy

View GitHub Profile
@gtracy
gtracy / bootDynamo.js
Created October 25, 2022 00:46
Create a new DynamoDB table from NodeJS
'use strict';
/***********************************************/
// configure these values for your Dynamo table
//
const TABLE_NAME = 'FIXME';
const table_params = {
TableName : TABLE_NAME,
KeySchema: [
@gtracy
gtracy / csvToDynamo.js
Created October 25, 2022 00:38
Import CSV file into DynamoDB
'use strict';
//
// core logic for importing and transforming a CSV dataset, and
// storing the results in a Dynamo table
//
const Fs = require('fs');
const CsvReadableStream = require('csv-reader');
const prompt = require('prompt-sync')({sigint: true});
@gtracy
gtracy / slurpy.js
Created July 12, 2020 19:32
Tweet dowload script
const Twit = require('twit')
const async = require('async');
/*
* ASSUMES YOU'VE STASHED YOUR TWEETS FROM A TWITTER DOWNLOAD HERE
*
* found in your twitter download @ /data/tweet.js
*/
const tweets = require('./tweets-old');
@gtracy
gtracy / google.js
Created December 22, 2019 15:41
Google Drive API
const config = require('../config');
const {google} = require('googleapis');
const Google = function() {
var self = this;
this.sheets = google.sheets({
version: 'v4',
auth: config.googleAPI.key
@gtracy
gtracy / easypost-scrape.js
Created April 9, 2017 16:38
EasyPost tracker history to CSV
const async = require('async');
const Easypost = require('node-easypost');
const csv = require('fast-csv');
const fs = require('fs');
const stream = require('stream');
var start_date = new Date('2017-03-01');
var easypost_key = 'fixme';
@gtracy
gtracy / ssh identity stash for private repos
Last active August 29, 2017 15:58
npm install : Provide access to private npm packages in Github
eval "$(ssh-agent -s)"
eval ssh-add ~/.ssh/id_rsa
Enter passphrase for /Users/developer/.ssh/id_rsa:
Identity added: /Users/developer/.ssh/id_rsa (/Users/developer/.ssh/id_rsa)
npm install
@gtracy
gtracy / localized time on App Engine
Created January 12, 2014 03:10
Using pytz, getting localized timestamps with Python on App Engine
def getLocalDatetime():
utc_dt = datetime.datetime.now()
central_tz = pytz.timezone('US/Central')
utc = pytz.utc
ltime = utc.localize(utc_dt).astimezone(central_tz)
return ltime
## end getLocalDatetime
@gtracy
gtracy / app-engine-redirector.py
Created November 5, 2012 01:24
A tiny redirector app that runs on App Engine
import os
import logging
from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
blog_slugs = {
'my-post' : '/12/09/',
'my-second-post' : '/12/12/'
}
@gtracy
gtracy / posterous-get-posts.js
Created November 4, 2012 21:15
Node app to fetch all public posts from a Posterous site
var request = require('request');
var site_id = 7963;
var grab_post_page = function(page) {
request.get({
url: 'http://posterous.com/api/2/sites/'+site_id+'/posts/public?page='+page,
headers: {
'Content-Type': 'application/json'
}
}, function(error, response, body) {
@gtracy
gtracy / gist:1209756
Created September 11, 2011 16:07
Signup handler function for a Twilio SMS interface
class CallHandler(webapp.RequestHandler):
def post(self):
# extract the message and phone
message = self.request.get('Body')
phone = self.request.get('From')
# the first word tells us everything...
first = message.lower().split()[0]