Skip to content

Instantly share code, notes, and snippets.

@zulhfreelancer
zulhfreelancer / heroku_pg_db_reset.md
Last active Jul 22, 2021
How to reset PG Database on Heroku (for Rails app)?
View heroku_pg_db_reset.md

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 Jul 6, 2020 — forked from dideler/upgrade-postgres-9.3-to-9.4.md
Upgrading PostgreSQL from 9.3 to 9.5 on Ubuntu
View upgrade-postgres-9.3-to-9.5.md

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
@rotvulpix
rotvulpix / validarRUT.html
Last active Jul 20, 2021
HTML5 Chilean RUT Validator
View validarRUT.html
<!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 Dec 7, 2013
Rails - Import SQL file as seed
View seeds.rb
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
@smazhara
smazhara / gist:4740692
Last active May 16, 2021
Ruby AES128 encrypt-decrypt example
View gist:4740692
require "openssl"
require "base64"
include Base64
@ctalkington
ctalkington / Gemfile
Last active Oct 12, 2020
Nginx, Sinatra, and Puma.
View Gemfile
source :rubygems
gem "puma"
gem "sinatra"
View yardoc_cheatsheet.md
@RiANOl
RiANOl / gist:1077760
Last active Jun 30, 2021
AES128 / AES256 CBC with PKCS7Padding in Ruby
View gist:1077760
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