Skip to content

Instantly share code, notes, and snippets.

#!/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
@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
@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
#!/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 / 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.

@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 / 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 / getSelectedHtml.html
Created February 25, 2018 18:36
Get selected HTML
<!DOCTYPE html>
<html>
<head>
<title>Get selected HTML</title>
<script>
function getSelectionHtml () {
var div, range, sel, result;
if (window.getSelection) {
sel = window.getSelection();
} else if (document.selection) {
@tonioriol
tonioriol / texteditor.html
Last active February 25, 2018 12:26
Text editor using contenteditable html attribute
<!-- data:text/html, -->
<html>
<head>
<title>Textr0n</title>
<style>
body {
margin: 0;
}
@tonioriol
tonioriol / laravel-forge-deploy.sh
Last active April 25, 2023 22:20 — forked from rap2hpoutre/laravel-forge-deploy.sh
Laravel Forge zero downtime deployment script
# stop script on error signal
set -e
SITE="your-site-original-folder-name.com"
DEPL="/home/forge/deployments/${SITE}"
# create directory and any intermediate directories if don't exist
mkdir -p ${DEPL}
CUR="/home/forge/${SITE}"