Skip to content

Instantly share code, notes, and snippets.

View skipperkongen's full-sized avatar

Pimin Konstantin Kefaloukos skipperkongen

View GitHub Profile
@skipperkongen
skipperkongen / plot_3d.py
Created February 21, 2022 19:23
3D plot with Pyplot
import matplotlib.pyplot as plt
import numpy as np
# https://jakevdp.github.io/PythonDataScienceHandbook/04.12-three-dimensional-plotting.html
def f(x, y):
return np.sin(np.sqrt(x ** 2 + y ** 2))
x = np.linspace(-6, 6, 30)
y = np.linspace(-6, 6, 30)
@skipperkongen
skipperkongen / shadow_prices_pulp.py
Last active November 24, 2021 12:44
Shadow prices in PuLP
import pandas as pd
import pulp as P
# Define Constraints, Solve, Print Status, Variables, Objective
model = P.LpProblem("Maximize Bakery Profits", P.LpMaximize)
R = P.LpVariable('Regular_production', lowBound=0, cat='Continuous')
J = P.LpVariable('Jumbo_production', lowBound=0, cat='Continuous')
model += 5 * R + 10 * J, "Profit"
# Adjust the constraint
@skipperkongen
skipperkongen / shadow_prices_cvxopt.py
Last active November 24, 2021 12:44
Shadow prices in CVXOPT
import cvxpy as cp
import numpy as np
# Problem data
m = 30
n = 20
np.random.seed(1)
A = np.random.randn(m, n)
b = np.random.randn(m)
@skipperkongen
skipperkongen / Dockerfile
Created November 11, 2021 16:49
Docker static HTML with nginx
FROM nginx:latest
COPY src /usr/share/nginx/html
# docker build -t try-docker-nginx-statichtml .
# docker run -p 8080:80 try-docker-nginx-statichtml
# open localhost:8080 in browser
@skipperkongen
skipperkongen / index.html
Created November 10, 2021 14:48
Template HTML page
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
@skipperkongen
skipperkongen / lazers.py
Created September 14, 2021 11:56
Lazer simulation
import simpy
import random
import statistics
env = simpy.Environment()
charger = simpy.Resource(env, 5)
class Lazer(object):
@skipperkongen
skipperkongen / kubernetes-ip-address.md
Last active July 18, 2019 19:58
Get public IP address of nodes in a Kubernetes service

Get the public IP addresses of nodes in a Kubernetes cluster:

kubectl get nodes -o wide

Get the public IP address, in an unnecessarily round-about way, of the node that a particular service is running on:

# Create an nginx deployment and service
@skipperkongen
skipperkongen / kubernetes-cheat-sheet.md
Last active July 18, 2019 18:23
Kubernetes cheat sheet

Kubernetes Cheat Sheet

Example: nginx

Run nginx:

# kubectl run web --image=nginx
kubectl create deployment web --image=nginx
@skipperkongen
skipperkongen / monitor.md
Last active July 17, 2019 19:40
Monitor network I/O on Docker container

Let's assume you have a running docker container with a webserver that serves requests. You want to see the requests and responses it receives. You can use the --net container:<id> of the docker run command.

First, you have to discover the ID of the container that you want to monitor. Use docker ps to get it.

# On host
docker ps

Keybase proof

I hereby claim:

  • I am skipperkongen on github.
  • I am skipperkongen (https://keybase.io/skipperkongen) on keybase.
  • I have a public key ASBjntm9D5V5uVtiIAogJKMeTmVedwh69aRp5p1fLzPqxQo

To claim this, I am signing this object: