Skip to content

Instantly share code, notes, and snippets.

@tonioriol
tonioriol / avi_to_mkv_set_lang.sh
Created Jun 30, 2021
Convert avi to mkv and set audio lang tags with MKVToolNix
View avi_to_mkv_set_lang.sh
# 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 Sep 22, 2020
copy postgres from one app db to another
View heroku_pg_copy.sh
# 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
View trim_audio_file.sh
#!/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 Apr 12, 2019 — forked from boneskull/README.md
syntax highlighting for Vagrantfile in non-RubyMine JetBrains IDEs
View README.md
  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 Apr 10, 2018 — forked from cblunt/rails-docker-pg-template.rb
A simple Rails application configured for PostgreSQL and Docker
View rails-docker-pg-template.rb
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
View reset-postgres-autoincrement.sql
select setval((select pg_get_serial_sequence('table_name', 'id')), (select max(id) from table_name));
View getSelectedHtml.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 Feb 25, 2018
Text editor using contenteditable html attribute
View texteditor.html
<!-- data:text/html, -->
<html>
<head>
<title>Textr0n</title>
<style>
body {
margin: 0;
}
@tonioriol
tonioriol / laravel-forge-deploy.sh
Last active Oct 14, 2021 — forked from rap2hpoutre/laravel-forge-deploy.sh
Laravel Forge zero downtime deployment script
View laravel-forge-deploy.sh
# 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}"
View enable-disable-xdebug.sh
#disable xdebug on vagrant
sudo php5dismod xdebug
#enable xdebug on vagrant
sudo php5enmod xdebug
# restart apache
sudo service apache2 restart