Skip to content

Instantly share code, notes, and snippets.

View BlaneyXYZ's full-sized avatar
🙏
Flex

Nathan Blaney BlaneyXYZ

🙏
Flex
View GitHub Profile
@BlaneyXYZ
BlaneyXYZ / gist:98469ddd523c43cd4ded69d679104e4e
Last active March 30, 2021 07:53
PUT all files in a folder to a REST endpoint
#!/usr/bin/env python3
import os
import requests
from requests.auth import HTTPBasicAuth
directory = os.fsencode(os.getcwd())
for file in os.listdir(directory):
filename = os.fsdecode(file)
response = requests.post('http://localhost', files={'file': open(filename, 'rb')}, auth=HTTPBasicAuth('user', 'pass'))
'''
A very basic check digit example
Pulled from a Systems Modeling Exam
Rules are.
User inputs two digit number where the first digit is greater than 1 (so first number being 10)
Input is split and the sum of the two digits is the check digit, if greater than 9 the new numbers are summed together
giving the check digit
Examples:
11 = 112 (because 1 + 1 is 2)
76 = 764 (because 7 + 6 is 13, 1 + 3 is 4)
import pandas as pd
rng = pd.date_range(start='1/1/1901', end='12/31/2000', freq='D')
count = 0
for date in rng:
if date.weekday() == 6:
count += 1
print(count)
javascript: jQuery('label:contains("Competent")').not('label:contains("Not Yet Competent")').prev('input').attr('checked','checked');jQuery('textarea').val('Good Work');jQuery('body').animate({scrollTop:$(document).height()}, 'fast');jQuery('#SaveAndValidate').trigger("click");
@BlaneyXYZ
BlaneyXYZ / gist:e2113b6e98dedee8fa4c
Created January 21, 2015 05:28
YOURLS For CloudBot
@_shortener('blny.tk')
class Blnytk(Shortener):
def shorten(self, url, custom=None):
p = {'signature': '', 'format': 'json', 'keyword': custom, 'action': 'shorturl', 'url': url}
h = {'User-Agent': 'CloudBot Refresh'}
r = requests.get('http://blny.me/api.php', params=p, headers=h)
j = r.json()
if 'shorturl' in j:
return j['shorturl']
@BlaneyXYZ
BlaneyXYZ / rusrulpy2.py
Created October 23, 2014 11:06
Russian Roulette py2
# russian roulette
import random
from util import hook
import os
import json
import time
@hook.command(autohelp=False)
def load(inp, say=None, me=None, chan=None):
"load [<number of barrels>] [<number of bullets>] - " \
@BlaneyXYZ
BlaneyXYZ / auto_shorten.py
Last active August 29, 2015 13:56
Autoshorten for @TheFiZi (Now for CloudBot running on python3.4)
from cloudbot import hook
from cloudbot.util import web
import re
link_re = re.compile(r'((https?://([-\w\.]+)+(:\d+)?(/([\S/_\.]*(\?\S+)?)?)?))', re.I)
@hook.regex(link_re)
def autoshorten(match):