Skip to content

Instantly share code, notes, and snippets.

View silasrm's full-sized avatar

Silas Ribas Martins silasrm

View GitHub Profile
@silasrm
silasrm / mysql-levenshtein.sql
Created December 23, 2024 17:34 — forked from Kovah/mysql-levenshtein.sql
Levenshtein function for MySQL
-- Levenshtein function
-- Source: https://openquery.com.au/blog/levenshtein-mysql-stored-function
-- Levenshtein reference: http://en.wikipedia.org/wiki/Levenshtein_distance
-- Arjen note: because the levenshtein value is encoded in a byte array, distance cannot exceed 255;
-- thus the maximum string length this implementation can handle is also limited to 255 characters.
DELIMITER $$
DROP FUNCTION IF EXISTS LEVENSHTEIN $$
CREATE FUNCTION LEVENSHTEIN(s1 VARCHAR(255) CHARACTER SET utf8, s2 VARCHAR(255) CHARACTER SET utf8)
@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
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 / Laravel PHP7 LEMP AWS.md
Created June 21, 2017 15:04 — forked from santoshachari/Laravel PHP7 LEMP AWS.md
Laravel 5.x on Ubuntu 16.x, PHP 7.x, Nginx 1.9.x

#Steps to install latest Laravel, LEMP on AWS Ubuntu 16.4 version. This tutorial is the improvised verision of this tutorial on Digitalocean based on my experience.

Install PHP 7 on Ubuntu

Run the following commands in sequence.

sudo apt-get install -y language-pack-en-base
sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install zip unzip
@silasrm
silasrm / WSSoapClient.php
Created June 9, 2017 18:24 — forked from Turin86/WSSoapClient.php
WS-Security for PHP SoapClient
<?php
/**
* This class can add WSSecurity authentication support to SOAP clients
* implemented with the PHP 5 SOAP extension.
*
* It extends the PHP 5 SOAP client support to add the necessary XML tags to
* the SOAP client requests in order to authenticate on behalf of a given
* user with a given password.
*
@silasrm
silasrm / gist:3da655045b899a858eae4f4463755f5c
Last active January 31, 2023 16:03 — forked from maccath/gist:3981205
Split PDF to individual pages using FPDI and FPDF
<?php
/**
* Split PDF file
*
* <p>Split all of the pages from a larger PDF files into
* single-page PDF files.</p>
*
* @package FPDF required http://www.fpdf.org/
* @package FPDI required http://www.setasign.de/products/pdf-php-solutions/fpdi/
@silasrm
silasrm / blink.css
Created February 25, 2017 19:44 — forked from mugifly/blink.css
CSS Blink for Webkit and others. (Chrome, Safari, Firefox (Gecko), IE, ...) CSSで擬似的なblinkを再現する簡単なTips。
<?php
/*
Plugin Name: bbPress - Custom KSES Allowed Tags
Plugin URI: https://gist.github.com/ntwb/7797990
Description: bbPress - Custom KSES Allowed Tags
Version: 0.2
Author: Stephen Edgar - Netweb
Author URI: http://netweb.com.au
*/