Skip to content

Instantly share code, notes, and snippets.

View rstriquer's full-sized avatar
🎯
focused

Ricardo Striquer Soares rstriquer

🎯
focused
View GitHub Profile
@rstriquer
rstriquer / minthemall.sh
Last active January 17, 2019 01:36
Find all css and javascript files in pwd filesystem and minify them all using cssminifier.com and jpgoptimiser.com creating the "min" files all around
#!/bin/bash
#files=`find "$PWD" -type f \( -name \*.css -o -name \*.js \) | grep -vP '^(.*).min.css$' | grep -vP '^(.*).min.js$'` # pega todos os arquivos
files=`find "$PWD" -type f \( -name \*.css -o -name \*.js \) -mmin -30 | grep -vP '^(.*).min.css$' | grep -vP '^(.*).min.js$'` # pega todos os arquivos
for file in $files; do
extention="${file##*.}"
if [ "css" == "$extention" ]; then
dname="${file%/*}"
fname="${file##*/}"
@rstriquer
rstriquer / CheckFileNames.sh
Last active September 21, 2018 12:43
simple bash backup script
#!/bin/bash
# Format: UTF8
# Sometimes there are some strange names which can generate a filesystem inconsistency if not
# corrected, therefore this script can be used to find files with those filename inconsistensies
PATH=/usr/local/bin/:/usr/bin/:/bin/:$PATH
find . -type f > filenames
while read filename; do
stripped="$(printf '%s\n' "$filename" | tr -d -C '[[:alnum:]][[:space:]][[:punct:]]')"
test "$filename" = "$stripped" || printf '%s\n' "$filename";
@rstriquer
rstriquer / MySQL base64_encode
Created December 30, 2015 12:14
Função para encodar strings em MySQL com o algoritmo base64 http://www.programabrasil.org/mysql-base64-encode-sem-tabela-de-conversao/
DELIMITER $$
USE `YOUR DATABASE`$$
DROP FUNCTION IF EXISTS `BASE64_ENCODE`$$
CREATE DEFINER=`YOUR DATABASE`@`%` FUNCTION `BASE64_ENCODE`(input BLOB) RETURNS BLOB
DETERMINISTIC
SQL SECURITY INVOKER
BEGIN
DROP FUNCTION IF EXISTS `slugify`;
DELIMITER ;;
CREATE DEFINER=CURRENT_USER
FUNCTION `slugify`(dirty_string varchar(200))
RETURNS varchar(200) CHARSET latin1
DETERMINISTIC
BEGIN
DECLARE x, y , z Int;
Declare temp_string, new_string VarChar(200);
Declare is_allowed Bool;
@rstriquer
rstriquer / gist:7600754
Created November 22, 2013 14:31
Show git repository diff of all files creating a simple "/tmp/gitlist.text" file with all differences in it
#!/bin/bash
rm -rf /tmp/gitlist.text
for f in $(echo -e "`git status | awk -F" " '{printf "%s\n", $3}' | tail -n+6 | head -n-7`"); do
git diff $f >> /tmp/gitlist.text
echo >> /tmp/gitlist.text
done
less /tmp/gitlist.text
@rstriquer
rstriquer / easydump.sh
Last active November 23, 2023 19:40
easydump script: Make a non consistent backupUse it with MyISAM databases. Guess this works with InnoDB, didn't tried tough
#!/bin/bash
# - To restore the database you can use the command bellow which whill return the file
# whithout send any output to the screen
# mysql -h 127.0.0.1 -A -u root -e "USE db_name; \. databasefile.sql"
PROGNAME=${0##*/}
PROGVERSION=0.9.3
usage()
{
@rstriquer
rstriquer / sample_db.php
Created November 22, 2013 14:23
A simple function to connect to the database and easy the creation of php-cli type scripts with database communication demands
<?php
$dbw = NULL;
$aDatabase = array (
'host' => '',
'database' => '',
'user' => '',
'pwd' => '',
);