Skip to content

Instantly share code, notes, and snippets.

View ErikDeBruijn's full-sized avatar

Erik de Bruijn ErikDeBruijn

View GitHub Profile
@ErikDeBruijn
ErikDeBruijn / bitgpt.py
Last active October 4, 2023 08:46
bitgpt.py - a bitbar tool that runs prompts on your copy & paste buffer
#!/usr/bin/env python3
# <xbar.title>BitGPT</xbar.title>
# <xbar.version>v0.1</xbar.version>
# <xbar.author>Erik de Bruijn</xbar.author>
# <xbar.author.github>ErikDeBruijn</xbar.author.github>
# <xbar.desc>Performs ChatGPT prompts on the clipboard and returns the result on the paste buffer.</xbar.desc>
# <xbar.image>http://www.hosted-somewhere/pluginimage</xbar.image>
# <xbar.dependencies>python</xbar.dependencies>
# <xbar.abouturl>https://erikdebruijn.nl/</xbar.abouturl>
# <xbar.var>string(OPENAI_API_KEY="your-open-ai-key"): Your openAI key. Find it here: https://platform.openai.com/account/api-keys</xbar.var>
@ErikDeBruijn
ErikDeBruijn / boost.js
Last active August 22, 2023 13:51
Boost: cmd-shift-m to convert current page to markdown link.
// You can use this as a boost!
// This code can be found at: https://gist.github.com/ErikDeBruijn/4d85042d0bd3be54b80e57593dccd20e
function showNotice(message) {
// Create a new div element for the notice
const noticeDiv = document.createElement('div');
noticeDiv.className = 'notice';
noticeDiv.innerHTML = message;
// Apply the CSS styles
@ErikDeBruijn
ErikDeBruijn / stream.rb
Last active February 26, 2021 09:34
Tesla stream.rb
module TeslaApi
module Stream
def self.streaming_endpoint_url
'wss://streaming.vn.teslamotors.com/streaming/'
end
def self.streaming_endpoint
Async::HTTP::Endpoint.parse(streaming_endpoint_url, alpn_protocols: Async::HTTP::Protocol::HTTP11.names)
end
@ErikDeBruijn
ErikDeBruijn / kWp.30s.rb
Created December 2, 2020 21:22
Bitbar plugin for live stats for solar power generation and EV charging in Culemborg
#!/usr/bin/env ruby
#BitBar Metadata
# <bitbar.title>Power generation and supply to chargers</bitbar.title>
# <bitbar.version>v0.1</bitbar.version>
# <bitbar.author>Erik de Bruijn</bitbar.author>
# <bitbar.author.github>Erik de Bruijn</bitbar.author.github>
# <bitbar.desc>Displays the power output of the solar array and supply to the charging stations.</bitbar.desc>
require 'net/http'
require 'uri'
#!/usr/bin/env ruby
#BitBar Metadata
# <bitbar.title>Frequency of the synchronous grid</bitbar.title>
# <bitbar.version>v0.1</bitbar.version>
# <bitbar.author>Erik de Bruijn</bitbar.author>
# <bitbar.author.github>Erik de Bruijn</bitbar.author.github>
# <bitbar.desc>Displays the current frequency of the grid and the time it is ahead or lagging.</bitbar.desc>
#
# This script in to be used with Bitbar as a toolbar plugin for OS X.
# It will display the grid freqency and time offset compared to the actual time (leading/lagging seconds)
# ZSH functions to quickly make and merge a PR on Github
# Use it from a repository, but set up gh first (`brew install gh && gh`)
# https://gist.github.com/ErikDeBruijn/a3767e448d82349cbf41561625289cf1/
qmerge () {
if [[ "$1" != "NESTED" ]]
then
echo -n Seeing if we can merge it...
fi
SLEEP_SECONDS=5
@ErikDeBruijn
ErikDeBruijn / rspec-mon.rb
Created June 14, 2020 10:25
Monitors changed files and will tell you as soon as a test doesn't pass anymore
#!/usr/bin/env ruby
# THIS IS A WORK IN PROGRESS TOOL
def get_changed_files
files = `git diff --name-only |grep .rb`.split("\n").map do |f|
f2 = f.split('/') ; f2.shift ; f2.join('/')
end
files_new = []
files.each do |f|
IRB.conf[:SAVE_HISTORY] = 2000
IRB.conf[:HISTORY_FILE] = '~/.irb-history'
def app_prompt
rails_klass = Rails.application.class
app_name =
if rails_klass.respond_to? :module_parent
rails_klass.module_parent
else
#!/usr/bin/env bash
set -eu
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NO_COLOR='\033[0m'
CLEAR_LINE='\r\033[K'
@ErikDeBruijn
ErikDeBruijn / install_aab.sh
Last active March 12, 2020 07:24
HOWTO Install an .aab file
echo "This utility will install an app based on an .aab to your Android device"
echo "Plug in your Android device and enable dev mode USB debugging."
ls /usr/local/Cellar/bundletool/*/bin/bundletool 1>/dev/null || brew install bundletool
bt=$(ls /usr/local/Cellar/bundletool/*/bin/bundletool |head -n1)
mkdir /tmp/apks
cd /tmp/apks
$bt build-apks --bundle $1 --output build.apks
echo "Waiting for your device to be connected and authorized..."
adb wait-for-usb-any && \