Skip to content

Instantly share code, notes, and snippets.

View Maykonn's full-sized avatar
🎯
Focusing

Maykonn Welington Maykonn

🎯
Focusing
View GitHub Profile
<?php
$currency_symbols = array(
'AED' => '&#1583;.&#1573;', // ?
'AFN' => '&#65;&#102;',
'ALL' => '&#76;&#101;&#107;',
'AMD' => '',
'ANG' => '&#402;',
'AOA' => '&#75;&#122;', // ?
'ARS' => '&#36;',
'AUD' => '&#36;',
@Maykonn
Maykonn / how-to-enable-cors-in-laravel-5.0.md
Last active August 29, 2015 14:16
How to enable CORS in Laravel 5.0?

Is common a [CORS][1] message when accessing a Laravel Application (or better, an Laravel API), resource via another client application (an Angular.js, Backbone.js, Ember.js, or a PHP, JS, Java, Mobile, app, whatever).

To enable CORS in your Laravel application, create a route group and put inside, all routes that you need to enable CORS:

<?php
Route::group(['after' => 'allowOrigin'], function() {
    // Your fantastic resources
    Route::post('/users', function () {  // ... });
    // ...
});
@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/

SIMPLE WEBRTC VIDEO CHAT USING PEERJS

Operating System Ubuntu 14.04 via Koding.com

Install node.js

sudo apt-get update
sudo apt-get install nodejs

Check node.js version

@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 / 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 / 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 / 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 / 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>
@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,