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
import random
import __future__
a = 'abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWYXZ23456789$%&()=?+#-}][{*/:<>~' #0Ol1!I
b = 'abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWYXZ23456789'
d = 'abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWYXZ23456789@#%_-&*()'
all = "".join((chr(i) for i in range(33,127)))
def doa(l = 20, chars = a):
return "".join(chars[int(random.random() * (len(chars[:-1])+1))] for i in range(l))
@d-schmidt
d-schmidt / brntool.py
Last active April 27, 2016 17:40
reading flash from Arcadyan/o2 IAD 6431 1.01.25b
#!/usr/bin/python
# -*- coding: utf-8 -*-
# see https://github.com/rvalles/brntool
#Keep python2 working
from __future__ import division #1/2 = float, 1//2 = integer
from __future__ import print_function #print("blah", file=whatever)
#Keep python2 working end
from optparse import OptionParser
import serial
import sys
@d-schmidt
d-schmidt / Bundler.java
Created October 14, 2016 21:13
a simple wrapper around android.os.Bundle to fluently build bundles
package pw.dschmidt.helper;
import android.os.Bundle;
public class Bundler {
private Bundle bundle;
@d-schmidt
d-schmidt / fixwinpath.go
Last active October 14, 2016 21:16
Circumvent 260 MAX_PATH charlength in Windows API in golang
// http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#maxpath
// http://stackoverflow.com/questions/1880321/why-does-the-260-character-path-length-limit-exist-in-windows
// converts a relative path like "abc\" or a filename like "savehere.zip"
// to full escaped path \\?\c:\currentdir\abc\
// note that all slashes have to be backslashes
func FuckWin(path string) string {
pwd, err := os.Getwd()
if err != nil { panic(err) }
result := pwd + "\\" + path
@d-schmidt
d-schmidt / OpenWithSublimeText3.cmd
Last active February 27, 2017 21:52 — forked from mrchief/LICENSE.md
Add "Open with Sublime Text 3" to Windows Explorer Context Menu of folders
@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 / sendEmail.py
Last active March 3, 2017 13:49
sending text mails from python with text attachments
#!/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 / memo.txt
Last active June 5, 2018 21:19
download app apk from Android phone and install it in emulator
// 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 / parsehtml.py
Last active July 18, 2018 19:35
Simple HTML parsing with python requests and lxml
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 / riter.py
Created July 18, 2018 20:33
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.
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 / 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