Skip to content

Instantly share code, notes, and snippets.

View dob9601's full-sized avatar

Daniel O'Brien dob9601

View GitHub Profile
@dob9601
dob9601 / twitter_filter.js
Created December 28, 2017 00:07
filter twitter feeds
const twitter_filter = (prev_tweet_count = 0) => {
const twitter_handles = []
const orgs = document.getElementsByClassName('org-info')
for (let i = 0; i < orgs.length; i++) {
const org_info = orgs[i].children
const children = [].slice.call(org_info)
const twitter_url = children.filter(
x => x.nodeName === 'A' && x.host === 'twitter.com'
)
@dob9601
dob9601 / humble_download_trove.js
Created April 8, 2018 21:12
Download the whole of the humble trove (if you have subscribed to the humble trove)
var buttons = $( ".js-download-button" ).click()
var i=0
setInterval(function() {
buttons[i].click()
console.log('Downloading: '+buttons[i].parentNode.parentNode.parentNode.children[0].children[0].children[0].innerHTML)
i++
}, 1000)
@dob9601
dob9601 / virtual_desktops.ahk
Last active June 1, 2018 13:01
Designed for laptops and other windows machines that cannot perform the default change virtual desktop key combination due to ghosting. This autohotkey file rebinds the combination to LeftCTRL + Left and LeftCTRL + Right. It also rebinds the Browser_Back event and Browser_Forward event to do the same thing. This can be used with some touchpads i…
Browser_Back::SendInput {LCtrl down}{LWin down}{Right}{LCtrl up}{LWin up}
Browser_Forward::SendInput {LCtrl down}{LWin down}{Left}{LCtrl up}{LWin up}
LCtrl & Left::sendevent {LWin down}{LCtrl down}{Left down}{Lwin up}{LCtrl up}{Left up}
LCtrl & Right::sendevent {LWin down}{LCtrl down}{Right down}{LWin up}{LCtrl up}{Right up}
@dob9601
dob9601 / django-random-secret-key.py
Last active July 4, 2018 21:01
Random generation for django SECRET_KEY variable designed for GitHub projects - remove the declaration of the SECRET_KEY in settings.py and replace it with this. Upon the webapp first being run, a file named SECRET_KEY is created in the <project_name> folder. This removes the risk of someone downloading a project without then forgetting to adjus…
import random
import string
try:
with open('<PROJECT_NAME>/SECRET_KEY', 'r') as secret_key_file:
SECRET_KEY = secret_key_file.read()
if SECRET_KEY == '':
raise FileNotFoundError
except FileNotFoundError:
with open('<PROJECT_NAME>/SECRET_KEY', 'w') as secret_key_file:
@dob9601
dob9601 / .travis.yml
Created October 6, 2018 08:13
Travis one-liner to fail a build on a django application of someone attempts to push a build with DEBUG=True. Replace APP_NAME with the name of your application.
python -c "from APP_NAME.settings import DEBUG; assert not DEBUG"

Keybase proof

I hereby claim:

  • I am dob9601 on github.
  • I am dob9601 (https://keybase.io/dob9601) on keybase.
  • I have a public key ASCasy7vPbgo0Mcub_i1f3TRss22bHGankuGswfrEd73owo

To claim this, I am signing this object:

@dob9601
dob9601 / .vimrc
Last active October 27, 2020 14:45
My vimrc config
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
@dob9601
dob9601 / init.vim
Last active April 22, 2021 10:39
Updated neovim config
if &compatible
set nocompatible " Be iMproved
endif
" Disable HTML polyglot due to dodgy inline-js indents
let g:polyglot_disabled = ['html'] " breaks java
call plug#begin('~/.vim/plugged')
@dob9601
dob9601 / sentry_decorator.py
Created October 3, 2020 13:53
A sample implementation of sentry user context with discord.py. A better solution would be to override the on_error function which I realised after writing this beast..
"""Decorators, primarily related to sentry logging."""
import functools
import sentry_sdk
import discord
from discord.ext import commands
def sentry_user_context(payload_position: int, payload_type: object, bot: commands.Bot = None):