Skip to content

Instantly share code, notes, and snippets.

View jcipriano's full-sized avatar

Jonathan Cipriano jcipriano

View GitHub Profile
@jcipriano
jcipriano / upload-gif-dm.py
Last active August 9, 2017 20:36
Upload GIF for use with Direct Message
import os
import sys
import time
import json
import requests
from requests_oauthlib import OAuth1
MEDIA_ENDPOINT_URL = 'https://upload.twitter.com/1.1/media/upload.json'
@jcipriano
jcipriano / send-dm-options-and-buttons.js
Created July 18, 2017 22:39
Sends a Twitter DM with Quick Reply Options and Buttons.
var nconf = require('nconf')
var request = require('request')
// load config
nconf.file({ file: 'config.json' }).env()
// twitter authentication
var twitter_oauth = {
consumer_key: nconf.get('TWITTER_CONSUMER_KEY'),
@jcipriano
jcipriano / latency.sh
Created July 11, 2017 21:49
Shell script that uses curl to measure latency for a given URL.
#!/bin/bash
# parse command line options
while [[ $# -gt 1 ]]
do
key="$1"
case $key in
-u|--url)
target_url="$2"
/*
Implement a key-value store that presents the following minimal interface:
`put(k, v)`
`get(k, timestamp=None)`
When a timestamp is specified for the `get` operation, the `get` should return
the value that was associated with the key at that point in time. (Semantically,
this should be equivalent to getting in a time machine, going back to that point
in time, and then asking the key-value store for the current value.)
@jcipriano
jcipriano / challenge-response.php
Created June 29, 2017 16:08
PHP example for generating challenge response for Twitter webhooks
<?php
// Example app consumer secret found in apps.twitter.com
const APP_CONSUMER_SECRET = 'z3ZX4v7mAAUGykl3EcmkqbartmuW8VFOOzCloLx9Q45P0hLrFu';
// Example token provided by incoming GET request
$token = $_GET['crc_token'];
/**
* Creates a HMAC SHA-256 hash created from the app TOKEN and
* your app Consumer Secret.
* @param token the token provided by the incoming GET request
@jcipriano
jcipriano / media-upload.py
Last active September 13, 2023 11:09
Async Twitter media upload example script in python. Generates media ID for use with Tweets and DMs.
import os
import sys
import time
import json
import requests
from requests_oauthlib import OAuth1
MEDIA_ENDPOINT_URL = 'https://upload.twitter.com/1.1/media/upload.json'
@jcipriano
jcipriano / add-subscription.js
Last active May 9, 2019 00:36
Creates a Twitter webhook config
var request = require('request')
// twitter authentication
var twitter_oauth = {
consumer_key: 'TWITTER_CONSUMER_KEY',
consumer_secret: 'TWITTER_CONSUMER_SECRET',
token: 'TWITTER_ACCESS_TOKEN',
token_secret: 'TWITTER_ACCESS_TOKEN_SECRET'
}
@jcipriano
jcipriano / create-welcome-message.js
Last active June 23, 2021 11:54
Creates a Welcome Message and generates a deeplink with NodeJS
var request = require('request')
// twitter authentication
var twitter_oauth = {
consumer_key: 'TWITTER_CONSUMER_KEY',
consumer_secret: 'TWITTER_CONSUMER_SECRET',
token: 'TWITTER_ACCESS_TOKEN',
token_secret: 'TWITTER_ACCESS_TOKEN_SECRET'
}
@jcipriano
jcipriano / challenge-response.py
Created June 5, 2017 20:57
Python example for generating challenge response for Twitter webhooks
import base64
import hmac
import hashlib
import json
# Example app consumer secret found in apps.twitter.com
APP_CONSUMER_SECRET = 'z3ZX4v7mAAUGykl3EcmkqbartmuW8VFOOzCloLx9Q45P0hLrFu'
# Example token provided by incoming GET request
TOKEN = '9b4507b3-9040-4669-9ca3-6b94edb50553'
@jcipriano
jcipriano / challenge-response.js
Created May 24, 2017 17:20
Creates a valid CRC response for Twitter webhook integration.
crypto = require('crypto');
// Example app consumer secret found in apps.twitter.com
APP_CONSUMER_SECRET = 'z3ZX4v7mAAUGykl3EcmkqbartmuW8VFOOzCloLx9Q45P0hLrFu';
// Example token provided by incoming GET request
TOKEN = '9b4507b3-9040-4669-9ca3-6b94edb50553';
/**