# Example of using SQLite VSS with OpenAI's text embedding API | |
# from Ruby. | |
# Note: Install/bundle the sqlite3, sqlite_vss, and ruby-openai gems first | |
# OPENAI_API_KEY must also be set in the environment | |
# Other embeddings can be used, but this is the easiest for a quick demo | |
# More on the topic at | |
# https://observablehq.com/@asg017/introducing-sqlite-vss | |
# https://observablehq.com/@asg017/making-sqlite-extension-gem-installable |
import { Controller } from '@hotwired/stimulus' | |
export default class extends Controller { | |
connect () { | |
this.element.addEventListener('change', this.handleChange.bind(this)) | |
} | |
handleChange (event) { | |
this.traverseDown(event.target, event.target.checked) |
This is all you really need to know in order to make Action Mailbox work in development.
- Fire up
ngrok http 3000
and make note of your subdomain for steps 3 and 8. - Create a Mailgun account because they offer sandbox addresses; grab your domain from the Dashboard.
- Go into Receiving and create a catch-all route pointing to:
https://XXX.ngrok.io/rails/action_mailbox/mailgun/inbound_emails/mime
- Add your Mailgun API key to your credentials:
action_mailbox:
mailgun_api_key: API KEY HERE
Turbolinks.scroll = {}; | |
document.addEventListener("turbolinks:load", ()=> { | |
const elements = document.querySelectorAll("[data-turbolinks-scroll]"); | |
elements.forEach(function(element){ | |
element.addEventListener("click", ()=> { | |
Turbolinks.scroll['top'] = document.scrollingElement.scrollTop; |
FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.
- By Edmond Lau
- Highly Recommended 👍
- http://www.theeffectiveengineer.com/
Get include-media here.
If you're using include-media to manage your breakpoints, you might want to have it generate media queries in em
units but still declare the breakpoints in px
for convenience.
We decided not to add this to the library core, as it's outside the scope of the project, but you can achieve that with a tiny function:
If you have any sort of administrative interface on your web site, you can easily imagine an intruder gaining access and mucking about. How do you know the extent of the damage? Adding an audit log to your app is one quick solution. An audit log should record a few things:
- controller entry points with parameter values
- permanent information about the user, like user_id
- transient information about the user, like IP and user_agent
Using the Rails framework, this is as simple as adding a before_action
to your admin controllers. Here’s a basic version that I’m using in production.
/* bling.js */ | |
window.$ = document.querySelector.bind(document); | |
window.$$ = document.querySelectorAll.bind(document); | |
Node.prototype.on = window.on = function(name, fn) { this.addEventListener(name, fn); }; | |
NodeList.prototype.__proto__ = Array.prototype; | |
NodeList.prototype.on = function(name, fn) { this.forEach((elem) => elem.on(name, fn)); }; |
This post described how to create an application with mithril 0.2.x. Now that ver 1.0 is out, some things are a little differnent.
The example is updated with the current version of mithril, though.