Skip to content

Instantly share code, notes, and snippets.

View Brodan's full-sized avatar

Chris Hranj Brodan

View GitHub Profile
@Brodan
Brodan / calculate-provenance-hash.ts
Created March 2, 2022 16:25
calculate the provenance hash of a directory full of files (e.g. images). requires hardhat
// run the script with `npx hardhat run <script>`
import path from 'path'
import fs from 'fs'
import { createHash } from 'crypto'
const CSV_FILENAME = "provenance_record.csv"
async function main() {
// CHANGE THE PATH HERE TO YOUR IMAGE COLLECTION PATH
const imageDirectory = path.join(__dirname, '/../../images/output/image')
const got = require('got');
exports.handler = function(context, event, callback) {
let message = "";
let twiml = new Twilio.twiml.MessagingResponse();
const prompt = event.Body !== undefined ? event.Body.trim() : event["prompt"]
got.post('https://api.openai.com/v1/engines/davinci/completions', {
json: {
"prompt": prompt,
@Brodan
Brodan / travis_twilio_function.js
Last active September 18, 2017 01:09
A Twilio Function snippet for handling Travis CI webhook notifications.
exports.handler = function(context, event, callback) {
let travis_payload = JSON.parse(event.payload);
let message_body = `${travis_payload.repository.name} \
failed to build after changes pushed by \
${travis_payload.committer_name}`;
let client = context.getTwilioClient();
client.messages.create({
to: '+15555555555', // Text this number
from: '+15555555555', // From a valid Twilio number
@Brodan
Brodan / twilio.pde
Created September 21, 2015 19:48
A Processing sketch that demonstrates sending an SMS message using Twilio
import http.requests.*;
String ACCOUNT_SID = "XXXXXXXXXXXXXXXXXXXXXXX";
String AUTH_TOKEN = "YYYYYYYYYYYYYYYYYYYYYYY";
PostRequest post = new PostRequest("https://api.twilio.com/2010-04-01/Accounts/"
+ ACCOUNT_SID + "/Messages");
void setup() {
post.addData("From", "+15555555555");
post.addData("To", "+15555555555");
@Brodan
Brodan / twilioBailout.py
Last active November 11, 2016 22:59
Python script to hangup all in-progress Twilio calls.
from twilio.rest import TwilioRestClient
from twilio.rest.resources import Call
ACCOUNT_SID = "YOUR_ACCOUNT_SID"
AUTH_TOKEN = "YOUR_AUTH_TOKEN"
client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN)
calls = client.calls.list(status=Call.IN_PROGRESS) # May need to use Call.QUEUED or Call.RINGING
for c in calls:
c.hangup()