Skip to content

Instantly share code, notes, and snippets.

@danromero
danromero / delighted_nps_distribution.py
Created February 20, 2017 22:18
Show the distribution of the last 100 Delighted.com NPS responses
%matplotlib inline
import delighted
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
# Add your Delighted API key — https://delighted.com/account/api
delighted.api_key = 'INSERT API KEY HERE'
x = delighted.SurveyResponse.all(order='desc:updated_at', per_page=100)
// Unique Slack WebHook to post payload (obtained from Slack API website)
// Replace 'XXX' with the unique WebHook URL generated for your application
var webhookUrl = 'https://hooks.slack.com/services/XXX';
// Function that sends payload message to Slack upon form submit
function onSubmit(e) {
// Get most recent form submission as array of fields
import json
import pygal
from requests_oauthlib import OAuth1Session
desk = OAuth1Session('client',
client_secret='XXX',
resource_owner_key='XXX',
resource_owner_secret='XXX')
url = 'https://yourdomain.desk.com/api/v2/insights3/reports'
data = '{"fields": ["case_creates", "case_resolves"], "time": {"min": "2015-01-01T00:00:00-08:00", "max": "2017-01-15T00:00:00-08:00", "window_size": "month"}}'
import os
import random
x = random.sample(range(1, 100), 3)
x = list(map(str, x))
y = ', '.join(x)
cmd = """
osascript -e '
tell application "Keynote"
activate
set thisDocument to make new document with properties ¬
{height:764, width:1024, document theme:theme "White"}
tell thisDocument
tell slide 1
set the base slide to master slide "Title - Top" of thisDocument
set the object text of the default title item to "Revenue"
@danromero
danromero / slide_generator.py
Created January 20, 2017 05:58
Generate slides from template presentation
from __future__ import print_function
from apiclient import discovery
from httplib2 import Http
from oauth2client import file, client, tools
IMG_FILE = 'google-slides.png' # use your own!
TMPLFILE = 'title slide template' # use your own!
SCOPES = (
'https://www.googleapis.com/auth/drive',
@danromero
danromero / revenue_projection.py
Last active January 13, 2017 19:57
Python script to estimate monthly revenue based on daily totals so far in a given month
import pandas as pd
import numpy as np
import time
from datetime import datetime
from calendar import monthrange
import locale
import os
locale.setlocale(locale.LC_ALL, 'en_US')
Verifying myself: My Bitcoin username is +dwr. https://onename.io/dwr

Keybase proof

I hereby claim:

  • I am danromero on github.
  • I am dwr (https://keybase.io/dwr) on keybase.
  • I have a public key whose fingerprint is 0E34 D0B8 3363 7A71 05BB C930 90C0 5556 AEF8 5DE7

To claim this, I am signing this object:

@danromero
danromero / address_parsing
Created February 13, 2014 00:22
Parse string of US address format into component parts
Input:
A1 | 301 Brannan St, San Francisco, CA 94107
Formulas:
B1 | =left(A1,find(",",A1)-1)
C1 | =MID(A1,find(",",A1)+1,find(",",A1)-1)
D1 | =left(right(A1,8),2)
E1 | =right(right(A1,8),5)
Ouput: