Skip to content

Instantly share code, notes, and snippets.

set DMURLTitle to ""
set DMURL to ""
tell application "Arc"
set currentURL to URL of active tab of window 1
set currentTitle to title of active tab of window 1
tell application "Keyboard Maestro Engine"
setvariable "DMURL" to currentURL
setvariable "DMURLTitle" to currentTitle
end tell
console.log(`Hey there! 👋`);
<h1 style="font-family: Arial">Wait a sec...</h1>
<script>
setTimeout(function() {
window.close();
}, 3000);
</script>
@iceener
iceener / execute.js
Last active January 23, 2023 16:27
Execute JavaScript snippet (Netlify Function)
import { execSync } from 'child_process';
export const handler = async (event) => {
if (event.httpMethod === 'POST') {
const payload = JSON.parse(event.body);
if (payload.secret !== 'SECRET_KEY') {
return;
}
const result = await execSync(
`node -e "console.log((() => {${payload.script
const API_URL = "https://api.openai.com/v1/chat/completions";
const MAX_TOKENS = 1500;
const TEMPERATURE = 0.5;
const SYSTEM_PROMPT = 'Act as assistant';
const MESSAGES = ["hello", "hi!", "how are you?"];
async function openAICompletion(msg) {
const options = {
method: "POST",
headers: {
@iceener
iceener / encoder.js
Last active July 9, 2023 18:50
gpt-3-encoder-netlify-function.js
const { encode } = require('@nem035/gpt-3-encoder')
exports.handler = async (event, context) => {
if (event.httpMethod === 'POST') {
try {
const payload = JSON.parse(event.body);
const text = payload.text;
return {
@iceener
iceener / remote.js
Created April 22, 2023 18:48
Keyboard Maestro Remote Action
/opt/homebrew/bin/node -e "(async () => {const response = await fetch('$KMVAR_webhook', {method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify($KMVAR_json)});const json = await response.json();console.log(JSON.stringify(json));})()"
@iceener
iceener / gpt3.sh
Created April 28, 2023 08:54
CURL GPT-3
curl -s <https://api.openai.com/v1/completions> \\
-H "Content-Type: application/json" \\
-H "Authorization: Bearer $OPENAI_API_KEY" \\
-d '{
"model": "text-davinci-003",
"prompt": "Hello",
"temperature": 0.7,
"max_tokens": 256,
"top_p": 1,
"frequency_penalty": 0,
tell application "System Events"
set frontmostApplication to name of first application process whose frontmost is true
set browserName to ""
if frontmostApplication is "Arc" then
tell application "Arc" to return title of active tab of window 1
else if frontmostApplication is "Google Chrome" then
tell application "Google Chrome" to return title of active tab of window 1
else if frontmostApplication is "Brave Browser" then
tell application "Brave Browser" to return title of active tab of window 1
tell application "System Events"
set frontmostApplication to name of first application process whose frontmost is true
set browserName to ""
if frontmostApplication is "Arc" then
tell application "Arc" to return URL of active tab of window 1
else if frontmostApplication is "Google Chrome" then
tell application "Google Chrome" to return URL of active tab of window 1
else if frontmostApplication is "Brave Browser" then
tell application "Brave Browser" to return URL of active tab of window 1