Skip to content

Instantly share code, notes, and snippets.

@blha303
blha303 / ddnsupdate.py
Created March 13, 2015 03:49
Script to update a DDNS provider (currently namecheap, but any provider that offers a simple http interface should work if the url is replaced) with your current IP
import requests,time,socket,json,sys
def init_settings():
try:
with open("settings.json") as f:
settings = json.load(f)
return settings
except:
with open("settings.json", "w") as f:
settings = dict(domain="REPLACE_WITH_DOMAIN",
@blha303
blha303 / testvm.ps1
Created March 14, 2015 04:17
Set up test vm in hyper-v
function Connect-VM {
param(
[Parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true, Position=1)]
[Microsoft.HyperV.PowerShell.VirtualMachine[]]$VM,
[switch] $PassThru
)
PROCESS {
foreach ($VMobject in $VM) {
vmconnect localhost ($VMobject.name)
}
@blha303
blha303 / hasnudes.py
Last active August 29, 2015 14:17
Web service to search celebritymoviearchive for movies with nudes, with a nice json interface http://hasnudes.blha303.biz
from flask import Flask, jsonify, redirect, request, abort
import requests, time
from bs4 import BeautifulSoup as Soup
app = Flask(__name__)
f_gh = """<a href="https://gist.github.com/blha303/e8e7568767cea6d12352"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/a6677b08c955af8400f44c6298f40e7d19cc5b2d/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f677261795f3664366436642e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png"></a>"""
f_base = "<html><head><title>{title}HasNudes</title></head><body>" + f_gh + "<h2>HasNudes</h2>{body}</body></html>"
f_result = "<h3>{moviename} has {number} nudes{dotorq}</h3>"
f_homepage = "<form><input type=text name=movie><input type=checkbox name=json id=json><label for=json>JSON output</label><input type=submit>"
@blha303
blha303 / __init__.py
Last active August 31, 2021 23:05
IRC Single Message Bot. Sends a single IRC message to a channel, then quits. Useful for job notifications maybe
from irc.bot import ServerSpec
import irc
import sys
import json
try:
with open('smbotconfig.json') as f:
conf = json.load(f)
except:
print "Error in config or no config found, returning to defaults. Please edit smbotconfig.json (http://jsonlint.com/) and restart the bot"
# Usage: gethbdownloads.py > filelist.txt
# Then: wget --content-disposition --no-check-certificate -c -i filelist.txt
# Defaults to returning torrent urls, easily configurable
from __future__ import print_function
from sys import stderr, exit
from getpass import getpass
import humblebundle
ERRORS = {1: "Login failed, please check details"}
@blha303
blha303 / netflix.py
Last active August 29, 2015 14:18
A python function to get netflix movie info and parse out all relevant data, returning it in a tuple as stated in the docstring
"""
Example usage:
>>> netflix("60024942")
(u'Catch Me If You Can', u'2002', u'Thu Jan 09 08:00:00 UTC 2003', u'M', u'140 minutes', u'http://cdn2.nflximg.net/images/0432/12050432.jpg', u'An FBI agent makes it his mission to put cunning con man Frank Abagnale Jr. behind bars. But Frank not only eludes capture, he revels in the pursuit.', {u'director': u'Steven Spielberg', u'genre': u'Dramas', u'language': u'English', u'starring': u'Leonardo DiCaprio, Tom Hanks'})
ID could be obtained through trivial URL parsing using any stdlib library.
Here, i'll do an example:
from urlparse import urlparse, parse_qs # urllib.parse in python 3
@blha303
blha303 / ipinfo.py
Created April 3, 2015 14:25
A local service to get your ip, for if you have a local service running that you want to link to other people but you can't be bothered finding your IP first.
# ipinfo.py by Steven Smith (blha303), MIT license (as is every script on my gist, by the way, unless otherwise stated)
# A local service to get your ip, for if you have a local service running that you want to link to other people but you can't be bothered finding your IP first.
# I use it for Plex, with a bookmark pointing to http://localhost:5212/32400/web/index.html
from flask import Flask, jsonify, redirect
import socket
app = Flask(__name__)
ip_addrs = None
def update():
@blha303
blha303 / gist:f77ab4f62ef5f9c0e8a1
Last active August 29, 2015 14:20
netctl config for polytechnic west (australia) wifi (needs student ID and password) | modified https://aur.archlinux.org/packages/netctl-eduroam/
Connection='wireless'
Interface=wlp2s0 # or your wireless interface name
Security='wpa-configsection'
Description='tafe'
IP='dhcp'
TimeoutWPA=30
WPAConfigSection=(
'ssid="PWAStudent"'
'key_mgmt=WPA-EAP'
'eap=PEAP'
@blha303
blha303 / ytPlaylistToPodcast.py
Last active September 29, 2019 10:46
Generates an iTunes compatible podcast from a Youtube playlist, storing the audio files in a local directory. Could be adapted to store the files in Dropbox or on another media provider if desired | Requires python 2.7, requests, wget, and youtube-dl | Configuration at top of file
#!/usr/bin/env python2
# This file is released as public domain by Steven Smith (blha303) in Apr 2015
# In areas where public domain isn't a thing, I release it under the MIT license.
# Although credit would be nice if you use this in something cool. And email me a link too pls.
import time,os,requests,json,subprocess
from urllib import urlretrieve
DTFORMAT = "%a, %b %d %Y %H:%M:%S +0000" # Do not modify, needs to be at top
playlisturl = "https://www.youtube.com/playlist?list=UU9CuvdOVfMPvKCiwdGKL3cQ"
@blha303
blha303 / get-billboard.py
Created June 5, 2015 08:11
Returns a list of tuples for each item in a specified Billboard Top 100 list. Planning a Arch Rollback Machine-style repository for popular music
#!/usr/bin/env python2
from bs4 import BeautifulSoup as Soup
import requests
from collections import namedtuple
from datetime import datetime, timedelta
Song = namedtuple('Song', ['title', 'artist', 'position', 'spotify', 'vevo', 'rdio'])
def billboard(date):
soup = Soup(requests.get("http://www.billboard.com/charts/hot-100/%s" % date).text)