Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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
# 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 / __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"
@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 / 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 / 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 / apache_mirror.py
Last active August 29, 2015 14:16
Script to mirror a directory visible over apache directory indexing. Creates a batch file containing urls and directory output locations
#!/usr/bin/env python2
# Usage: ./apache_mirror.py [BASE URL] [NUMBER OF COLUMNS]
# If the target site has more (or less) than three columns in the directory index, the second parameter is required.
import sys
import urllib2
from bs4 import BeautifulSoup as Soup
def do_iterate(curdir="", BASE="", COL="", fh=None):
print "Entering {}".format(BASE + curdir)
@blha303
blha303 / gpstrack.php
Created March 3, 2015 13:19
Google Maps display for a csv-formatted list of dates/latitudes/longitudes/accuracy-in-metres.
<?php
$passwdfile = "/path/to/file";
$logpath = "/path/to/file"; // should be a csv file with date,lat,long,hor-acc
// For json
foreach (apache_request_headers() as $header => $value) { if ($header == "Accept") { $accept = $value; } }
// Variable checks
$allowed = isset($_GET['allowed']);