Skip to content

Instantly share code, notes, and snippets.

View d-schmidt's full-sized avatar
🏠
Coding from home

David Schmidt d-schmidt

🏠
Coding from home
  • Germany
View GitHub Profile
@d-schmidt
d-schmidt / redirectExample.go
Last active March 12, 2024 08:04
How to redirect HTTP to HTTPS with a golang webserver.
package main
import (
"net/http"
"log"
)
func redirect(w http.ResponseWriter, req *http.Request) {
// remove/add not default ports from req.Host
target := "https://" + req.Host + req.URL.Path
if len(req.URL.RawQuery) > 0 {
@d-schmidt
d-schmidt / chrome_history_clean.py
Created January 16, 2017 14:52
Cleaning the Chrome browser history with Python
#!/usr/bin/env python3
import sqlite3
import re
# find your 'History' file
conn = sqlite3.connect('c:/Users/username/AppData/Local/Google/Chrome/User Data/Default/History')
c = conn.cursor()
print("history length", c.execute('SELECT count(1) FROM urls').fetchone()[0])
@d-schmidt
d-schmidt / gist:ad821748cdcbb128ea365ba32a365389
Created January 22, 2020 16:56
how to disable nvidia ansel
can't uninstall, only deactivate
find
c:\Windows\System32\DriverStore\FileRepository\nv_dispi.inf_amd64_d223212c0a2275b5\NvCamera\
in admin cmd:
NvCameraEnable.exe off
@d-schmidt
d-schmidt / refreshToken.py
Last active November 15, 2021 04:51
request a praw reddit oauth authcode and refresh token
#!/usr/bin/env python3
import sys
import http.server
from urllib.parse import urlparse
import praw
import time
"""
https://github.com/reddit/reddit/wiki/API
http://praw.readthedocs.io/en/latest/getting_started/authentication.html
@d-schmidt
d-schmidt / rangemap.go
Last active May 4, 2021 06:06
Simple golang RangeMap implementation for sorted, not overlapping ranges of integers (like IP address ranges). Elements are found using binary search.
package main
import (
"fmt"
"sort"
)
type Range struct {
L int
U int
@d-schmidt
d-schmidt / raspberry-pi-zero_as_webcam.md
Last active February 7, 2021 13:58 — forked from justinschuldt/raspberry-pi-zero_as_webcam.md
Directions for setting up a RaspberryPi 4 to act as a generic USB webcam

hardware/software

Webcam parts:

  • Raspberry Pi 4
  • Raspberry Pi High Quality Camera (12.3-megapixel)
  • Raspbian Buster Lite 2021-01-11

Webcam works with:

  • Windows 10
  • Windows 10 "Camera" app
  • Google Hangouts via Chrome
@d-schmidt
d-schmidt / chrome.js
Last active February 4, 2021 12:30
clear current (filtered) chrome history page using F12 console
// copy paste and enter to clear current page
for (i = 0; i < 150;i++) document.getElementById("checkbox-" + i).checked = true;
document.getElementById("remove-selected").disabled = false;
document.getElementById("remove-selected").click();
document.getElementById("alertOverlayOk").click();
@d-schmidt
d-schmidt / read-google-play-music-playlist-to-csv.js
Last active November 8, 2020 12:34
How to convert a Google Play Music Playlist to CSV
// open playlist or album
// paste this into the console in dev tools (F12) of browser:
var seenSongs = {};
var seenSongTitles = {};
var playlistTable = document.querySelectorAll('.song-table tbody')[0];
function printSongs() {
let playlist = playlistTable.querySelectorAll('tr.song-row');
for(let i = 0; i < playlist.length; i++) {
let l = playlist[i];
import csv
import requests
import glob
# Quick and dirty script to convert a CSV file of album names to a Spotify playlist
SEARCH = "https://api.spotify.com/v1/search"
ALBUMS = "https://api.spotify.com/v1/albums"
AUTH = "Bearer xxxxxxxx" # Fill in with OAUTH token
PLAYLIST = "https://api.spotify.com/v1/users/xxxx/playlists/xxxxxxxx/tracks" # fill in
@d-schmidt
d-schmidt / SimpleAuthServer.py
Last active May 3, 2019 19:36 — forked from fxsjy/SimpleAuthServer.py
SimpleAuthServer: A IPv6 Python 3 SimpleHTTPServer with authentication
import base64
from http.server import HTTPServer
from http.server import SimpleHTTPRequestHandler
import socket
key = base64.b64encode(b"user:password")
class HTTPServerV6(HTTPServer):
address_family = socket.AF_INET6