Skip to content

Instantly share code, notes, and snippets.

@miguelpeixe
miguelpeixe / backup.sh
Created March 7, 2018 14:58
PG backups in Rancher
#!/bin/bash
date="$(date -I)"
timestamp="$(date +%s)"
origin="/nfs/accessible/postgresql/data/backups"
target="/final/backup/destination/path"
rancherContainer="1s203"
filename="db-$(date +%H).sql.gz"
echo "--------"
@miguelpeixe
miguelpeixe / index.html
Last active November 15, 2017 12:48
Medialab Prado 1km radius map
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Liane Madrid Map</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.2.0/leaflet.css" integrity="sha256-LcmP8hlMTofQrGU6W2q3tUnDnDZ1QVraxfMkP060ekM=" crossorigin="anonymous" />
<style>
html, body, #map { width: 100%; height: 100%; margin: 0; padding: 0; }
</style>
</head>
@miguelpeixe
miguelpeixe / index.js
Last active November 9, 2017 10:36
React Axios Search Example
# On backend
app.use('/searchInterests', function(req, res) {
const token = app.get('fbAppToken');
if(req.query.q) {
app.facebook.api('search', {
type: 'adinterest',
q: req.query.q,
access_token: token,
locale: 'en_US'
@miguelpeixe
miguelpeixe / README.md
Last active November 7, 2017 17:23
LIANE dev environment
@miguelpeixe
miguelpeixe / index.js
Last active March 5, 2018 08:48
Express raw body for Facebook Hub Signature validation
const express = require('express');
const bodyParser = require('body-parser');
const crypto = require('crypto');
const app = express();
// Use json body parser when content is `application/json` type and request headers does not include `x-hub-signature`
app.use(bodyParser.json({
type: req => req.headers['content-type'] == 'aplication/json' && !req.headers['x-hub-signature']
}));
// Use raw body parser when headers include `x-hub-signature`
@miguelpeixe
miguelpeixe / README.md
Last active August 8, 2017 20:40
WordPress: Queries padrões por post type definidos via classe

Como está agora:

No arquivo archive-{post-type}.php:

<?php
  $posts_query = new WP_Query(array(
    'post_type' => 'pmc_timeline_item',
    'posts_per_page' => -1,
    'meta_key' => 'start_date',

Keybase proof

I hereby claim:

  • I am miguelpeixe on github.
  • I am miguelpeixe (https://keybase.io/miguelpeixe) on keybase.
  • I have a public key whose fingerprint is A998 F31A 34BB A9D2 C4DE B251 3CA8 8A3C D24C 6C6E

To claim this, I am signing this object:

@miguelpeixe
miguelpeixe / README.md
Last active December 4, 2016 20:43
PostGIS Queries

Useful PostGIS Queries

Raster

Area in square meters for raster between pixels values of 4 and 6

SELECT
  SUM(
 ST_Area(
@miguelpeixe
miguelpeixe / README.md
Last active November 24, 2016 15:17
DomeGIS 0.2.0

DomeGIS 0.2.0

Atualizações da nova versão do DomeGIS

Upload de arquivos

Podem ser enviados arquivos raster (.tiff) e shapefile (compactados em .zip) para serem processados e importados na base de dados

Analysis

@miguelpeixe
miguelpeixe / .block
Last active June 8, 2016 18:24
Tile Basemaps
border: "no"
scrolling: "yes"