Skip to content

Instantly share code, notes, and snippets.

@diriver63
diriver63 / pyodbc-unixODBC-lambda-layer
Last active April 28, 2024 19:35
pyodbc and unixODBC for MSSQL as a lambda layer
# use https://github.com/lambci/docker-lambda to simulate a lambda environment
docker run -it --rm --entrypoint bash -e ODBCINI=/opt/odbc.ini -e ODBCSYSINI=/opt/ lambci/lambda:build-python3.7
# download and install unixODBC
# http://www.unixodbc.org/download.html
curl ftp://ftp.unixodbc.org/pub/unixODBC/unixODBC-2.3.7.tar.gz -O
tar xzvf unixODBC-2.3.7.tar.gz
cd unixODBC-2.3.7
./configure --sysconfdir=/opt --disable-gui --disable-drivers --enable-iconv --with-iconv-char-enc=UTF8 --with-iconv-ucode-enc=UTF16LE --prefix=/opt
@mazzma12
mazzma12 / kml_io.py
Last active February 22, 2024 17:01
IO / Read and write KML file with geopandas and fiona driver
import fiona
import geopandas as gpd
# Enable fiona driver
gpd.io.file.fiona.drvsupport.supported_drivers['KML'] = 'rw'
# Read file
df = gpd.read_file(path, driver='KML')
# Write file
@Sunlighter
Sunlighter / README.md
Last active August 28, 2023 20:35
Installing Python 3.7 in Amazon Linux 2

Installing Python 3.7 in Amazon Linux 2

This is a way to build Python 3.7 from source and temporarily install it in Amazon Linux 2 without overwriting the system Python and without interfering with the Python in amazon-linux-extras.

At the time of this writing, Amazon Linux 2 offers Python 2.7.14 and (through the extras) Python 3.6.2, but Python 3.7.0 was just released.

  1. Start Amazon Linux 2 and sign in. (I recommend a c5.large instance.)
@iam1980
iam1980 / windows10_bashrc
Created June 10, 2017 09:33
.bashrc windows 10
LS_COLORS='rs=0:di=1;35:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*
@oinopion
oinopion / read-access.sql
Created October 5, 2016 13:00
How to create read only user in PostgreSQL
-- Create a group
CREATE ROLE readaccess;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO readaccess;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess;
-- Grant access to future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess;
@jgravois
jgravois / commands.md
Last active March 22, 2016 16:46
get out of jail git commands

use these commands VERY carefully!

$ git checkout filename.txt

blows away whatever changes you've made to a tracked file and replaces the file with what was present in the most recent commit

$ git reset --hard HEAD

forcefully rewinds you to the most recent commit, blowing away all uncommitted changes you've made locally

$ git reset --hard f772f4 (sha)

same as above, but allows you to rewind to a specific named commit (via its SHA)

@mplewis
mplewis / flask-uwsgi-nginx-primer.md
Last active October 24, 2022 19:20
Flask + uWSGI + nginx Primer. I've been having trouble with serving a Flask app via uWSGI and nginx, so I thought I'd put together some of the basics to help out others.

Flask + uWSGI + nginx Primer

I've been having trouble with serving a Flask app via uWSGI and nginx, so I thought I'd put together some of the basics to help out others.

How this shit works

  • Flask is managed by uWSGI.
  • uWSGI talks to nginx.
@mihkels
mihkels / 1-req.sh
Last active October 24, 2022 19:20
Ubuntu 12.04 with flask + nginx + uwsgi
#!/bin/bash
sudo apt-get update
# Now let's install all the required ubuntu packages
sudo apt-get install build-essential uwsgi nginx uwsgi-plugin-python python-pip
# PS! If you are doing this stuff for fun I do recommend to install nginx from PPA repository
# that you can find here https://launchpad.net/~nginx/+archive/development