Skip to content

Instantly share code, notes, and snippets.

View superacidjax's full-sized avatar

Brian Dear superacidjax

View GitHub Profile
require "digest"
require "rack"
# This class encapsulates a unit of work done for a particular tenant, connected to that tenant's database.
# ActiveRecord makes it _very_ hard to do in a simple manner and clever stuff is required, but it is knowable.
#
# What this class provides is a "misuse" of the database "roles" of ActiveRecord to have a role per tenant.
# If all the tenants are predefined, it can be done roughly so:
#
# ActiveRecord::Base.legacy_connection_handling = false if ActiveRecord::Base.respond_to?(:legacy_connection_handling)
@superacidjax
superacidjax / description_writer.rb
Created April 20, 2025 19:09
This is a Ruby program that takes a CSV and prompts a locally running Ollama LLM to generate a useful description suitable for publishing in a directory. This uses multithreading: you can specify the number of threads when involving at the command line.
require 'csv'
require 'net/http'
require 'json'
require 'uri'
require 'thread'
require 'optparse'
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: #{$PROGRAM_NAME} [options] <input.csv> [output.csv]"
@tadast
tadast / ssl_puma.sh
Last active January 21, 2025 16:20 — forked from trcarden/gist:3295935
localhost SSL with puma
# 1) Create your private key (any password will do, we remove it below)
$ cd ~/.ssh
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@juandazapata
juandazapata / mountain_lion_home_brew.md
Created July 26, 2012 15:07
Get Mountain Lion and Homebrew to Be Happy

Get Mountain Lion and Homebrew to Be Happy

After upgrading to Mountain Lion, I got this message when trying to run my local rails server:

Installing rmagick (2.13.1) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    Users/user/.rvm/rubies/ruby-1.9.3-rc1/bin/ruby extconf.rb
@patbenatar
patbenatar / gist:3021688
Last active October 6, 2015 16:28
My Sublime Text 2 Preferences
{
	"color_scheme": "Packages/Color Scheme - Default/Solarized (Dark).tmTheme",
	"draw_white_space": "selection",
	"font_face": "Source Code Pro",
	"font_size": 14,
	"highlight_line": true,
	"ignored_packages":
	[
 "Vintage"
@superacidjax
superacidjax / the_install.sh
Created November 8, 2011 07:17 — forked from therubymug/the_install.sh
Ruby development environment for OS X (Lion)
#!/usr/bin/env sh
# Title: Ruby development environment for OS X (Lion)
# Author: Rogelio J. Samour
# Warning:
# While it is unlikely any code below might damage your system,
# it’s always a good idea to back up everything that matters to you
# before running this script! Just in case. I am not responsible for
# anything that may result from running this script. Proceed at
# your own risk.
@therubymug
therubymug / the_install.sh
Created November 5, 2011 18:48
Ruby development environment for OS X (Lion)
#!/usr/bin/env sh
# Title: Ruby development environment for OS X (Lion)
# Author: Rogelio J. Samour
# Warning:
# While it is unlikely any code below might damage your system,
# it’s always a good idea to back up everything that matters to you
# before running this script! Just in case. I am not responsible for
# anything that may result from running this script. Proceed at
# your own risk.
@mhenrixon
mhenrixon / _form.html.haml
Created May 18, 2011 11:02
A complete sample of how to perform nested polymorphic uploads in rails using carrierwave
=semantic_form_for [:admin, @dog], validate: true, html: {multipart: true} do |f|
=f.inputs do
=f.input :name
=f.input :kennel_name
=f.input :birthdate
=f.input :gender, as: :radio, collection: {'Tik' => 'F', 'Hane' => 'M'}
=f.input :father_id, as: :select, collection: @dogs
=f.input :mother_id, as: :select, collection: @bitches
=f.semantic_fields_for :pictures do |pic|
@yunjian
yunjian / Opentok_rails.rb
Created February 28, 2011 21:13
Use Opentok API in Rails
# 1. plugin
# Download the ruby SDK code, and copy to the plugin directory.
${RAILS_ROOT}/vendor/plugins/opentok
# You may need to create an "init.rb" file in the opentok plugin directory,
# and insert the following line.
require 'opentok'
# 2. database