Skip to content

Instantly share code, notes, and snippets.

View chloerei's full-sized avatar

Rei chloerei

View GitHub Profile
@fabiolimace
fabiolimace / UUIDv6.sql
Last active September 16, 2024 08:02
Functions for generating UUIDv6 and UUIDv7 on PostgreSQL
/*
* MIT License
*
* Copyright (c) 2023-2024 Fabio Lima
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@MarkMurphy
MarkMurphy / README.md
Last active February 5, 2024 19:59
Cursor based pagination for Rails models.

Example Usage

Users

id name
1 Jane
2 Max
3 John
4 Scott
@mojavelinux
mojavelinux / generate-cjk-font.pe
Created December 31, 2014 09:53
Distill the NotoSansCJK otf fonts into something we can use in Asciidoctor PDF (and Asciidoctor EPUB3)
#!/usr/bin/env fontforge
# * 0x90 - Neither OpenType or Apple
# * 0x800 - Generate old-style 'kern' table
# * 0x08 - Exclude TrueType instructions
# For PDF
genflags = 0x90 + 0x08 + 0x800
# For EPUB3
# config/routes.rb
resources :documents do
scope module: 'documents' do
resources :versions do
post :restore, on: :member
end
resource :lock
end
end
class GroupersController < ApplicationController::Base
def create
@grouper = Grouper.new(leader: current_member)
if @grouper.save
confirm_grouper_via_emails(@grouper)
enqueue_bar_assignment(@grouper)
redirect_to home_path
else
@terryjray
terryjray / gist:3296171
Created August 8, 2012 15:55
Enabling hstore for new postgresql 9.1 and rails 3 install on ubuntu 12.04
RAILS_ENV=production rake db:setup
# produces the error below.....hmmm.....it's a no-worky
psql:/yourprojectpath/yourproject/db/structure.sql:29: ERROR: could not open extension control file "/usr/share/postgresql/9.1/extension/hstore.control": No such file or directory
# hstore postgresql extension needs to be installed, so....
sudo apt-get install postgresql-contrib
# now your extension should be available to enable so log in with psql
psql -d yourproject_production -U yourdbuser -W
@czottmann
czottmann / Procfile
Created June 15, 2011 13:43
Example of a Foreman/Capistrano/upstart setup
worker: QUEUE=* bundle exec rake environment resque:work
scheduler: bundle exec rake environment resque:scheduler
@dhh
dhh / gist:1014971
Created June 8, 2011 18:09
Use concerns to keep your models manageable
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end
class DownloadsController < ApplicationController
def show
if @current_user
send_file "#{Rails.root}/downloads/test.pdf"
else
render :file => "#{Rails.root}/public/404.html", :status => 404, :layout => false
end
end
end