Skip to content

Instantly share code, notes, and snippets.

View chbrandt's full-sized avatar

Carlos H Brandt chbrandt

View GitHub Profile
@chbrandt
chbrandt / myserver.py
Created May 16, 2024 16:34
Recurse Center Database Server code sample
"""
RC Database Server code sample
> Before your interview, write a program that runs a server that is accessible
> on `http://localhost:4000/`. When your server receives a request
> on `http://localhost:4000/set?somekey=somevalue` it should store
> the passed key and value in memory. When it receives a request
> on `http://localhost:4000/get?key=somekey` it should return
> the value stored at `somekey`.
> During your interview, you will pair on saving the data to a file.
@chbrandt
chbrandt / world.geojson
Created February 5, 2024 10:36
World countries GeoJSON
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@chbrandt
chbrandt / africa.geojson
Created February 4, 2024 20:18
Africa GeoJSON
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@chbrandt
chbrandt / gist:345968d578e89f9ad39451bee4c7888d
Created February 4, 2024 16:36
Rovers landing sites Mars
{
"type": "FeatureCollection",
"features": [
{ "type": "Feature", "properties": { "index": "0", "Name": "Viking 2", "Space Agency": "NASA", "Type": "Lander", "Travel distance (km)": null, "Launch Date": "1975-09-09", "Landing Date": "1976-09-03", "Region": "Utopia Planitia", "Min Lat": 46.84, "Max Lat": 48.46, "Min Lon": 133.36, "Max Lon": 135.07, "Landing Lat": 47.643, "Landing Lon": 134.28799438476562, "Elevation": -4495.0, "Status": "Not Active" }, "geometry": { "type": "Point", "coordinates": [ 134.287994384765625, 47.643 ] } },
{ "type": "Feature", "properties": { "index": "1", "Name": "Perseverance", "Space Agency": "NASA", "Type": "Rover", "Travel distance (km)": 0.2, "Launch Date": "2020-07-30", "Landing Date": "2021-02-18", "Region": "Jazero Crater", "Min Lat": 17.9, "Max Lat": 19.13, "Min Lon": 76.92, "Max Lon": 78.32, "Landing Lat": 18.4386, "Landing Lon": 77.503097534179688, "Elevation": -2640.0, "Status": "Active" }, "geometry": { "type": "Point", "coordinates": [ 77.503097534179688, 18.4386 ] }
@chbrandt
chbrandt / ipython-0.0.1.py
Created November 8, 2023 11:03 — forked from fperez/ipython-0.0.1.py
IPython 0.0.1, a simple script to be loaded as $PYTHONSTARTUP: of historical interest only...
#!/usr/bin/env python
"""
Interactive execution with automatic history, tries to mimic Mathematica's
prompt system. This environment's main features are:
- Numbered prompts (In/Out) similar to Mathematica. Only actions that produce
output (NOT assingments, for example) affect the counter and cache.
- The following GLOBAL variables always exist (so don't overwrite them!):
_p: stores previous result which generated printable output.
@chbrandt
chbrandt / 3D_image_view_with_matplotlib.md
Created August 11, 2023 14:19
Maplotlib 3D plot of image used in the Carpentries Image-Processing episode.
@chbrandt
chbrandt / git-check.sh
Created February 9, 2023 09:49
Check all Git repositories in the (current or given) directory
#!/bin/bash -ue
# This is script is meant to be sourced:
# > source git-check.sh
#
# It defines an equally named function 'git-check' that accepts one argument:
# - the path to where git repositories live in your system.
# If none is given, the current working directory ($PWD) is used.
#
# Example:
@chbrandt
chbrandt / onedrive.sh
Created October 6, 2021 08:47
OneDrive docker container script
#!/bin/bash
# Use docker container from https://github.com/abraunegg/onedrive
# Detailed instructions at https://github.com/abraunegg/onedrive/blob/master/docs/Docker.md
ONEDRIVE_DATA_DIR="${HOME}/OneDrive"
ONEDRIVE_UID=`id -u`
ONEDRIVE_GID=`id -g`
mkdir -p ${ONEDRIVE_DATA_DIR} &> /dev/null
@chbrandt
chbrandt / clean_bashrc.sh
Created May 19, 2021 16:28
Clean Conda init from bashrc
#!/bin/bash
awk '/>>> conda initialize >>>/ {p=1}; /<<< conda initialize <<</ {p=0; next}; {if (p==0) print $0}' .bashrc
@chbrandt
chbrandt / database_server.py
Last active February 26, 2021 21:21
Database Server exercise
from http.server import HTTPServer, ThreadingHTTPServer, BaseHTTPRequestHandler
from urllib.parse import urlparse, parse_qs
# Dictionary-db storing user key-value pairs.
#
_db = {}
_database_file = '/tmp/dataserver.txt'