Skip to content

Instantly share code, notes, and snippets.

View peckjon's full-sized avatar

Jon Peck peckjon

View GitHub Profile
@peckjon
peckjon / translate.py
Created July 31, 2018 23:51
pre-translation in NLP
import Algorithmia
client = Algorithmia.client("your_api_key")
algo_input = {
"action": "translate",
"text": "Me gustan los aguacates"
}
translated_text = client.algo("translation/GoogleTranslate/0.1.1").pipe(algo_input).result["translation"]
@peckjon
peckjon / getdataset.py
Created August 1, 2018 18:38
Train a Machine to Turn Documents into Keywords, via Document Classification
import Algorithmia
remote_url = 'data://.my/collection/training_data.json'
local_dataset = '/path/to/my/training_dataset.json'
client = Algorithmia.client('YOUR_API_KEY_HERE')
client.file(remote_url).putFile(local_dataset)
@peckjon
peckjon / setup.py
Created August 9, 2018 05:58
Quickly Building a Face Recognizer
import Algorithmia
api_key = "YOUR_API_KEY"
client = Algorithmia.client(api_key)
@peckjon
peckjon / content-aware-resize.htm
Created August 9, 2018 06:02
Smart Autogeneration of Thumbnails Banners, and Socials with Content Aware Resize
<html>
<head>
<script src="https://algorithmia.com/v1/clients/js/algorithmia-0.2.0.js" type="text/javascript"></script>
<script src="content-aware-resize.js" type="text/javascript"></script>
</head>
<body>
<h3>Image:</h3>
<input type="text" size="80" id="img_url" value="https://upload.wikimedia.org/wikipedia/commons/f/f7/Hickory_Golfer.jpg" />
<h3>Automatically resize:</h3>
<input type="submit" value="Thumbnail 150x150" onclick="resize(150,150,'thumb')" /> <a download="thumb.png" id="thumb"></a><br/>
@peckjon
peckjon / input.json
Created August 9, 2018 06:09
Video Metadata Extraction
input = {
"input_file":"data://media/videos/lounge_demo.mp4",
"output_file":"data://.algo/temp/detected_objects.json",
"algorithm":"algo://LgoBE/CarMakeandModelRecognition/0.3.4",
"advanced_input":{"$SINGLE_INPUT"}
}
result = client.algo('media/VideoMetadataExtraction?timeout=3000').pipe(input).result
@peckjon
peckjon / input.json
Created August 9, 2018 06:16
Introduction to Twitter Topic and Sentiment Analysis
import Algorithmia
input = {
"query": "seattle seahawks",
"numTweets": "1000",
"auth": {
"app_key": "YOUR_TWITTER_APP_KEY",
"app_secret": "YOUR_TWITTER_APP_SECRET",
"oauth_token": "YOUR_TWITTER_OAUTH_TOKEN",
"oauth_token_secret": "YOUR_TWITTER_OAUTH_TOKEN_SECRET"
@peckjon
peckjon / input.py
Created August 9, 2018 06:21
Extract Structured Data From Web Sites Using Analyze URL
import Algorithmia
input = "//blog.algorithmia.com/predictive-algorithms-track-real-time-health-trends/"
client = Algorithmia.client('YOUR API KEY')
algo = client.algo('web/AnalyzeURL/0.2.14')
print algo.pipe(input)
@peckjon
peckjon / ClearDroplist.js
Last active January 26, 2024 20:41
Clear Honey Droplist
// paste into browser console at https://www.joinhoney.com/droplist to remove ALL Droplisted items
var script = document.createElement('script');
script.src = "https://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(script);
setTimeout(() => {
$('img[alt="Remove this item from your Droplist"]').each(function(){this.click()});
$('button[aria-label="Remove item"]').each(function(){this.click()});
$('div[id="HoneyDropList:index-moreButton"]').click();
}, 2000);
@peckjon
peckjon / splittranscript.py
Created May 11, 2023 00:19
Python script to split an input file into multiple files no longer than 3900 words each, breaking only on lines that start with the pattern "00;"
import os
import sys
# Set the maximum number of words per file
max_words = 3900
# Set the pattern to split on
pattern = "00;"
# Get the input file name from the command line arguments
@peckjon
peckjon / qfc_coupon_clipper.js
Last active February 18, 2024 08:45
Clip all QFC coupons
// ==UserScript==
// @name Clip all QFC coupons
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Click every "clip" coupon button on the QFC coupons page www.qfc.com/savings/cl/coupons/
// @author peckjon
// @authorurl https://greasyfork.org/en/users/824205-peckjon
// @include http*://*qfc.com/savings/cl/coupons*
// @icon https://www.google.com/s2/favicons?domain=qfc.com
// @grant none