Skip to content

Instantly share code, notes, and snippets.

View GabrielApG's full-sized avatar

Gabriel Gonçalves GabrielApG

View GitHub Profile
@GabrielApG
GabrielApG / app.js
Created March 4, 2024 00:01 — forked from joshnuss/app.js
Express.js role-based permissions middleware
// the main app file
import express from "express";
import loadDb from "./loadDb"; // dummy middleware to load db (sets request.db)
import authenticate from "./authentication"; // middleware for doing authentication
import permit from "./authorization"; // middleware for checking if user's role is permitted to make request
const app = express(),
api = express.Router();
// first middleware will setup db connection
@GabrielApG
GabrielApG / settings.json
Created February 20, 2024 02:16 — forked from diego3g/settings.json
VSCode Settings (Updated)
{
"workbench.startupEditor": "newUntitledFile",
"editor.fontSize": 14,
"editor.lineHeight": 1.8,
"javascript.suggest.autoImports": true,
"javascript.updateImportsOnFileMove.enabled": "always",
"editor.rulers": [80, 120],
"extensions.ignoreRecommendations": true,
"typescript.tsserver.log": "off",
"files.associations": {
@GabrielApG
GabrielApG / distance-sample.php
Created June 15, 2020 12:28 — forked from LucaRosaldi/distance-sample.php
PHP: Get Distance Between two Geolocated Points (lat/lon)
<?php
/* These are two points in New York City */
$point1 = array('lat' => 40.770623, 'long' => -73.964367);
$point2 = array('lat' => 40.758224, 'long' => -73.917404);
$distance = getDistanceBetweenPoints($point1['lat'], $point1['long'], $point2['lat'], $point2['long']);
foreach ($distance as $unit => $value) {
echo $unit.': '.number_format($value,4).'<br />';
}
@GabrielApG
GabrielApG / Gulpfile.js
Created May 8, 2020 21:11 — forked from ddprrt/Gulpfile.js
Gulp: Grabbing JavaScript assets from a CDN to add to your build pipeline
var gulp = require('gulp');
var source = require('vinyl-source-stream');
var request = require('request');
var merge = require('merge2');
var concat = require('gulp-concat');
var buffer = require('gulp-buffer');
/**
* 1. We request the latest jQuery version from the jQuery CDN. The
* request package allows for streaming. What we get in return
@GabrielApG
GabrielApG / ajax.js
Created March 2, 2020 20:50 — forked from jasonhinkle/ajax.js
jQuery AJAX Snippet
$.ajax({
url: 'api/url',
method: 'POST',
data: {var:'val'},
// data: JSON.stringify({var:'val'}), // send data in the request body
// contentType: "application/json; charset=utf-8", // if sending in the request body
dataType: 'json'
}).done(function(data, textStatus, jqXHR) {
// because dataType is json 'data' is guaranteed to be an object
console.log('done');
@GabrielApG
GabrielApG / default.conf
Created April 7, 2019 23:26
NGiNX Configuration for Vue-Router in HTML5 Mode
server {
listen 80 default_server;
listen [::]:80 default_server;
root /your/root/path;
index index.html;
server_name you.server.com;

Multiple MySQL Versions with Homebrew

For homebrew version 0.9.5.

brew -v # => Homebrew 0.9.5

Install the current version of mysql.

# Install current mysql version

brew install mysql

@GabrielApG
GabrielApG / dddsBrasileiros.json
Created February 22, 2019 18:05 — forked from ThadeuLuz/dddsBrasileiros.json
Objeto JSON com Estados Brasileiros por DDD e lista de DDDs por Estados.
{
"estadoPorDdd": {
"11": "SP",
"12": "SP",
"13": "SP",
"14": "SP",
"15": "SP",
"16": "SP",
"17": "SP",
"18": "SP",
@GabrielApG
GabrielApG / index.php
Created November 12, 2018 10:53
Pagamento simples com PagSeguro
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.2.5/vue.min.js"></script>
<!--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css">-->
<script src="pagseguro.js"></script>
</head>
@GabrielApG
GabrielApG / List.md
Created November 7, 2018 11:22 — forked from msurguy/List.md
List of open source projects made with Laravel

Other people's projects:

My projects (tutorials are on my blog at http://maxoffsky.com):