Skip to content

Instantly share code, notes, and snippets.

View aconz2's full-sized avatar

Andrew Consroe aconz2

View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@aconz2
aconz2 / upwork-auto-redirect.js
Created June 12, 2017 20:50
Automatically redirect you to the external page when clicking on an external link from an Upwork
// ==UserScript==
// @name Upwork AutoRedirect
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Automatically redirect you to the external page when clicking on an external link from an Upwork listing.
// @author aconz2
// @match https://www.upwork.com/leaving?*
// @grant none
// ==/UserScript==
@aconz2
aconz2 / upwork-auto-job-load.js
Created June 12, 2017 20:52
Load more job results when bottom of page is reached on Upwork
// ==UserScript==
// @name Upwork MoreResults
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Load more job results when bottom of page is reached
// @author aconz2
// @match https://www.upwork.com/ab/find-work/*
// @require http://code.jquery.com/jquery-latest.js
// @grant none
// ==/UserScript==
@aconz2
aconz2 / update-ip
Last active September 4, 2017 04:15
a simple alternative to something like dyn-dns for remoting into home servers
#!/usr/bin/env bash
# requires the google-cloud-sdk
# to activate key
# google-cloud-sdk/bin/gcloud auth activate-service-account --key-file foobar.json
# be sure to run the above as root user as well for cron use
# to fix timeskew
[Unit]
Description=Starts i3lock at suspend time
Before=sleep.target
[Service]
User=%I
Type=forking
Environment=DISPLAY=:0
ExecStart=/usr/bin/i3lock -c 3f3f3f
@aconz2
aconz2 / boto3_with_role.py
Created August 24, 2017 16:14
How to assume a role in boto3
def boto3_with_role(role_arn, session_prefix, external_id, **kwargs):
"""
Create a partially applied session to assume a role with an external id.
A unique session_name will be generated by {session_prefix}_{time}
`session` can be passed, otherwise the default sesion will be used
see: http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-api.html
"""
res = sts.assume_role(
RoleArn = role_arn,
RoleSessionName = '{}_{}'.format(session_prefix, int(time.time())),
@aconz2
aconz2 / pi-minimal-DE-install.sh
Last active September 3, 2017 20:15
Installs the PIXEL DE
sudo apt-get upgrade
sudo apt-get install lightdm
sudo apt-get install --no-install-recommends raspberrypi-ui-mods lxterminal gvfs gvfs-backends
@aconz2
aconz2 / mk-firewall.sh
Created September 3, 2017 22:19
Add firewall rules for minidlna
firewall-cmd --permanent --new-service minidlna
firewall-cmd --permanent --service minidlna --add-port 8200/tcp
firewall-cmd --permanent --service minidlna --add-port 1900/udp
firewall-cmd --permanent --add-service minidlna
firewall-cmd --reload
firewall-cmd --list-services
@aconz2
aconz2 / search-py-docs.py
Created September 6, 2017 04:17
A program that launches a dmenu choice of index terms to open python docs; or lets you search for a term; works with multiple versions
#!/usr/bin/env python3.6
import re
from subprocess import run, PIPE
from pathlib import Path
import requests
import zipfile
import io
import pickle
import urllib
@aconz2
aconz2 / noworks.py
Last active May 18, 2023 12:31
asyncio ssl get peercert
# WARNING: this doesn't work properly
import asyncio
import ssl
import socket
# included logging to try to figure out why this wasn't working...
import logging
logging.basicConfig()
logging.getLogger('asyncio').setLevel(logging.DEBUG)