Skip to content

Instantly share code, notes, and snippets.

@ismarsantos
ismarsantos / uuidv4test.js
Created October 24, 2021 22:25 — forked from johnelliott/uuidv4test.js
uuid v4 regex
import { v4 as uuid } from 'uuid';
export function generateId() {
return uuid();
}
const v4 = new RegExp(/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i);
console.log(generateId().match(v4));
//console.log(generateId().length)
@ismarsantos
ismarsantos / launch_postgres_console.sh
Created October 23, 2021 14:07 — forked from emailrhoads/launch_postgres_console.sh
Launch Postgres Console #postgres
sudo su -
su postgres
psql
@ismarsantos
ismarsantos / downloading_pdfs.markdown
Created September 28, 2021 12:57
Generating and Download PDF's in Rails (Windows)

Generating and Downloading PDF's in Rails (Windows)

I had a lot of trouble trying to get one of my Rails apps to accomplish this common task. For one thing, my dev box runs Windows 7, which notoriously does not play nicely with Ruby on Rails. Another thing... all the instructions/tutorials/document for the gem I'm using, Wicked PDF, were either incomplete or, for some reason or another, didn't work for me.

That's all to say, here are the steps I took, and I hope they will help someone.

I used the Wicked PDF gem. Ryan Bates over at RailsCasts goes over using PDFKit, but this writeup will be all about Wicked PDF.

These next steps I got straight from the instructions on the GitHub page:

class AddRecordUuidToActiveStorageAttachments < ActiveRecord::Migration[5.2]
def change
# After applying this migration, you'll need to manually go through your
# attachments and populate the new `record_uuid` column.
# If you're unable to do this, you'll probably have to delete all your attachments.
# You've pretty much got useless garbage data if that's the case :(
add_column :active_storage_attachments, :record_uuid, :uuid
end
end
@ismarsantos
ismarsantos / rbenv-deploy.sh
Created August 22, 2021 23:57 — forked from ipoerner/rbenv-deploy.sh
Shell script to deploy rbenv w/ ruby-build plugin
#!/bin/sh
set -e # Exit script immediately on first error.
set -x # Print commands and their arguments as they are executed.
# Update Debian package index.
sudo apt-get update -y
# Install required Debian packages.
sudo apt-get install -y build-essential git-core wget zlib1g-dbg libssl-dev libreadline-dev libopenssl-ruby
@ismarsantos
ismarsantos / gist:b107e499291770ff90e46b39611ed422
Created August 19, 2021 18:07 — forked from hhff/gist:158a3ac397eb66df6a98
Setting up Spree on Dokku via Digital Ocean
Spree API Server Needs
- Easy Setup & Deployment (Dokku)
- New Relic
- Error Monitoring (Raven)
- Performance Monitoring (Skylight)
- Logging (Loggly or Logentries?)
- SSL (Dokku handles this)
- Database Backups (http://donpottinger.net/blog/2014/11/22/bye-bye-heroku-hello-dokku-part-2.html (See Clockwork section))
- Caching (Memcached + Dalli)
- Worker (Sidekiq)
@ismarsantos
ismarsantos / digitalocean.md
Created August 19, 2021 18:05 — forked from JamesDullaghan/digitalocean.md
Deploy rails app to digitalocean with nginx, unicorn, capistrano & postgres

Deploy Rails app to digitalocean with nginx, unicorn, capistrano & postgres

Create droplet of your liking (ubuntu 12.10 x32)

ssh to root in terminal with your server ip

ssh [email protected]

Add ssh fingerprint and enter password provided in email

@ismarsantos
ismarsantos / digitalocean.md
Created August 19, 2021 18:05 — forked from jentanbernardus/digitalocean.md
Setup instructions for Digital Ocean VPS using Ubuntu and Rails 3.2 #digitalocean #vps #setup

Deploy Rails app to digitalocean with nginx, unicorn, capistrano & postgres

Create Droplet

Create droplet of your liking (ubuntu 12.04 x32) Use an xx.04 LTS version

Setup DNS

On Digital Ocean, create a DNS entry for your server (xyz.com)

Make sure it has NS records that use digital oceans nameservers

@ismarsantos
ismarsantos / 01. Gemfile
Created August 12, 2021 00:29 — forked from schleg/01. Gemfile
Setup for Devise + Omniauth
gem 'pg'
group :development do
gem 'ruby-debug'
end
gem 'rake', '~> 0.8.7'
gem 'devise'
gem 'oa-oauth', :require => 'omniauth/oauth'
gem 'omniauth'
gem 'haml'
gem 'dynamic_form'
Note: this assumes you are using ZSH shell.
## Installation
Install [asdf](https://github.com/asdf-vm/asdf):
```
$ git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.4.0
$ echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.zshrc
$ echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.zshrc