Skip to content

Instantly share code, notes, and snippets.

View rafamoreira's full-sized avatar
:shipit:

Rafael Moreira rafamoreira

:shipit:
View GitHub Profile
#!/bin/bash
#
# This script will create a 'backend.md' and 'frontend.md' containing
# all the source code in the current directory. You can then upload these
# files to a custom GPT. It's setup for my golang project but you can easily
# modify it to suit your needs.
#
# This script requires 'fd' to be installed.
set -e
File.open("my_db", "w") do |f|
ActiveRecord::Base.connection.tables.sort.each do |table_name|
f.write "#{table_name}\n"
ActiveRecord::Base.connection.columns(table_name).map(&:name).sort.each do |c|
f.write "- #{c}\n"
end
end
end
@rafamoreira
rafamoreira / puma.service
Created July 1, 2019 10:42
puma systemd unit
[Unit]
Description=Puma Rails Server
After=network.target
[Service]
Type=simple
User=deploy
WorkingDirectory=/home/deploy/apps/app/current
ExecStart=/home/deploy/.rbenv/bin/rbenv exec bundle exec puma -C /home/deploy/apps/app/shared/puma.rb
ExecStop=/home/deploy/.rbenv/bin/rbenv exec bundle exec pumactl -S /home/deploy/apps/app/shared/tmp/pids/puma.state stop
@rafamoreira
rafamoreira / delayed_job.service
Created July 1, 2019 10:41
delayed_job systemd service
[Unit]
Description=delayed_job
After=network.target
After=syslog.target
After=postgresql.target
[Service]
Type=forking
User=deploy
Environment=RAILS_ENV=production
@rafamoreira
rafamoreira / easy_rails_deployment_with_capistrano.md
Created March 25, 2018 08:57
Easy Rails deployment with Capistrano

Goals of this tutorial:

  • deploy a new Rails app with capistrano
  • make it fast (total process takes less than 5 minutes)
  • make it simple (no unecessary config)
  • manual ssh to the server not required

Rails application stack:

  • nginx
  • unicorn
  • postgresql
@rafamoreira
rafamoreira / VM-XServer-Instructions.md
Created March 25, 2018 02:13 — forked from rpavlik/VM-XServer-Instructions.md
Cygwin X for a virtual machine

Using Cygwin X as a display for a Linux VM without SSH overhead

This is primarily for my own record and knowledge. If it helps you, great! If it breaks something, don't say I didn't warn you - this is just documentation of what I did to get this to work at the time I wrote this on one particular machine.

Environment

  • I have a 64-bit cygwin install in c:\cygwin64 (possible in 32-bit too, I just messed up that install and it no longer works, so these were tested on my machine in a 64-bit install). I use my Cygwin setup scripts to simplify this part.
  • I'm using VirtualBox on Windows 8.1.
    • Importantly (at least for VirtualBox), I added a "host-only networking" adapter for communication between the guest (VM) and host machine - this seems to be required.
  • Totally optional but useful part of my setup: I'm using VBoxHeadlessTray to be able to easily have my virtual machine running without taking
@rafamoreira
rafamoreira / RemoteTech_Settings.cfg
Created October 15, 2017 03:21
Remote Tech settings for RSS with Alcantara Base
// ==================================================
// RSS tracking stations.
// Red: Uncategorized
// Green: ESTRACK / DSA
// Blue: DSN
// Yellow: Launch sites
// Magenta: MSFN
// The methodology for range here is game-y, but then RT2 is game-y to begin with.
@rafamoreira
rafamoreira / LaunchSites.cfg
Created October 15, 2017 02:40
KSCSwitcher with Alcantara - BR launch base
@KSCSWITCHER:FOR[RealSolarSystem]
{
// Please keep this list alphabetically sorted.
// The launch sites in this list are historical or planned orbital launch sites.
// Launch site displayName should be [ISO 3166-1 alpha-2 code of current country] - Common Name,
// For technical reasons unicode support is poor; site names in non-latin scripts should be given their
// traditional English name, or if none exists, the English romanization of their name.
// Examples:
// FR - Kourou, not FR - Centre Spatial Guyanais (full name),
// DZ - Hammaguir, not FR - Hammaguir (former country), DZ - Centre interarmées d'essais d'engins spéciaux de Hammaguir B2 (full name)
@rafamoreira
rafamoreira / folha.snob
Last active December 25, 2015 04:39
Block Comments on folha.com.br
{
"id": "[email protected]",
"label": "folha",
"url": "^https?://www1\\.folha\\.uol\\.com\\.br/.*$",
"dynamic": false,
"allCommentsSelector": "#articleComments",
"commentContainerSelector": ".comment_li",
"commentTextSelector": "p"
}
require 'cgi'
require 'digest/md5'
require 'net/https'
require 'uri'
module Jekyll
class GistTag < Liquid::Tag
def initialize(tag_name, text, token)
super
@text = text