Skip to content

Instantly share code, notes, and snippets.

View kanejamison's full-sized avatar

Kane Jamison kanejamison

View GitHub Profile
@peterc
peterc / CONVENTIONS.md
Last active March 10, 2025 06:49
CONVENTIONS.md file for AI Rails 8 development
  • You MUST NOT try and generate a Rails app from scratch on your own by generating each file. For a NEW app you MUST use rails new first to generate all of the boilerplate files necessary.
  • Create an app in the current directory with rails new .
  • Use Tailwind CSS for styling. Use --css tailwind as an option on the rails new call to do this automatically.
  • Use Ruby 3.2+ and Rails 8.0+ practices.
  • Use the default Minitest approach for testing, do not use RSpec.
  • Default to using SQLite in development. rails new will do this automatically but take care if you write any custom SQL that it is SQLite compatible.
  • An app can be built with a devcontainer such as rails new myapp --devcontainer but only do this if requested directly.
  • Rails apps have a lot of directories to consider, such as app, config, db, etc.
  • Adhere to MVC conventions: singular model names (e.g., Product) map to plural tables (products); controllers are plural.
  • Guard against incapable browsers accessing controllers with `allo
@stympy
stympy / honeybadger.rb
Created July 12, 2024 19:32
Filtering and truncating SQL before reporting to Insights
# config/initializers/honeybadger.rb
Honeybadger.configure do |config|
config.before_event do |event|
# DB-backed job backends can generate a lot of useless queries
if event.event_type == "sql.active_record" && event[:query]&.match?(/good_job|solid_queue/)
event.halt!
end
# Truncate long queries
if event.event_type == "sql.active_record" && event[:query].present?
@dbreunig
dbreunig / random_emoji.rb
Last active January 2, 2025 18:14
A Ruby function that returns a random emoji. Useful for seeding and more.
EMOJI_CODEPOINTS = [
*0x1F600..0x1F64F, # Emoticons
*0x1F300..0x1F5FF, # Misc Symbols and Pictographs
*0x1F680..0x1F6FF, # Transport and Map Symbols
*0x2600..0x26FF, # Misc symbols
*0x2700..0x27BF, # Dingbats
*0x1F900..0x1F9FF, # Supplemental Symbols and Pictographs
*0x1FA70..0x1FAFF # Symbols and Pictographs Extended-A
]
def random_emoji = EMOJI_CODEPOINTS.sample.chr(Encoding::UTF_8)

How to deploy a Rails 7.1 app with Postgres and Kamal on a single server

I think you have looked at the tutorial from Mr. Heinemeier Hansson at least once or twice and have a similar setup.

rails new kamal_pg --css tailwind --skip-test --database=postgresql

cd kamal_pg
const chromium = require('chrome-aws-lambda');
const puppeteer = require('puppeteer-core');
const extractor = require('unfluff');
const summarize = require('summarize');
exports.handler = async (event, context, callback) => {
console.log('Received event:', JSON.stringify(event, null, 2));
@staltz
staltz / adnetworks.txt
Created November 20, 2016 10:34
Ban these domains of ad networks
101com.com, 101order.com, 123found.com, 180hits.de, 180searchassistant.com, 1x1rank.com, 207.net, 247media.com, 24log.com, 24log.de, 24pm-affiliation.com, 2mdn.net, 2o7.net, 360yield.com, 4affiliate.net, 4d5.net, 50websads.com, 518ad.com, 51yes.com, 600z.com, 777partner.com, 77tracking.com, 7bpeople.com, 7search.com, 99count.com, a-ads.com, a-counter.kiev.ua, a.0day.kiev.ua, a.aproductmsg.com, a.collective-media.net, a.consumer.net, a.mktw.net, a.sakh.com, a.ucoz.net, a.ucoz.ru, a.xanga.com, a32.g.a.yimg.com, aaddzz.com, abacho.net, abc-ads.com, absoluteclickscom.com, abz.com, ac.rnm.ca, accounts.pkr.com.invalid, acsseo.com, actionsplash.com, actualdeals.com, acuityads.com, ad-balancer.at, ad-balancer.net, ad-center.com, ad-images.suntimes.com, ad-pay.de, ad-rotator.com, ad-server.gulasidorna.se, ad-serverparc.nl, ad-souk.com, ad-space.net, ad-tech.com, ad-up.com, ad.100.tbn.ru, ad.71i.de, ad.980x.com, ad.a8.net, ad.abcnews.com, ad.abctv.com, ad.about.com, ad.aboutit.de, ad.aboutwebservices.com, ad.abum.com,
@jtwaleson
jtwaleson / fetch.go
Created January 17, 2016 12:08
Certificate fetcher in Go
package main
import "crypto/tls"
import "crypto/sha1"
import "crypto/x509"
import "fmt"
import "encoding/pem"
import "os"
import "time"
import "bufio"
@lydell
lydell / bigrams-to-pairs.js
Created August 23, 2015 08:54
English bigram and letter pair frequencies from the Google Corpus Data in JSON format
// By Simon Lydell 2015.
// This file is in the public domain.
var stdin = require("get-stdin")
var tools = require("text-frequencies-analysis")
var helpers = require("text-frequencies-analysis/lib/helpers")
stdin(function(text) {
process.stdout.write(tools.jsonStringifyRow(convert(JSON.parse(text))))
})
# -*- coding: utf-8 -*-
"""
common-crawl-cdx.py
A simple example program to analyze the Common Crawl index.
This is implemented as a single stream job which accesses S3 via HTTP,
so that it can be easily be run from any laptop, but it could easily be
converted to an EMR job which processed the 300 index files in parallel.
@tgittos
tgittos / pinterest-watir.rb
Last active August 29, 2015 14:17
Use Ruby and Watir-Webdriver to scrape pins from a Pinterest page.
#! /usr/bin/env ruby
require 'watir-webdriver'
require 'openssl'
require 'open-uri'
require 'nokogiri'
# bad pinterest, having a bad cert
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE