Skip to content

Instantly share code, notes, and snippets.

@zulhfreelancer
zulhfreelancer / heroku_pg_db_reset.md
Last active January 29, 2024 10:09
How to reset PG Database on Heroku (for Rails app)?

It's important to note that running this reset will drop any existing data you have in the application

How to reset PG Database on Heroku?

  • Step 1: heroku restart
  • Step 2: heroku pg:reset DATABASE (no need to change the DATABASE)
  • Step 3: heroku run rake db:migrate
  • Step 4: heroku run rake db:seed (if you have seed)

One liner

@johanndt
johanndt / upgrade-postgres-9.3-to-9.5.md
Last active July 15, 2022 12:35 — forked from dideler/upgrade-postgres-9.3-to-9.4.md
Upgrading PostgreSQL from 9.3 to 9.5 on Ubuntu

TL;DR

Install Postgres 9.5, and then:

sudo pg_dropcluster 9.5 main --stop
sudo pg_upgradecluster 9.3 main
sudo pg_dropcluster 9.3 main
@gaulatti
gaulatti / validarRUT.html
Last active June 15, 2023 15:12
HTML5 Chilean RUT Validator
<!doctype html>
<html lang="es">
<head>
<meta charset="UTF-8">
<title>Validador de RUT HTML5</title>
</head>
<body>
<form>
<input type="text" id="rut" name="rut" required oninput="checkRut(this)" placeholder="Ingrese RUT">
<button type="submit">Validar RUT y Enviar Form</button>
@seyhunak
seyhunak / seeds.rb
Created December 7, 2013 14:54
Rails - Import SQL file as seed
unless Rails.env.production?
connection = ActiveRecord::Base.connection
connection.tables.each do |table|
connection.execute("TRUNCATE #{table}") unless table == "schema_migrations"
end
sql = File.read('db/import.sql')
statements = sql.split(/;$/)
statements.pop
Simple Ruby Server:
# ruby -run -e httpd -- -p 5000 .
Simple Python Server:
# python -m SimpleHTTPServer
@smazhara
smazhara / gist:4740692
Last active May 16, 2021 19:55
Ruby AES128 encrypt-decrypt example
require "openssl"
require "base64"
include Base64
@ctalkington
ctalkington / Gemfile
Last active May 16, 2023 20:19
Nginx, Sinatra, and Puma.
source :rubygems
gem "puma"
gem "sinatra"
@chetan
chetan / yardoc_cheatsheet.md
Last active April 16, 2024 23:49
YARD cheatsheet
@RiANOl
RiANOl / gist:1077760
Last active April 13, 2024 06:17
AES128 / AES256 CBC with PKCS7Padding in Ruby
require "openssl"
require "digest"
def aes128_cbc_encrypt(key, data, iv)
key = Digest::MD5.digest(key) if(key.kind_of?(String) && 16 != key.bytesize)
iv = Digest::MD5.digest(iv) if(iv.kind_of?(String) && 16 != iv.bytesize)
aes = OpenSSL::Cipher.new('AES-128-CBC')
aes.encrypt
aes.key = key
aes.iv = iv