Skip to content

Instantly share code, notes, and snippets.

View danielfriis's full-sized avatar

Daniel Friis danielfriis

View GitHub Profile
@schappim
schappim / _webrtc.html.erb
Created December 18, 2024 02:31
OpenAI’s Real-time API (with WebRTC) using StimulusJS and Rails
<%# A partial that can be placed anywhere to utilise the Real-time API (with WebRTC) %>
<div data-controller="webrtc" class="bg-gray-600 rounded-full text-white mb-4 ">
<audio data-webrtc-target="audio"></audio>
<button data-webrtc-target="toggle" data-action="click->webrtc#toggleAudio" class="relative flex items-center justify-center w-full font-medium min-w-[150px] min-h-[40px]">
<div class="w-full text-center" data-button-text>Enable Audio Chat</div>
<div data-webrtc-target="spinner" class="hidden absolute">
<svg class="animate-spin h-5 w-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
@jeremedia
jeremedia / ruby-structured-outputs-v4.rb
Last active April 10, 2025 18:53
Ruby implementation of OpenAI structured outputs
require 'json'
require 'dry-schema'
require 'openai'
require 'ostruct'
module StructuredOutputs
# Schema class for defining JSON schemas
class Schema
MAX_OBJECT_PROPERTIES = 100
MAX_NESTING_DEPTH = 5
@JamieMason
JamieMason / unfollow.js.md
Last active April 16, 2025 19:28
Unfollow everyone on twitter.com

Unfollow everyone on twitter.com

By @foldleft.bsky.social, see also Unfollow everyone on bsky.app.

  1. Go to https://twitter.com/YOUR_USER_NAME/following
  2. Open the Developer Console. (COMMAND+ALT+I on Mac)
  3. Paste this into the Developer Console and run it
// Unfollow everyone on twitter.com, by Jamie Mason (https://twitter.com/fold_left)
@matthutchinson
matthutchinson / fakeout.rb
Created May 10, 2012 16:59
fake.rake - a takeout approach and rake task that generates some random fake data for a rails app (using ffaker)
# place this in lib/fakeout.rb
require 'ffaker'
module Fakeout
class Builder
FAKEABLE = %w(User Product)
attr_accessor :report
en:
errors:
messages:
wrong_content_type: "is the wrong content type"