Skip to content

Instantly share code, notes, and snippets.

🏠
Coding from home

David Schmidt d-schmidt

🏠
Coding from home
  • Germany
Block or report user

Report or block d-schmidt

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@d-schmidt
d-schmidt / SimpleAuthServer.py
Last active May 3, 2019 — forked from fxsjy/SimpleAuthServer.py
SimpleAuthServer: A IPv6 Python 3 SimpleHTTPServer with authentication
View SimpleAuthServer.py
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
@d-schmidt
d-schmidt / riter.py
Created Jul 18, 2018
A random Python list iterator without shuffle using the linear congruential generator (LCG) algorithm. A pseudorandom number generator producing all numbers < len(list) with a period == len(list) is created.
View riter.py
import random
import warnings
def __prime_factors(n):
"""
https://stackoverflow.com/a/412942/6078370
Returns all the prime factors of a positive integer
"""
factors = []
d = 2
@d-schmidt
d-schmidt / parsehtml.py
Last active Jul 18, 2018
Simple HTML parsing with python requests and lxml
View parsehtml.py
import requests
import lxml.html
t = requests.get("https://www.hearthpwn.com/news/5425-final-witchwood-card-reveal-stream-live-updates").text
html = lxml.html.fromstring(t)
links = html.xpath("//span/span[@class='pretty-bg']/a")
for link in links:
print(link.get("href"))
@d-schmidt
d-schmidt / refreshToken.py
Last active Mar 19, 2017
request a praw reddit oauth authcode and refresh token
View refreshToken.py
#!/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 / OpenWithSublimeText3.cmd
Last active Feb 27, 2017 — forked from mrchief/OpenWithSublimeText2.bat
Add "Open with Sublime Text 3" to Windows Explorer Context Menu of folders
View OpenWithSublimeText3.cmd
@echo off
SET st3Path=c:\Program Files\Sublime Text 3\sublime_text.exe
rem add it for folders
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 3" /t REG_SZ /v "" /d "Open with Sublime Text 3" /f
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 3" /t REG_EXPAND_SZ /v "Icon" /d "%st3Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st3Path% \"%%1\"" /f
pause
@d-schmidt
d-schmidt / rangemap.go
Last active May 10, 2018
Simple golang RangeMap implementation for sorted, not overlapping ranges of integers (like IP address ranges). Elements are found using binary search.
View rangemap.go
package main
import (
"fmt"
"sort"
)
type Range struct {
L int
U int
@d-schmidt
d-schmidt / memo.txt
Last active Jun 5, 2018
download app apk from Android phone and install it in emulator
View memo.txt
// install and or goto adb
// download from device (usb) -d
// list full path of third party packages
adb -d shell pm list packages -f -3
// package:/data/app/com.google.android.inputmethod.japanese-1/base.apk=com.google.android.inputmethod.japanese
// download apk to path
adb -d pull /data/app/com.google.android.inputmethod.japanese-1/base.apk path/to/
@d-schmidt
d-schmidt / chrome_history_clean.py
Created Jan 16, 2017
Cleaning the Chrome browser history with Python
View chrome_history_clean.py
#!/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 / sendEmail.py
Last active Mar 3, 2017
sending text mails from python with text attachments
View sendEmail.py
#!/usr/bin/env python3
# this is python 2 and 3 compatible
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
import datetime
COMMASPACE = ', '
sender = 'sender@example.com'
@d-schmidt
d-schmidt / Bundler.java
Created Oct 14, 2016
a simple wrapper around android.os.Bundle to fluently build bundles
View Bundler.java
package pw.dschmidt.helper;
import android.os.Bundle;
public class Bundler {
private Bundle bundle;
You can’t perform that action at this time.