Skip to content

Instantly share code, notes, and snippets.

@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')
@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',
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"
import os
import random
x = random.sample(range(1, 100), 3)
x = list(map(str, x))
y = ', '.join(x)
cmd = """
osascript -e '
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"}}'
// 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
@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)
@danromero
danromero / feed.xml
Last active February 21, 2020 06:51
Linklog RSS feed for Jekyll
---
layout: none
---
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" >
<generator uri="https://jekyllrb.com/" version="3.8.5">Jekyll</generator>
<link href="{{ site.url }}/feed.xml" rel="self" type="application/atom+xml" />
<link href="{{ site.url }}" rel="alternate" type="text/html" />
<updated>2020-02-20T17:02:57-08:00</updated>
<id>{{ site.url }}/feed.xml</id>
@danromero
danromero / unlike.py
Created July 14, 2020 18:07
Twitter unlike script
import tweepy
ACCESS_TOKEN = '...'
ACCESS_SECRET = '...'
CONSUMER_KEY = '...'
CONSUMER_SECRET = '...'
def connect_to_twitter_OAuth():
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_TOKEN, ACCESS_SECRET)
[{"body":{"type":"text-short","publishedAt":1621010885463,"sequence":3,"username":"stallman","address":"0x68c6b1CEa2D655435f3Cf36E6b9F27Af9B31D518","data":{"text":"I did write some code in Java once, but that was the island in Indonesia."},"prevMerkleRoot":"0xe176d2cb262a5e379b7865ec60ba87f4b59710b1560fe32b29672bd12c77c2d7"},"merkleRoot":"0x23c0ad7f2fbae0db3c699b82007a2f3b19ffbe8e99daa5d3ea558c0d18806114","signature":"0x9c2db3dc1f09459147abbb5a686f812c80810d3c46d0078f43b2b7fe9512cdd31e9869f7a75257bf8c15c46b1d473cfec751ca28c8a8ecc2006d7ef11d63f6f61b"},{"body":{"type":"text-short","publishedAt":1621010874991,"sequence":2,"username":"stallman","address":"0x68c6b1CEa2D655435f3Cf36E6b9F27Af9B31D518","data":{"text":"No person, no idea, and no religion deserves to be illegal to insult, not even the Church of Emacs."},"prevMerkleRoot":"0x0e3d4cd0cf749c904ccd393d1d2a13661d428fb2095449760132429a2398e2e6"},"merkleRoot":"0xe176d2cb262a5e379b7865ec60ba87f4b59710b1560fe32b29672bd12c77c2d7","signature":"0xda1eee4d428b15475c