Skip to content

Instantly share code, notes, and snippets.

@ryanburnette
ryanburnette / Caddyfile
Last active July 9, 2024 01:41
Caddy v2.1+ CORS whitelist
(cors) {
@cors_preflight{args.0} method OPTIONS
@cors{args.0} header Origin {args.0}
handle @cors_preflight{args.0} {
header {
Access-Control-Allow-Origin "{args.0}"
Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE, OPTIONS"
Access-Control-Allow-Headers *
Access-Control-Max-Age "3600"
@tombeynon
tombeynon / pgloader-commands
Created October 5, 2016 15:06
pg_loader config to migrate a MySQL DB to Postgres
-- See https://github.com/dimitri/pgloader/blob/master/pgloader.1.md for
-- connection string options.
LOAD DATABASE
FROM mysql://root@localhost/mydb
INTO postgresql:///mydb
WITH include drop, truncate, create tables, create indexes, foreign keys, reset sequences
-- CAST varchar to varchar instead of text
@andypike
andypike / index.html.erb
Created February 13, 2016 19:43
Notes and experiments for the view objects in Rectify
<!--
In the template just use the @view object and call it's methods to clean up
the presentation logic. Maybe think about adding a helper method called `view`
that just returns `@view` so we can remove the noise of the `@`.
-->
<%= @view.users.each do |user| %>
<%= @view.user_link(user) %>
<% end %>
@tristanm
tristanm / README.md
Last active May 13, 2024 06:16
Migrating a Rails project from MySQL to PostgreSQL

Migrating a Rails project from MySQL to PostgreSQL

This brief guide is written from my own experience with migrating a large (~5GB) MySQL database to PostgreSQL for a Rails project.

No warranties, guarantees, support etc. Use at your own risk and, as always, ENSURE YOU MAKE BACKUPS FIRST!

I chose [pgloader][1] because it's extremely fast. YMMV.

  1. Replace mysql2 gem with pg in Gemfile.
  2. Update config/database.yml for PostgreSQL. I used [Rails' template][2] as a starting point.
@bradmontgomery
bradmontgomery / install-comodo-ssl-cert-for-nginx.rst
Last active June 10, 2024 15:37
Steps to install a Comodo PositiveSSL certificate with Nginx.

Setting up a SSL Cert from Comodo

I use Namecheap.com as a registrar, and they resale SSL Certs from a number of other companies, including Comodo.

These are the steps I went through to set up an SSL cert.

Purchase the cert

# RSpec matcher to spec delegations.
# Forked from https://gist.github.com/ssimeonov/5942729 with fixes
# for arity + custom prefix.
#
# Usage:
#
# describe Post do
# it { should delegate(:name).to(:author).with_prefix } # post.author_name
# it { should delegate(:name).to(:author).with_prefix(:any) } # post.any_name
# it { should delegate(:month).to(:created_at) }
@Relequestual
Relequestual / remove.sql
Created September 20, 2012 13:52
Remove hidden character copied from Adobe (Ps, Ai) from mysql database
# Replace TABLE and COLUMN as appropriate
Update TABLE Set COLUMN = Replace(COLUMN, CHAR(3), '');
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active July 21, 2024 20:54
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname