Skip to content

Instantly share code, notes, and snippets.

View tonycoco's full-sized avatar

Tony Coconate tonycoco

View GitHub Profile
@tonycoco
tonycoco / Code.js
Last active November 3, 2022 17:59
=GPT3() for Google Sheets (Google Apps Script)
// Useage: =GPT3(prompt)
// Example: =GPT3("This bot will generate a creative ad headline that is will increase views, clicks, and impressions, based on a website category.\n\nWebsite Category: tech\nHeadline: Why Google will win the AI wars\n\nWebsite Category: retail\nHeadline: Need a break? Check out our new fall selections now!\n\nWebsite Category: pharma\nHeadline: Are you ready for the next pandemic? Be prepared with your own pandemic survival kit today\n\nWebsite Category: travel\nHeadline: We noticed that cruise lines are super cheap now, find out why!\n\nWebsite Category: holiday\nHeadline: Partying for the holidays? Find a new coat to go out in!\n\nWebsite Category: sports\nHeadline:")
class OpenAIApp {
static get API_KEY_PROP() {
return "OPENAI_API_KEY";
}
constructor(apiKey) {
this.apiKey = apiKey;
@tonycoco
tonycoco / auth.py
Last active March 8, 2022 16:27
Google Display & Video 360 Simple Auth
import google.auth
import googleapiclient.discovery
API_NAME = "displayvideo"
API_SCOPES = ["https://www.googleapis.com/auth/display-video"]
API_VERSION = "v1"
credentials, project = google.auth.default(scopes=API_SCOPES)
print(f"Google Cloud Project ID: {project}.")
@tonycoco
tonycoco / bookmarket.js
Last active April 22, 2021 16:58
Safari Bookmarklet for <video> AirPlay options – Copy the `bookmarket.js` snippet and paste it as the address of a bookmark in Safari. Then, while playing any <video> you can click the bookmarklet and the <video> will bring up your AirPlay options.
javascript:if(window.WebKitPlaybackTargetAvailabilityEvent){var videos=document.getElementsByTagName("video");if(videos.length>0)for(var airplayable=videos[0],i=0;i<videos.length;i++)if(!(airplayable=videos[i]).paused){airplayable.webkitShowPlaybackTargetPicker();break}}
@tonycoco
tonycoco / docker-compose.yml
Last active August 22, 2023 18:42
Setting up Synology with Sabnzbd/Sonarr/Radarr/Nzbget/Watchtower using Docker Compose
version: "3.9"
services:
sabnzbd:
image: linuxserver/sabnzbd
container_name: sabnzbd
environment:
- PUID=1026
- PGID=100
- TZ=America/Chicago
volumes:
@tonycoco
tonycoco / bookmarket.js
Last active April 22, 2021 16:59
Safari Bookmarklet for <video> Picture-In-Picture options – Copy the `bookmarket.js` snippet and paste it as the address of a bookmark in Safari. Then, while playing any <video> you can click the bookmarklet and the <video> will toggle between Picture-In-Picture and Inline.
javascript:var videos=document.getElementsByTagName("video");if(videos.length>0)for(var pipable=videos[0],i=0;i<videos.length;i++)if(!(pipable=videos[i]).paused&&pipable.webkitSupportsPresentationMode&&"function"==typeof pipable.webkitSetPresentationMode){pipable.webkitSetPresentationMode("picture-in-picture"===pipable.webkitPresentationMode?"inline":"picture-in-picture");break}
@tonycoco
tonycoco / ember-cli-update.sh
Created January 15, 2015 16:30
Ember CLI Project Update Bash Function
function ember-cli-update {
if [ -z "$1" ]; then
echo "$(tput setaf 1)No Ember CLI version has been specified. Example: ember-cli-update 0.1.7$(tput sgr 0)"
return 1
fi
echo "$(tput setaf 2)Uninstalling global Ember CLI...$(tput sgr 0)"
npm uninstall -g ember-cli
echo "$(tput setaf 2)Cleaning NPM and Bower cache...$(tput sgr 0)"
@tonycoco
tonycoco / uploader_input.rb
Last active August 29, 2015 14:08
Carrierwave Uploader (with Cloudinary support) Input for ActiveAdmin's Formtastic Inputs
class UploaderInput < Formtastic::Inputs::FileInput
MAX_WIDTH_PIXELS = 300
MAX_HEIGHT_PIXELS = 200
def to_html
input_wrapping do
html_array = []
html_array << label_html
html_array << cache_html if method_changed?
html_array << file_html
@tonycoco
tonycoco / active_admin.js
Last active July 15, 2017 18:34
Array of Hashes input for ActiveAdmin and Formtastic
$('.array-of-hashes-tables').on('click', '.array-of-hashes-table .remove', function(event) {
event.preventDefault();
$(this).closest('.array-of-hashes-table').remove();
});
$('.array_of_hashes .add').on('click', function(event) {
event.preventDefault();
var $this = $(this);
var $tables = $this.siblings('.array-of-hashes-tables');
var $cloneable = $tables.find('.cloneable').first();
@tonycoco
tonycoco / select2.rb
Created February 19, 2014 17:28
Select2 Capybara Support File
# Useage: select2("value to select", from: "label text")
module Capybara
module Select2
def select2(value, options={})
select_name = options[:from]
select2_container = first("label", text: select_name).find(:xpath, "..").find(".select2-container")
select2_container.find(".select2-choice").click
find(:xpath, "//body").find(".select2-drop li", text: value).click
end
@tonycoco
tonycoco / heroku-pg-backup.sh
Last active August 29, 2015 13:56
Heroku PG Backup
curl -o latest.dump `heroku pgbackups:url`
rake db:drop db:create db:migrate
pg_restore --verbose --clean --no-acl --no-owner -h localhost -U root -d DATABASE_development latest.dump
rm latest.dump