Skip to content

Instantly share code, notes, and snippets.

View fxcosta's full-sized avatar
:octocat:
Focusing

Felix Costa fxcosta

:octocat:
Focusing
View GitHub Profile
# extracted from http//www.naturalearthdata.com/download/110m/cultural/ne_110m_admin_0_countries.zip
# under public domain terms
country_bounding_boxes = {
'AF': ('Afghanistan', (60.5284298033, 29.318572496, 75.1580277851, 38.4862816432)),
'AO': ('Angola', (11.6400960629, -17.9306364885, 24.0799052263, -4.43802336998)),
'AL': ('Albania', (19.3044861183, 39.624997667, 21.0200403175, 42.6882473822)),
'AE': ('United Arab Emirates', (51.5795186705, 22.4969475367, 56.3968473651, 26.055464179)),
'AR': ('Argentina', (-73.4154357571, -55.25, -53.628348965, -21.8323104794)),
'AM': ('Armenia', (43.5827458026, 38.7412014837, 46.5057198423, 41.2481285671)),
@fxcosta
fxcosta / useStateWithPromise.js
Last active October 16, 2020 00:10 — forked from jeff-pal/README.md
ReactJS - Hook customizado - useState() com Promise.
import { useEffect, useRef, useCallback } from 'react';
const useStateWithPromise = (state, setState) => {
const resolverRef = useRef(null);
useEffect(() => {
if (resolverRef.current) {
resolverRef.current(state);
resolverRef.current = null;
}
@fxcosta
fxcosta / clean_code.md
Created May 11, 2020 14:28 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@fxcosta
fxcosta / deploy.php
Created April 24, 2020 22:44 — forked from ab-budaev/deploy.php
Deployer config for laravel project
<?php
namespace Deployer;
require 'recipe/laravel.php';
// Configuration
set('ssh_type', 'native');
set('ssh_multiplexing', true);
set('git_tty', true); // [Optional] Allocate tty for git on first deployment
@fxcosta
fxcosta / Laravel-Container.md
Created February 1, 2018 16:33
Laravel's Dependency Injection Container in Depth

Laravel's Dependency Injection Container in Depth

Laravel has a powerful Inversion of Control (IoC) / Dependency Injection (DI) Container. Unfortunately the official documentation doesn't cover all of the available functionality, so I decided to experiment with it and document it for myself. The following is based on Laravel 5.4.26 - other versions may vary.

Introduction to Dependency Injection

I won't attempt to explain the principles behind DI / IoC here - if you're not familiar with them you might want to read What is Dependency Injection? by Fabien Potencier (creator of the Symfony framework).

Accessing the Container

@fxcosta
fxcosta / introrx.md
Created February 26, 2017 19:36 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@fxcosta
fxcosta / multiple-3rd-party-widgets.js
Created January 7, 2017 03:02 — forked from zenorocha/multiple-3rd-party-widgets.js
Loading multiple 3rd party widgets asynchronously
(function() {
var script,
scripts = document.getElementsByTagName('script')[0];
function load(url) {
script = document.createElement('script');
script.async = true;
script.src = url;
scripts.parentNode.insertBefore(script, scripts);
import {Sql} from "../providers/Sql";
export class ExamplePage {
constructor(private sql: Sql) {
//sql.query(...);
//...
}
}
@fxcosta
fxcosta / mpdo.php
Created November 16, 2015 18:36 — forked from teslitsky/mpdo.php
OpenCart PDO Database Adapter
<?php
/**
* i changed class name as mPDO because, give me an error
*
* " Fatal error: Cannot redeclare class pdo. If this code worked without the Zend Optimizer+,
* please set zend_optimizerplus.dups_fix=1 in your php.ini "
*/
class Mpdo
{