Skip to content

Instantly share code, notes, and snippets.

@tonioriol
tonioriol / reset-postgres-autoincrement.sql
Created March 8, 2018 11:27
Reset Postgres Autoincrement
select setval((select pg_get_serial_sequence('table_name', 'id')), (select max(id) from table_name));
@tonioriol
tonioriol / rails-docker-pg-template.rb
Created April 10, 2018 15:26 — forked from cblunt/rails-docker-pg-template.rb
A simple Rails application configured for PostgreSQL and Docker
generate(:scaffold, "post", "title:string", "body:text")
route "root to: 'posts#index'"
file 'config/database.yml', <<-CODE
default: &default
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
host: db
@tonioriol
tonioriol / README.md
Last active April 12, 2019 15:10 — forked from boneskull/README.md
syntax highlighting for Vagrantfile in non-RubyMine JetBrains IDEs
  1. Add this file to ~/Library/Preferences/RiderXXXX.X/filetypes/Vagranfile.xml
  2. Restart IDE

This page will help you find the correct directory.

#!/bin/bash
for FILE in *; do
echo "${FILE}"
duration=$(ffprobe -i "${FILE}" -show_entries format=duration -v quiet -of csv="p=0")
nth_second=$(echo "${duration} - 2.3" | bc)
ffmpeg -i "${FILE}" -ss 0.1 -to "${nth_second}" "fixed-${FILE}"
done
@tonioriol
tonioriol / heroku_pg_copy.sh
Last active September 22, 2020 09:16
copy postgres from one app db to another
# copy postgres from one app db to another
heroku pg:copy sushi::ORANGE GREEN --app sushi-staging
# This would copy data from the ORANGE database of the sushi app to the GREEN database in sushi-staging. This could be used to copy production data into a staging app for testing purposes.
# source: https://devcenter.heroku.com/articles/heroku-postgres-backups#direct-database-to-database-copies
@tonioriol
tonioriol / avi_to_mkv_set_lang.sh
Created June 30, 2021 15:17
Convert avi to mkv and set audio lang tags with MKVToolNix
# convert avi to mkv and set audio lang tags
# brew install mkvtoolnix
# loop all avi files in current folder
for file in *.avi; do
# replace original avi ext by mkv ext
mkv="${file%.*}.mkv"
# convert avi to mkv
#!/bin/bash
# Exit if any command fails
set -e
# Check if script is run as root
if [ "$EUID" -eq 0 ]
then echo "Please do not run as root"
exit
fi