Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris Diana chrisdiana

View GitHub Profile
View flexbox-cheatsheet.md

Display: Flex

Makes container use flex

#container {  display: flex;}

Flex Direction

column, row-reverse and column-reverse

@chrisdiana
chrisdiana / simple-http-server.py
Created Dec 23, 2020
Simple Python HTTP Server
View simple-http-server.py
#!/usr/bin/env python3
"""
Very simple HTTP server in python for logging requests
Usage::
./server.py [<port>]
"""
from http.server import BaseHTTPRequestHandler, HTTPServer
import logging
class S(BaseHTTPRequestHandler):
View Makefile
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
View redis-cluster-setup.md

Redis cluster setup

In order to setup redis cluster. We will need 3 redis instances.

  • 1 master
  • 2 slaves

redis-cluster folder structure

├── master ── redis.conf , sentinel.conf , redis-server
├── slave1 ── redis.conf , sentinel.conf , redis-server
View redis-cheetsheet.md

Redis

Set record

SET foo bar

Get record

GET foo
@chrisdiana
chrisdiana / python-application-structures.md
Last active Jul 8, 2021
Python Application Structures
View python-application-structures.md

One-Off Script

helloworld/
│
├── .gitignore
├── helloworld.py
├── LICENSE
├── README.md
├── requirements.txt
@chrisdiana
chrisdiana / amazon_linux_ec2_starter.sh
Last active Sep 7, 2021
Amazon Linux EC2 Starter
View amazon_linux_ec2_starter.sh
sudo yum update -y
sudo yum install -y tmux vim docker htop wget git w3m python3 htop curl
sudo service docker start
sudo usermod -a -G docker ec2-user
sudo pip3 install virtualenv
virtualenv -p python3 venv
aws configure
sudo systemctl enable docker
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
. ~/.nvm/nvm.sh
@chrisdiana
chrisdiana / docker-builds.sh
Last active Feb 15, 2022
Install Docker Amazon Linux
View docker-builds.sh
export DOCKER_BUILDKIT=1
docker build --platform=local -o . git://github.com/docker/buildx
mkdir -p ~/.docker/cli-plugins
mv buildx ~/.docker/cli-plugins/docker-buildx
chmod a+x ~/.docker/cli-plugins/docker-buildx
docker run --privileged --rm tonistiigi/binfmt --install all
docker buildx ls
@chrisdiana
chrisdiana / example.py
Last active Oct 6, 2020
Data Pipeline Function in Python
View example.py
import pandas as pd
data = {'col1': [1, 2, 2], 'col2': [3, 4, 5], 'col3': [1, 2, 3]}
df = pd.DataFrame(data)
def clean(df):
return df[['col1', 'col2']]
def equals_2(df, col):
View progress-dd.sh
sudo apt-get install pv
sudo dd if=/dev/disk2 | sudo pv -s 128G | sudo dd of=~/sd.bin bs=4096
dd if=/dev/urandom | pv | dd of=/dev/null