Skip to content

Instantly share code, notes, and snippets.

View silasrm's full-sized avatar

Silas Ribas Martins silasrm

View GitHub Profile
@silasrm
silasrm / pagination.php
Last active August 14, 2020 00:38
Paginação com PHP e MySQL puro com slider com padrõa bootstra 4
<?php
$currentPage = $_SERVER["PHP_SELF"];
$maxRows = 15;
$pageNum = 1;
if (isset($_GET['page'])) {
$pageNum = $_GET['page'];
}
$startRow = ($pageNum - 1) * $maxRows;
@silasrm
silasrm / TimeAgo.js
Last active July 7, 2020 12:47
A vue-timeago (https://github.com/egoist/vue-timeago/) version using luxon
// directives/TimeAgo.js
import DateTime from 'luxon/src/datetime.js';
/**
* Need Luxon https://moment.github.io/luxon/
* @usage import Timeago from '../directives/TimeAgo';
Vue.use(Timeago, {locale: 'pt-BR'}); // or Vue.use(Timeago);
* @param opts
*/
@silasrm
silasrm / pubspec.yaml
Last active June 7, 2020 20:00
Manager storage data on json file
dependencies:
path_provider: ^1.6.10
@silasrm
silasrm / readme.md
Created January 14, 2020 03:53
Removendo tipos de arquivos em subpastas

Removendo tipos de arquivos em subpastas

Na AWS

Usando o cli da AWS:

aws s3 ls s3://bucket/pasta/ | awk {'print "aws s3 rm s3://bucket/pasta/" $2 " --recursive --exclude \"*\" --include \"chamada*.mp3\" --include \"nome*.mp3\""'} | bash

  • aws s3 ls s3://bucket/pasta/ lista as subpastas
  • awk {'print "aws s3 rm s3://bucket/pasta/" $2 " --recursive --exclude "" --include "chamada.mp3" --include "nome*.mp3""'} monta o comando
@silasrm
silasrm / php-pools.md
Created October 17, 2019 13:07 — forked from holmberd/php-pools.md
Adjusting child processes for PHP-FPM (Nginx)

Adjusting child processes for PHP-FPM (Nginx)

When setting these options consider the following:

  • How long is your average request?
  • What is the maximum number of simultaneous visitors the site(s) get?
  • How much memory on average does each child process consume?

Determine if the max_children limit has been reached.

  • sudo grep max_children /var/log/php?.?-fpm.log.1 /var/log/php?.?-fpm.log
@silasrm
silasrm / get-video-thumbnail.php
Created June 17, 2019 01:32 — forked from secretstache/get-video-thumbnail.php
Get Video Thumbnail from Youtube or Vimeo
<?php
/**
* Retrieves the thumbnail from a youtube or vimeo video
* @param - $src: the url of the "player"
* @return - string
* @todo - do some real world testing.
*
**/
function get_video_thumbnail( $src ) {
function get_vimeoid( $url ) {
$regex = '~
# Match Vimeo link and embed code
(?:<iframe [^>]*src=")? # If iframe match up to first quote of src
(?: # Group vimeo url
https?:\/\/ # Either http or https
(?:[\w]+\.)* # Optional subdomains
vimeo\.com # Match vimeo.com
(?:[\/\w:]*(?:\/videos)?)? # Optional video sub directory this handles groups links also
\/ # Slash before Id
@silasrm
silasrm / get-zap-contacts-and-download-csv.js
Last active December 28, 2022 18:50
Run this code in developer tools from Whatsapp Web. Get contacts phone number using image profile URL
// @gist https://gist.github.com/silasrm/2f5e87926d08ce21e25c1aed5b9ffae9
// Get contacts phone number using image profile URL
var script = document.createElement('script');script.src = "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js";document.getElementsByTagName('head')[0].appendChild(script);
var csvData = [];
var uniqueArray = function(arrArg) {
return arrArg.filter(function(elem, pos,arr) {
return arr.indexOf(elem) == pos;
});
import requests
from requests.auth import HTTPBasicAuth
import argparse
from getpass import getpass
"""
@origin https://gist.github.com/cdefgah/35f127fe39b1ebf2caa2d53d675f1019#file-revokeaccesstounwantedbitbucketrepository-py
@author silasrm <[email protected]>
In some cases you may want to remove yourself from a different user's private repository in bitbucket.
@silasrm
silasrm / fields_form.js
Created February 1, 2018 17:41
Get fields from form
$('#requerimentoCurriculo input, #requerimentoCurriculo select').each(
function(index){
var input = $(this);
console.log('Name: ' + input.attr('name') + ' | Type: ' + (!!input.attr('type') ? input.attr('type') : 'select') + ' | Value: ' + input.val());
}
);
$('#requerimento input, #requerimento select').each(
function(index){
var input = $(this);