Skip to content

Instantly share code, notes, and snippets.

View danielberkompas's full-sized avatar

Daniel Berkompas danielberkompas

View GitHub Profile
@alexrudall
alexrudall / #ChatGPT Streaming.md
Last active May 3, 2024 02:54
ChatGPT streaming with ruby-openai, Rails 7, Hotwire, Turbostream, Sidekiq and Tailwind!

How to add ChatGPT streaming to your Ruby on Rails 7 app!

This guide will walk you through adding a ChatGPT-like messaging stream to your Ruby on Rails 7 app using ruby-openai, Rails 7, Hotwire, Turbostream, Sidekiq and Tailwind. All code included below!

Alt Text

First, add the ruby-openai gem! Needs to be at least version 4. Add Sidekiq too.

@jswny
jswny / Flexible Dockerized Phoenix Deployments.md
Last active July 3, 2023 05:25
A guide to building and running zero-dependency Phoenix (Elixir) deployments with Docker. Works with Phoenix 1.2 and 1.3.

Prelude

I. Preface and Motivation

This guide was written because I don't particularly enjoy deploying Phoenix (or Elixir for that matter) applications. It's not easy. Primarily, I don't have a lot of money to spend on a nice, fancy VPS so compiling my Phoenix apps on my VPS often isn't an option. For that, we have Distillery releases. However, that requires me to either have a separate server for staging to use as a build server, or to keep a particular version of Erlang installed on my VPS, neither of which sound like great options to me and they all have the possibilities of version mismatches with ERTS. In addition to all this, theres a whole lot of configuration which needs to be done to setup a Phoenix app for deployment, and it's hard to remember.

For that reason, I wanted to use Docker so that all of my deployments would be automated and reproducable. In addition, Docker would allow me to have reproducable builds for my releases. I could build my releases on any machine that I wanted in a contai

@atomkirk
atomkirk / analyze_compile.ex
Created November 5, 2017 00:27
a mix task to help figure out why elixir is recompiling every file
defmodule Mix.Tasks.AnalyzeCompile do
use Mix.Task
@shortdoc "Looks for problems in compile graph"
@moduledoc """
This is where we would put any long form documentation or doctests.
"""
def run(_args) do
@jerel
jerel / elixir.exs
Last active October 5, 2015 18:30
This is a rough list of things that might initially be confusing to a non-rubyist trying to learn Elixir
# implicit return is fairly obvious but foreign to most languages
def foo(arg) do
arg
end
# foo/2 is the notation for a function that takes two arguments
# optional parenthesis
def foo arg, arg2 do
#usage: use YourApp.CatchallController in web.ex right after use Phoenix.Controller
defmodule YourApp.CatchAllController do
defmacro __using__(_opts) do
quote do
@before_compile unquote(__MODULE__)
end
end
defmacro __before_compile__(env) do
actions = Module.definitions_in(env.module, :def)
@omnibs
omnibs / phoenix showdown rackspace onmetal io.md
Last active January 25, 2023 18:33
Phoenix Showdown Comparative Benchmarks @ Rackspace

Comparative Benchmark Numbers @ Rackspace

I've taken the benchmarks from Matthew Rothenberg's phoenix-showdown, updated Phoenix to 0.13.1 and ran the tests on the most powerful machines available at Rackspace.

Results

Framework Throughput (req/s) Latency (ms) Consistency (σ ms)
@cloudbring
cloudbring / README.md
Last active May 1, 2017 02:42
Building an Phoenix / Elixir Web App in June 2015
@chrismccord
chrismccord / gist:4a62780056b08c60542d
Last active August 29, 2015 14:21
Phoenix Upgrade Instructions 0.13.0 to 0.13.1
@paulirish
paulirish / bling.js
Last active May 1, 2024 19:56
bling dot js
/* bling.js */
window.$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
}
NodeList.prototype.__proto__ = Array.prototype;
@imjasonh
imjasonh / markdown.css
Last active February 12, 2024 17:18
Render Markdown as unrendered Markdown (see http://jsbin.com/huwosomawo)
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}