Skip to content

Instantly share code, notes, and snippets.

View carlosveucv's full-sized avatar

Carlos García carlosveucv

View GitHub Profile
#!/bin/bash
for file in *.MP4; do
ffmpeg -i "$file" -an -c:v copy "${file%.MP4}_noaudio.MP4"
rm "$file"
done
for file in *.mp4; do
ffmpeg -i "$file" -an -c:v copy "${file%.mp4}_noaudio.MP4"
rm "$file"
done
@carlosveucv
carlosveucv / sanitize_compact_hash.rb
Created May 24, 2019 07:36
sanitize_compact_hash
def main
files = Dir.entries(".").sort
files.each do |file|
array = convert_file_to_sanitized_array(file)
array_for_file(file, array) unless array.empty?
end
end
def convert_file_to_sanitized_array(file)
array = []
@carlosveucv
carlosveucv / sanitize_hash_to_validate.rb
Created May 23, 2019 21:59
Parse all files in a folder
def main
files = Dir.entries(".").sort
files.each do |file|
array = convert_file_to_sanitized_array(file)
array_for_file(file, array) unless array.empty?
end
end
def convert_file_to_sanitized_array(file)
array = []
@carlosveucv
carlosveucv / dummy_data_mysql.rb
Created February 26, 2019 11:55
Dummy data to fill up mysql on batches
#!/usr/bin/env ruby
require 'mysql2'
require 'securerandom'
require 'date'
@mysql_username = 'root'
@mysql_password = 'root'
@mysql_port = 3306
@mysql_host = '1.1.1.1'
@database_name = 'foo_database'
@carlosveucv
carlosveucv / dummy_data_mysql.rb
Created February 11, 2019 08:59
Populate Mysql Database with dummy data automatically
#!/usr/bin/env ruby
require 'mysql2'
require 'securerandom'
require 'date'
@mysql_username = 'foo_username'
@mysql_password = 'foo_password'
@mysql_port = 3306
@database_name = 'foo_database'
@number_of_transactions = 100
@carlosveucv
carlosveucv / yaml_cmp_and_replace.rb
Last active June 1, 2022 09:52
Replace values of a Yaml ( only if it exists and key (whole path) matches ) -> Generates a 3rd file
require 'yaml'
def hash_ypath(ypath, hash, value=nil)
paths = ypath.split('.', 2)
actual_path = paths[0]
return if hash[actual_path].nil?
if paths.size == 1
hash[actual_path] = value if value
return hash[actual_path]
end
@carlosveucv
carlosveucv / yaml_cmp.rb
Created September 1, 2016 14:50
Compare 2 yaml's in ruby (print matching keys)
require 'yaml'
def compare_yaml_hash(cf1, cf2, context = [])
cf1.each do |key, value|
if cf2.key?(key)
puts "Contains key : #{key} in path #{context.join(".")}"
end
value2 = cf2[key]
next unless value2