Skip to content

Instantly share code, notes, and snippets.

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 / 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
<h1 style="font-family: Arial">Wait a sec...</h1>
<script>
setTimeout(function() {
window.close();
}, 3000);
</script>
console.log(`Hey there! 👋`);
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
set JSSnippet to "snippet"
tell application "Keyboard Maestro Engine"
set JSSnippet to getvariable "snippet"
end tell
tell application "Arc"
set JSResult to execute front window's active tab javascript JSSnippet
end tell
<div class="creative">
<!-- column-left -->
<div class="column-left">
<div class="copy">
<div class="moveable"><div class="text-first">{{ copy1 }}</div></div>
<div class="moveable">
<div class="text-second"><span class="line-wrapper">{{ copy2 }}</span></div>
</div>
</div>
</div>
codesign --remove-signature /Applications/Visual\ Studio\ Code.app/Contents/Frameworks/Code\ Helper\ \(Renderer\).app
function christmas(x) {
if(x < 3) {
return "";
}
let tree = "";
for(let i = 1; i <= x; i++) {
for(let j = 1; j <= x + x - 1; j++) {
if(j <= x - i || j >= x + i) {
tree += " ";
} else {
const videos = [...document.querySelectorAll('.label.style-scope.ytcp-thumbnail')];
const pattern = /[0-9]:../gi
const time = videos.map(item => item.textContent.match(pattern)[0]);
const pageTime = time.reduce((acc, curr) => acc += curr.split(':').reduce((acc,time) => (60 * acc) + +time), 0);
console.log(`Total time on page ${pageTime} seconds`);