Skip to content

Instantly share code, notes, and snippets.

View martinvd's full-sized avatar

Martin van Driel martinvd

View GitHub Profile
@marckohlbrugge
marckohlbrugge / assistant.rb
Created January 12, 2025 22:56
Overview of my LLM-powered prototype. Very rough code.
# Add these gems to your Gemfile
gem "rails" # not strictly needed, but I use ActiveConcern, etc
gem "raix" # helpful gem to reduce code needed for function calling etc
gem "thor" # to make a CLI app (not needed if you make a web app)
gem "http" # my preferred gem to make API calls
# This is the main app (`app/models/ai_chat/cli.rb`)
module AIChat
class Cli
# Thor
@marckohlbrugge
marckohlbrugge / WIP_Streak.scriptable
Created June 1, 2024 13:38
Scriptable widget showing your streak. Make sure to set your own API key ( https://wip.co/my/api_keys )
{
"always_run_in_app" : false,
"icon" : {
"color" : "yellow",
"glyph" : "fire"
},
"name" : "WIP Streak",
"script" : "\/\/ Replace with your API key\nconst API_KEY = \"wip_sk_REPLACE_ME\";\nconst API_URL = `https:\/\/api.wip.co\/v1\/users\/me.json?api_key=${API_KEY}`;\n\n\/\/ Function to fetch data from the API\nasync function fetchStreakData() {\n let request = new Request(API_URL);\n let response = await request.loadJSON();\n return response;\n}\n\n\/\/ Function to calculate hours left until midnight in a given time zone\nfunction hoursLeftUntilMidnight(timeZone) {\n let now = new Date();\n let nowInUserTimeZone = new Date(now.toLocaleString(\"en-US\", { timeZone: timeZone }));\n let midnight = new Date(nowInUserTimeZone);\n midnight.setHours(24, 0, 0, 0); \/\/ Set to midnight\n\n let hoursLeft = (midnight - nowInUserTimeZone) \/ (1000 * 60 * 60); \/\/ Convert milliseconds to hours\n return hoursLeft.toFixed(0);\n}\n\n\/\/ Function to create a widget displaying the streak info\nasy
@bdsqqq
bdsqqq / vesper-dark.json
Last active December 1, 2024 20:38
Vesper theme for zed.dev
{
"$schema": "https://zed.dev/schema/themes/v0.1.0.json",
"name": "Vesper",
"author": "Rauno Freiberg",
"themes": [
{
"name": "Vesper",
"appearance": "dark",
"style": {
"border": "#101010",
@levelsio
levelsio / upgradeSubPrice.php
Created October 8, 2023 17:28
This script upgrades the price on active subscriptions on Stripe
<?
// set price
$newPricePlanId='price_1NsRt5Inbsdfsfddsf';
$newPriceMonthly=39;
$i=1;
foreach($users as $user) {
if(!$user['stripe_customer_id']) {
echo "No Stripe customer id, maybe update in db?";
#!/usr/bin/env bash
set -Eeuo pipefail
hosts_file="/etc/hosts"
hosts=(
"www.reddit.com"
"twitter.com"
"www.nrc.nl"
"www.theguardian.com"
@erikyuzwa
erikyuzwa / wordpress-6-2-2-docker-compose.yml
Last active February 23, 2025 18:03
Wordpress 6.2.2 Docker Compose for Local Development
# create a local .env file with the following 4 properties:
#
# MYSQL_DATABASE=<something>
# MYSQL_USER=<something>
# MYSQL_PASSWORD=<something>
# MYSQL_ROOT_PASSWORD=<something>
#
# Note: I have had a LOT of issues working with anything newer then Docker Desktop v4.26.1
# If you're on something newer, then double check against this release.
#
<?
//
// AUTO KEYWORD-BASED FOLLOWER CURATION BOT (by @levelsio)
//
// File: twitterFollowerCuratorBot.php
//
// Created: May 2021
// License: MIT
//
@sindresorhus
sindresorhus / esm-package.md
Last active April 11, 2025 10:16
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
/**
* A bookmarklet for viewing the largest contentful paint in a page.
* Will show each LCP after the bookmarklet is clicked.
*
* To install:
* 1. Copy the code starting from the line beginning `javascript:`
* 2. Add a new bookmark in Chrome, and paste the code in as the URL.
**/
javascript:(function(){
try {
@poliquin
poliquin / mariadb-docker-digitalocean.md
Last active June 15, 2024 17:59
Using MariaDB via Docker on Digital Ocean

Notes on MariaDB and Docker

These notes describe how to start a MariaDB container with Docker on a Digital Ocean droplet running Ubuntu.

Installing Docker

Follow the instructions for [Docker CE on Ubuntu][0]: