Skip to content

Instantly share code, notes, and snippets.

@Shelob9
Shelob9 / blue.css
Created December 7, 2023 22:42
Tailwind CSS with links styled like links
@tailwind base;
@tailwind components;
@tailwind utilities;
a {
@apply underline text-blue-800 hover:text-blue-400 visited:text-purple-800
}
@Shelob9
Shelob9 / filter-wp-request.php
Last active December 1, 2023 14:54
Using pre_http_request filter to mock HTTP request responses in WordPress phpunit test https://github.com/WordPress/wordpress-develop/blob/trunk/src/wp-includes/class-wp-http.php#L240-L262
<?php
class Test extends TestCase {
public function test_function_that_makes_api_request(){
add_filter('pre_http_request', function(){
return [
'body' => [
'id' => 1,
],
export async function sendSkeet({ text, agent, attatchments }: {
text: string,
agent: bsky.BskyAgent,
attatchments?: Attatchments,
}) {
const rt = new RichText({ text });
await rt.detectFacets(agent);
const post: any = {
$type: 'app.bsky.feed.post',
import bsky from '@atproto/api';
const { BskyAgent, RichText } = bsky;
import * as dotenv from 'dotenv';
import process from 'node:process';
dotenv.config();
const agent = new BskyAgent({
service: 'https://bsky.social',
});
import { BskyAgent, AtpSessionEvent, AtpSessionData } from '@atproto/api'
//https://github.com/bluesky-social/atproto/tree/main/packages/api
const bsAgent = async () => {
const agent = new BskyAgent({
service: 'https://bsky.app/',
persistSession: (evt: AtpSessionEvent, sess?: AtpSessionData) => {
// store the session-data for reuse
}
<?php
add_filter('get_default_comment_status', [
IM_M_Comments::class, 'get_default_comment_status'
], 100, 3 );
apply_filters( 'comments_open', [
IM_M_Comments::class, 'comments_open'
], 100, 2 );
class IM_M_Comments {
@Shelob9
Shelob9 / download-yt-transcribe.py
Created April 22, 2023 20:34
Download YouTube video's audio and transcribe with Whisper
import pytube as pt
import whisper
# download mp3 from youtube video (Two Minute Papers)
yt = pt.YouTube("https://www.youtube.com/watch?v=dd1kN_myNDs")
stream = yt.streams.filter(only_audio=True)[0]
stream.download(filename="audio_english.mp3")
# load large wisper model
model = whisper.load_model("large")
# transcribe
from openai import Model, Engine
from gpt_index.composability import ComposableGraph
from gpt_index.readers import GithubRepositoryReader
from gpt_index import download_loader,GPTTreeIndex,Document,MockLLMPredictor,GPTListIndex,PromptHelper,GPTSimpleVectorIndex, LLMPredictor, SimpleDirectoryReader
from dotenv import load_dotenv
from pathlib import Path
from prepare import unmark
load_dotenv()
import os
//https://raw.githubusercontent.com/imaginarymachines/ufo-ai-wp/75803f4a44158a51f9f77b740ae4065417492d0e/src/api/checkConnection.js
import React from 'react';
import apiFetch from '@wordpress/api-fetch';
const checkConnection = async () => {
const is = await apiFetch( {
path: '/ufo-ai/v1/connected',
method: 'GET',
} )
.then( ( res ) => {
if ( res ) {