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 / 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' => '',
);
@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 / 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
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 / 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
@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 / 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 / README.md
Last active August 4, 2022 07:47
Git command automation shell

Script for git command automation

Script to automate git day-to-day and validate of Pull Request code.

It presented some inconsistencies when used on windows (I had some problems, mainly with the command git stash).

For Linux it seems to be very functional, regardless of the installation.
@rstriquer
rstriquer / simple_mysql_procedure.sql
Created March 12, 2020 16:33
Exemplo de criação simples de procedures e funcions no mysql
DELIMITER //
DROP FUNCTION IF EXISTS `TSTE_BVASE`//
CREATE FUNCTION `TSTE_BVASE`() RETURNS TINYINT
BEGIN
DECLARE agora DATETIME;
SET agora = now();
@rstriquer
rstriquer / instalike.js
Last active November 23, 2021 09:16 — forked from jadeallencook/instalike.js
Scripts that auto likes posts on instagram via tag.
// javascript function to use on terminal.
// based on code from https://gist.github.com/jadeallencook/139a3d5f9291c2d612d91c8b8c72a755
// more to considere: https://www.youtube.com/watch?v=yM0NIZ6wbEc
// script do login: https://github.com/mateovrb/instafollow
// script feito em phyton https://www.youtube.com/watch?v=0PdIP2Q2X4U
/**
* Get element by XPath
* - Get the xpath thrught the browser and use it to select that element.
* @param string path