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)),
[HttpPost("list-grid/{externalSystemId}/{area:int}/{externalId:int}")]
[ProducesResponseType(200, Type = typeof(DataSourceResult))]
[ProducesResponseType(400)]
[ProducesResponseType(403)]
[Authorize(Policies.ViewAllComplaint)]
public DataSourceResult GetComplaintByAreaDataSource([FromBody] DataSourceRequest request, string externalSystemId, int area = -1, int externalId = -1)
{
var citizens = _unitOfWork.Citizens;
var areas = _unitOfWork.AreaOfInterests;
var occurrences = _unitOfWork.Occurrences;
@fxcosta
fxcosta / 3857to4326.sql
Created March 30, 2021 12:47
psql script to convert multipolygon 3857 format to polygon 4326 format
// SQL Server script
select m.Projection.STAsText() from Municipalities m where m.Id = 2156
// postgreSQL script
select
ST_AsText(
(ST_Dump(
ST_Transform(
ST_GeomFromText(
'MULTIPOLYGON (((-3884126.3010306959 -791883.451045178, -3884126.3010306945 -791883.45104516833, -3884126.3010306982 -791883.45104517636, -3884126.3010306959 -791883.451045178)), ((-3893236.4527932997 -800877.64490911842, -3892191.9273572848 -800025.844839543, -3890964.1567836069 -800166.86940394074, -3890308.1098329481 -799567.087032903, -3888864.2525632759 -800133.6170797341, -3888066.1494093197 -799974.048784268, -3887760.3277926128 -800355.48796048935, -3886801.3321703845 -799662.98475919117, -3886201.8417713884 -798025.13301518466, -3887020.5708114384 -797276.06510668714, -3887157.2154216631 -796221.85454990936, -3886489.2946365052 -795611.23870923941, -3885533.6696349503 -795433.01819036063, -3885276.8615179742 -794737.74445359781, -3884537.5393745154 -794944.22897379287, -3884104.8104961966 -793665.70045422565, -3884
@fxcosta
fxcosta / launch.json
Created October 20, 2020 20:05
NET Core VSCode run config
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
@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;
}
[
{
name: "Acessar empresas",
slug: "PAGE_COMPANY",
group: "Administração"
},
{
name: "listar empresas",
slug: "LIST_COMPANY",
group: "Administração"
@fxcosta
fxcosta / InputDateMask.cs
Last active November 13, 2023 16:19
Simple initial input date mask for unity inputfield eg 12/12/1995. PS: working but regex is not completly correct. PS2: Limit input char number on InputField on Inspector
using UnityEngine;
using System.Collections;
using UnityEngine.UI; // Required when Using UI elements.
using System.Text.RegularExpressions;
public class DateInputMask : MonoBehaviour
{
public UnityEngine.UI.InputField inputField;
private void Awake()
@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 / launch.json
Created May 10, 2020 21:01
vscode configs for debug asp net core app in macos/linux
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
@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