Skip to content

Instantly share code, notes, and snippets.

View erick-otenyo's full-sized avatar
🧭
Focusing

Erick Otenyo erick-otenyo

🧭
Focusing
View GitHub Profile
@PhilipSchmid
PhilipSchmid / minio-upload.sh
Created November 19, 2020 13:38
Upload data to Minio using CURL
#!/bin/bash
# Usage: ./minio-upload my-bucket my-file.zip
bucket=$1
file=$2
host=minio.example.com
s3_key=svc_example_user
s3_secret=svc_example_user_password
@chriswhong
chriswhong / README.md
Created February 28, 2020 17:55
Using ogr2ogr to load a CSV into Postgres

The absolute easiest way to get a CSV into a postgresql table is to use ogr2ogr with AUTODETECT_TYPE=YES.

I learned a while back that this is what cartoDB uses to import your CSV into postgis (with a lot of other parameters added)

ogr2ogr -f PostgreSQL PG:"host=localhost user=postgres dbname=postgres password=password"  docs.csv -oo AUTODETECT_TYPE=YES
@chriswhong
chriswhong / gist:762ceac7fb8a1420e7e7adceb770b707
Last active March 3, 2022 09:01
Using ST_AsMVT() and ST_AsMVTGeom() in express to build a vector tile endpoint
/* GET /tiles/:z/:x/:y.mvt */
/* Retreive a vector tile by tileid */
router.get('/tiles/:z/:x/:y.mvt', async (req, res) => {
const { z, x, y } = req.params;
// calculate the bounding polygon for this tile
const bbox = mercator.bbox(x, y, z, false);
// Query the database, using ST_AsMVTGeom() to clip the geometries
// Wrap the whole query with ST_AsMVT(), which will create a protocol buffer
@martinsvoboda
martinsvoboda / nospaces.py
Last active April 9, 2020 09:21
Django template custom tag nospace - Removes whitespace inside tags and text
import re
from django.utils.encoding import force_text
from django.template import Library, Node
register = Library()
def strip_spaces_in_tags(value):
@rmdort
rmdort / react-modal-portal.js
Created April 17, 2018 14:20
Simple react modal using portals
import React from 'react'
import PropTypes from 'prop-types'
import ReactDOM from 'react-dom'
import cx from 'classnames'
const TAB_KEY = 9
const ESC_KEY = 27
const FOCUSABLE_ELEMENTS = ['INPUT', 'BUTTON', 'SELECT', 'TEXTAREA', 'A']
class ModalPortal extends React.Component {
@arbennett
arbennett / nc_to_gtiff.py
Created June 27, 2017 18:11
Workflow for uploading data from netcdf to google earth engine
#!/usr/bin/env python2
"""
Script that allows for conversion of a netcdf file to
a stack of geotiff files with each raster being a time
slice from the input file.
Base implementation taken from:
https://www.linkedin.com/pulse/convert-netcdf4-file-geotiff-using-python-chonghua-yin
Usage:
@rveciana
rveciana / .block
Last active February 6, 2023 19:26
Smooth GeoTIFF drawing with D3js
license: mit
@rudyryk
rudyryk / post-receive
Last active May 23, 2022 16:00
Git post-receive hook sample for basic Django project
#!/usr/bin/env python
#
# No Rights Reserved
# http://creativecommons.org/publicdomain/zero/1.0/
"""Git post-receive hook script
Suggested project structure::
/home/$_USER/
env/
@Nilpo
Nilpo / Using Git to Manage a Live Web Site.md
Last active April 26, 2024 19:09
Using Git to Manage a Live Web Site

Using Git to Manage a Live Web Site

Overview

As a freelancer, I build a lot of web sites. That's a lot of code changes to track. Thankfully, a Git-enabled workflow with proper branching makes short work of project tracking. I can easily see development features in branches as well as a snapshot of the sites' production code. A nice addition to that workflow is that ability to use Git to push updates to any of the various sites I work on while committing changes.

Contents

@joshnuss
joshnuss / app.js
Last active March 4, 2024 00:01
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