Skip to content

Instantly share code, notes, and snippets.

View Maykonn's full-sized avatar
🎯
Focusing

Maykonn Welington Maykonn

🎯
Focusing
View GitHub Profile
@Maykonn
Maykonn / Maykonn-Symfony-4-Code-Style.xml
Created August 9, 2018 18:57
PHP Code Style for PHPStorm IDE based on Symfony 4 Skeleton App
<code_scheme name="Maykonn-Symfony-4-Code-Style" version="173">
<PHPCodeStyleSettings>
<option name="CONCAT_SPACES" value="false" />
</PHPCodeStyleSettings>
<codeStyleSettings language="PHP">
<option name="SPACE_AFTER_TYPE_CAST" value="true" />
</codeStyleSettings>
</code_scheme>
@Maykonn
Maykonn / twitter-request-token.php
Created January 23, 2018 12:16
Twitter Integration: Backend endpoint to request token
<?php
/**
* Twitter Integration: Backend endpoint to request token
*
* @author Maykonn Welington Candido<maykonn@outlook.com>
* @see https://developer.twitter.com/en/docs/basics/authentication/api-reference/request_token
*
* @uses This file must be requested by a application passing the callback_url on querystring. Response Content-Type is application/json.
* @example https://mydomain.com/twitter/request_token.php?callback_url=https://mydomain.com/path-to-redirect-after-request-token
*/
@Maykonn
Maykonn / maykonn-php-code-style.xml
Created January 24, 2019 12:42
PHP Code Style for PHPStorm IDE
<code_scheme name="maykonn-php-code-style" version="173">
<PHPCodeStyleSettings>
<option name="CONCAT_SPACES" value="false" />
</PHPCodeStyleSettings>
<codeStyleSettings language="PHP">
<option name="SPACE_AFTER_TYPE_CAST" value="true" />
</codeStyleSettings>
</code_scheme>
# EditorConfig for web development
#
# EditorConfig
# https://editorconfig.org
#
# Author: Maykonn Welington Candido
root = true
[*]
# @author Maykonn Welington Candido <maykonn@outlook.com>
# For docker-compose for instance you may do it in order to install the latest version on UNIX:
REPO_PATH=docker/compose
ARTIFACT_NAME=docker-compose-$(uname -s)-$(uname -m)
DOCKER_COMPOSE_VERSION=$(curl --silent "https://api.github.com/repos/$REPO_PATH/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")')
sudo curl -L "https://github.com/$REPO_PATH/releases/download/$DOCKER_COMPOSE_VERSION/$ARTIFACT_NAME" -o /usr/local/bin/docker-compose
# Change the REPO_PATH value by the desired repository path
# Change the ARTIFACT_NAME value by the name of the downloadable artifact, you can see the name on the repository release page
@Maykonn
Maykonn / earlyFatalErrorHandler.php
Last active November 4, 2019 20:43
PHP Early fatal errors handler
<?php
// Early fatal errors handler, it will be replaced by a full featured one in Controller class
// (given it does not have any parse or fatal errors of its own)
function earlyFatalErrorHandler($unregister = false)
{
// Functionality for "unregistering" shutdown function
static $unregistered;
if ($unregister) $unregistered = true;
if ($unregistered) return;
@Maykonn
Maykonn / hierarchical_parent_id_recursive_query.sql
Last active March 13, 2019 17:09
[SQL] Retrieves results in a hierarchy starting from a specific register (recursive parent_id)
/**
* Retrieves a customer group hierarchy.
* Change the @root_id value to change the hierarchy root.
*/
SET @root_id = 1;
SELECT *
FROM (
SELECT * FROM tbl
ORDER BY parent_id, id) hiearchy_sorted,
@Maykonn
Maykonn / check-if-service-is-running.sh
Last active January 24, 2019 12:44
This gist is a .sh file which test if a service is running, you may change as necessary for your needs
#!/bin/bash
local_mysql_service=mysql
if (( $(ps -ef | grep -v grep | grep ${local_mysql_service} | wc -l) > 0 ))
then
service ${local_mysql_service} stop
fi
echo "Conflicting local services stopped ($local_mysql_service), continue..."
local_apache_service=apache2
@Maykonn
Maykonn / sql-redshift-mysql-postgresql-find-string-comma-separated.md
Last active October 22, 2018 14:58
SQL search by specific string in a comma separated string (Solution for Redshift too).

Will return 0 or false:

SELECT "5,18,5,7,9,2" REGEXP "[[:<:]](8)[[:>:]]"

Will return 1 or true:

SELECT "5,18,5,7,9,2" REGEXP "[[:<:]](5)[[:>:]]"

For Redshift you must use ~ instead REGEXP on above statements:

@Maykonn
Maykonn / gist:9f135e83ab27b1c9e4fc
Last active January 23, 2018 12:18 — forked from fernandojunior/gist:0c1bcf595c16a059fc5d
Install mysql and/or workbench on ubuntu
# Install mysql server 5.6 on Ubuntu
apt-get install mysql-server-5.6
# Login into MySQL Server
mysql -uroot -p
# restart mysql server
sudo service mysql start|restart|stop|status
# http://sharadchhetri.com/2014/05/07/install-mysql-server-5-6-ubuntu-14-04-lts-trusty-tahr/