Skip to content

Instantly share code, notes, and snippets.

View tpb1908's full-sized avatar

Theo Pearson-Bray tpb1908

View GitHub Profile
@tpb1908
tpb1908 / BarSpan.java
Created March 2, 2017 20:28
Android bar span to draw a line through the full width of a TextView
package com.yourpackage.package
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.support.annotation.NonNull;
import android.text.style.ReplacementSpan;
/**
* Created by theo on 02/03/17.
@tpb1908
tpb1908 / bash.txt
Created March 22, 2017 10:25
Count repo LOC in bash
git ls-files | xargs wc -l //Everything
git ls-files | grep "\.my_file_type$" | xargs wc -l //A particular file type
@tpb1908
tpb1908 / HtmlTagHandler.java
Created March 22, 2017 10:33
Extract attributes from XmlReader in Android HtmlTagHandler
public class HtmlTagHandler implements Html.TagHandler {
private static final String TAG = HtmlTagHandler.class.getSimpleName();
@Override
public void handleTag(final boolean opening, final String tag, Editable output, final XMLReader xmlReader) {
if(opening) {
if(tag.equalsIgnoreCase("a")) {
start(output, new A(getAttribute("href", xmlReader, "error.com")));
}
} else {
@tpb1908
tpb1908 / pre-commit.py
Last active May 1, 2017 11:08
Insert code from file into markdown
#!/usr/bin/env python
import re
import os
def get_imports(source):
imports = []
i = 0
while i < len(source)-1:
print i
@tpb1908
tpb1908 / walker.py
Created May 3, 2017 20:46
Walk a directory and create a markdown file for given file types
#!/usr/bin/env python
import os
# Valid file types
file_types = ["java", "xml", "gradle"]
# Only include paths containing one of these strings
path_whitelist = ["src"]
@tpb1908
tpb1908 / bashrc.sh
Last active November 22, 2017 23:42
bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# We use preexec and precmd hook functions for Bash
# If you have anything that's using the Debug Trap or PROMPT_COMMAND
# change it to use preexec or precmd
# See also https://github.com/rcaloras/bash-preexec
# If not running interactively, don't do anything
case $- in
@tpb1908
tpb1908 / Extensions.kt
Created July 3, 2017 19:41
Useful Android Kotlin extension functions
package com.tpb.brainfuck
import android.support.design.widget.FloatingActionButton
import android.support.v7.widget.RecyclerView
import android.text.Editable
import android.text.TextWatcher
import android.util.Log
import android.widget.TextView
/**
@tpb1908
tpb1908 / fixMonitor.sh
Created November 2, 2017 12:12
Script to set resolution for old VGA monitor.
#!/bin/sh
xrandr --newmode "VGAMODE" 109.00 1280 1368 1496 1712 1024 1027 1034 1063 -hsync +vsync
xrandr --addmode VGA1 VGAMODE
xrandr --output VGA1 --mode VGAMODE
@tpb1908
tpb1908 / i3 config
Last active August 28, 2018 18:11
i3 conf file
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout some time, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see https://i3wm.org/docs/userguide.html for a complete reference!
alias please='sudo $(history -p !!)'
alias accio='sudo apt-get install'
alias alohomora='chmod 777'
alias setclip="xclip -selection c"
alias getclip="xclip -selection c -o"
alias ls="ls --color=auto"