Skip to content

Instantly share code, notes, and snippets.

View mrcnc's full-sized avatar

Marc Cenac mrcnc

View GitHub Profile
@mrcnc
mrcnc / fepmap.html
Last active March 24, 2020 04:45
front end party 2020-03-24 value-by-alpha map
<!DOCTYPE html>
<html lang="en">
<head>
<title>Front End Party | Value-by-alpha Map</title>
<script src="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.1.1/build/ol.js"></script>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.1.1/css/ol.css"
type="text/css"
/>
@mrcnc
mrcnc / readme.md
Last active March 11, 2022 05:11
getting started with conda

getting started with conda

Download Anaconda for a hassle-free way of configuring your development environment.

Download the Python 3 version b/c Python 2 is no longer maintained

If you're wondering "Why not use virutalenv and/or pip?", Anaconda (aka conda) is built specifically for working with the data science ecosystem of languages (Python, R, Julia) and libraries (scipy, numpy, pandas, scikit-learn, plotly/matplotlib), many of which require non-Python build requirements like C/C++ and Fortran compilers.

{
"01": "Acadia",
"02": "Allen",
"03": "Ascension",
"04": "Assumption",
"05": "Avoyelles",
"06": "Beauregard",
"07": "Bienville",
"08": "Bossier",
"09": "Caddo",
@mrcnc
mrcnc / notes.md
Last active January 31, 2021 07:21
Get data from Pandora API
# https://6xq.net/pandora-apidoc/rest/

# get a csrftoken (or just make one up b/c it only matters that the cookie matches the header)
curl -I https://www.pandora.com/

# use csrftoken + credentials to get authToken
curl -X POST https://www.pandora.com/api/v1/auth/login \
-H 'Content-Type: application/json;charset=utf-8' \
-H 'X-CsrfToken: lol' \
@mrcnc
mrcnc / table_size_mysql.sql
Last active April 8, 2019 22:48
show size of database tables
-- https://dev.mysql.com/doc/refman/8.0/en/tables-table.html
SELECT
table_name,
table_rows AS num_rows,
ROUND((data_length + index_length) / 1024 / 1024) AS size_mb
FROM
information_schema.TABLES
WHERE
TABLE_SCHEMA = 'your_schema_here'
ORDER BY
@mrcnc
mrcnc / pre-commit
Last active January 25, 2019 16:51
git pre-commit hook to format terraform files
#!/usr/bin/env /bin/sh
set -e
files=$(git diff --cached --name-only --diff-filter=d)
for f in $files
do
if [ -e "$f" ] && [[ $f == *.tf ]]; then
printf "Formatting $f\n"
terraform fmt -check=true $f
fi
@mrcnc
mrcnc / fp.js
Last active July 22, 2019 23:02
turn browser cookies into an array of key/value pairs (in a functional style)
// https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie
document.cookie.split(';')
.map(s => s.split('='))
.filter(a => a[0] && a[1])
// if there is a shorter, code golf way to do this, let me know
.reduce((acc, a) => { let obj = {}; obj[a[0].trim()] = a[1]; acc.push(obj); return acc }, [])
@mrcnc
mrcnc / test_500.py
Created November 26, 2018 19:53
a simple server that runs in python2 that always returns a 500 (useful for testing)
import BaseHTTPServer
HOST = "0.0.0.0"
PORT = 8000
class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(500)
self.send_header("Content-type", "text/plain")
@mrcnc
mrcnc / getting-started-clojure-macos.md
Created November 14, 2018 07:07
getting started with clojure on macos

Use homebrew!

brew install clojure
brew install leiningen
@mrcnc
mrcnc / code_review_thoughts.md
Last active January 6, 2023 23:17
Some thoughts on what to look for in a code review

Python

Use precise exception types

ValueError

General