Skip to content

Instantly share code, notes, and snippets.

View andrewmcodes's full-sized avatar
🌱

Andrew Mason andrewmcodes

🌱
View GitHub Profile
@navjeetc
navjeetc / run_assistant.rb
Last active December 16, 2023 12:00
OpenAI assistants API usage
require 'openai'
client = OpenAI::Client.new(access_token: ENV['openai_key'])
assistants = OpenAI::Assistants.new(client: client)
# assistant = assistants.create(
# parameters: {
# name: 'Math tutor',
# model: 'gpt-4',
# instructions: 'You are a personal math tutor. Write and run code to answer math questions.'
#!/Users/aaron/.rubies/arm64/ruby-trunk/bin/ruby
# This is a demo language server for Ruby, written in Ruby. It just checks
# the syntax of Ruby programs when you save them.
#
# Configure this in Vim by adding the vim-lsp plugin, then doing this
# in your vimrc:
#
# au User lsp_setup
# \ lsp#register_server({
@Quorafind
Quorafind / AskChatGPT-With-Surfing.js
Created February 19, 2023 11:20
Using Quickadd to ask current selection In ChatGPT
// Version 0.0.1
module.exports = askChatWithPrompt;
function askChat(str, app) {
const prompt = encodeURI(str);
const chatViewEl = app.workspace.getLeavesOfType("surfing-view").find((item)=>{ return /chat\.openai\.com/.test(item?.view?.currentUrl)}).view.webviewEl;
chatViewEl.executeJavaScript(`
var htmlElement = document.querySelector("textarea");
htmlElement.value = decodeURI("${ prompt }");
@jgeusebroek
jgeusebroek / readwise_obsidian_export.md
Created December 29, 2022 20:40
Readwise Obsidian export templates

File name

{{last_highlighted_date |date('Y-m-d')}} {{title|replace(""","")|replace(""","")|replace("'","")|replace("'","")|truncate(159)}} by {{author|replace("@","")|truncate(80)}}

Add date and sanitize filename.

Page Metadata

{% if image_url -%}
![rw-book-cover]({{image_url}})
@ransurf
ransurf / Zettelizer.js
Created November 29, 2022 08:42
Eleanor's Zettelizer script but modified for my workflow
module.exports = async (params) => {
console.log("Starting...")
console.log(params);
const currentFile = params.app.workspace.getActiveFile();
if (!currentFile) {
new Notice("No active file.");
return;
}
console.log("Found active file: ", currentFile.basename);
@AnubisNekhet
AnubisNekhet / !Description.md
Last active May 15, 2023 04:19
Capacities-like sidebars

Preview

image

Caveats

Since the snippet utilises callouts, the sidebar disappears after a note is scrolled enough for the callout to be outside rendering range, i.e. it's best used for smaller notes. Smaller sidebar sizes are better in this case because there's more scroll area.

Usage

Use the capacities-sidebars.css as a snippet and paste the markdown into a new note.

# you must also upload the public key as signing key to https://github.com/settings/keys
git config --global user.signingkey '~/.ssh/id_rsa'
git config --global commit.gpgsign true
git config --global gpg.format ssh
# (optional) this file enables `git log --show-signature` and contains email addresses associated with public keys
git config --global gpg.ssh.allowedsignersfile '~/.ssh/git-signers'
@dannberg
dannberg / obsidian-people-template.txt
Last active April 24, 2024 05:27
Dann Berg's People Template for Obsidian. Uses Dataview & Templater plugins. Should be saved as a Markdown file in Obsidian. See full tutorial for setup instructions: https://dannb.org/blog/2022/obsidian-people-note-template/
---
company:
location:
title:
email:
website:
aliases:
---
tags:: [[👥 People MOC]]
function c {
git add --all
git commit -m $1
}
function p {
git add --all
git commit -m $1
@julianrubisch
julianrubisch / script.rb
Last active February 18, 2022 12:03
ActiveStorage DirectUpload via Faraday
require "faraday"
require "faraday/multipart"
token = ARGV.shift
absolute_path = File.expand_path(ARGV.shift)
# TODO how could we require "active_storage/blob" without eager loading the whole app
blob = ActiveStorage::Blob.build_after_unfurling(io: File.open(absolute_path), filename: File.basename(absolute_path))