Skip to content

Instantly share code, notes, and snippets.

View Hellowlol's full-sized avatar

Steffen Fredriksen Hellowlol

  • Kristiansand, Norway
View GitHub Profile
@colemar
colemar / #wg-peer.md
Last active April 20, 2024 20:55
Manage Wireguard peers (IPv4 only)

Manage Wireguard peers (IPv4 only)

List, add or delete Wireguard peers. Also show client configuration for already added peers.

wg-peer [add|show <peer>|del <peer>|list]

where:

  • a[dd] add a new peer
@tonybaloney
tonybaloney / app.py
Last active March 25, 2024 23:52
FastAPI with OpenTelemetry
from azure.monitor.opentelemetry.exporter import AzureMonitorTraceExporter
from fastapi import FastAPI, Request
from fastapi.responses import JSONResponse
from opentelemetry.context import get_current as get_current_context
from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor
from opentelemetry.sdk.trace import TracerProvider, _Span
from opentelemetry.sdk.trace.export import (BatchSpanProcessor,
ConsoleSpanExporter,
SimpleSpanProcessor)
from starlette.exceptions import HTTPException as StarletteHTTPException
@DevSusu
DevSusu / 1-setup.sh
Last active April 19, 2024 17:29
Setup Apache, LetsEncrypt, Vsftpd for multiple domain, multiple users (Ubuntu 18.04)
# reference
# ubuntu, php
# https://websiteforstudents.com/apache2-with-php-7-1-support-on-ubuntu-18-04-lts-beta-server/
# apache
# https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-ubuntu-18-04
# https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-18-04
# vsftpd
@balloob
balloob / example_options_flow.diff
Created August 15, 2019 20:21
Example options flow
diff --git a/homeassistant/components/unifi/config_flow.py b/homeassistant/components/unifi/config_flow.py
index e5a8965df..06751ed6e 100644
--- a/homeassistant/components/unifi/config_flow.py
+++ b/homeassistant/components/unifi/config_flow.py
@@ -2,6 +2,7 @@
import voluptuous as vol
from homeassistant import config_entries
+from homeassistant.core import callback
from homeassistant.const import (
@joncutrer
joncutrer / scapy-arp-listener.py
Last active July 21, 2020 00:08
This script listens for ARP request packets using scapy to learn the IP and Mac Address of LAN hosts. Learn more about this script at https://jcutrer.com/python/scapy-arp-listener
#!/usr/bin/env python3
"""scapy-arp-listener.py
Listen for arp packets using scapy to learn the IP and Mac Address of LAN hosts
Copyright (C) 2018 Jonathan Cutrer
License Dual MIT, 0BSD
"""
@kauffmanes
kauffmanes / install_anaconda.md
Last active May 6, 2024 02:02
Install Anaconda on Windows Subsystem for Linux (WSL)

Thanks everyone for commenting/contributing! I made this in college for a class and I no longer really use the technology. I encourage you all to help each other, but I probably won't be answering questions anymore.

This article is also on my blog: https://emilykauffman.com/blog/install-anaconda-on-wsl

Note: $ denotes the start of a command. Don't actually type this.

Steps to Install Anaconda on Windows Ubuntu Terminal

  1. Install WSL (Ubuntu for Windows - can be found in Windows Store). I recommend the latest version (I'm using 18.04) because there are some bugs they worked out during 14/16 (microsoft/WSL#785)
  2. Go to https://repo.continuum.io/archive to find the list of Anaconda releases
  3. Select the release you want. I have a 64-bit computer, so I chose the latest release ending in x86_64.sh. If I had a 32-bit computer, I'd select the x86.sh version. If you accidentally try to install the wrong one, you'll get a warning in the terminal. I chose `Anaconda3-5.2.0-Li
@kellerza
kellerza / oauth2_session.py
Last active March 23, 2023 10:39
OAuth2 authentication with aiohttp and oauthlib (based on requests_oauthlib)
"""OAuth2Support for aiohttp.ClientSession.
Based on the requests_oauthlib class
https://github.com/requests/requests-oauthlib/blob/master/requests_oauthlib/oauth2_session.py
"""
# pylint: disable=line-too-long,bad-continuation
import logging
from oauthlib.common import generate_token, urldecode
from oauthlib.oauth2 import WebApplicationClient, InsecureTransportError
@rene-d
rene-d / colors.py
Last active May 1, 2024 17:50
ANSI color codes in Python
# SGR color constants
# rene-d 2018
class Colors:
""" ANSI color codes """
BLACK = "\033[0;30m"
RED = "\033[0;31m"
GREEN = "\033[0;32m"
BROWN = "\033[0;33m"
BLUE = "\033[0;34m"
@mohit-0212
mohit-0212 / read_audio.py
Created February 23, 2018 22:13
Analysing audio signals of a video
import subprocess
import numpy as np
import scipy
import librosa
import matplotlib.pyplot as plt
file_input = "/path for/video file/"
file_output = "/path for/output audio file.wav/"
command = "ffmpeg -i " + file_input +" -t 300 -codec:a pcm_s16le -ac 1 "+ file_output #converts the first 5 minutes of video file to wav output
@mohit-0212
mohit-0212 / read_video.py
Created February 23, 2018 21:54
Detecting intro from video frames
import cv2
import numpy as np
import matplotlib.pyplot as plt
vid_frame = cv2.VideoCapture('/path for/video file/')
length = vid_frame.get(cv2.CAP_PROP_FRAME_COUNT)
fps = vid_frame.get(cv2.CAP_PROP_FPS)
num_frames = int(fps*300) #number of frames in first 5 minutes