Skip to content

Instantly share code, notes, and snippets.

@tmelz
tmelz / center.vim
Created January 2, 2012 22:10
Vim: center current window in screen
let g:centerinscreen_active = 0
function! ToggleCenterInScreen(desired_width)
if g:centerinscreen_active == 0
let l:window_width = winwidth(winnr())
let l:sidepanel_width = (l:window_width - a:desired_width) / 2
exec("silent leftabove " . l:sidepanel_width . "vsplit new")
wincmd l
exec("silent rightbelow " . l:sidepanel_width . "vsplit new")
@tmelz
tmelz / reddit_wallpaper.py
Last active January 1, 2016 12:18
Script to update wallpaper with picture from Subreddit on a Mac
#!/usr/bin/env python
# encoding: utf-8
# Fun script to download reddit pics and set as wallpaper.
# Easiest way to do this is to point to a directory
# then have Mac set to load random picture from directory
# (say every hour).
# Then set a cron job to run this script every hour
# and a job to delete old pictures every few days
# Ex:
@tmelz
tmelz / 0_reuse_code.js
Last active August 29, 2015 14:07
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@tmelz
tmelz / multidexdump.sh
Last active December 29, 2015 22:14
dexdump doesn't include all dex files for multidex apps. here's a bash hack that does.
#!/bin/bash
# Usage: multidexdump apk [dexdump args]
# Example utility:
# multidexdump myapp.apk | grep 'Class descriptor'
temp=$(mktemp -d -t "dex")
unzip -qq $1 -d $temp
# Toss apk argument.
shift
@tmelz
tmelz / pre-commit.sh
Last active April 12, 2023 15:09
auto format java files with google-java-format
#!/bin/bash
# Auto format changed java files using google-java-format.
# To install, copy this file into $repo/.git/hooks and remove the .sh extension.
# Download the google-java-format JAR from
# https://github.com/google/google-java-format
# A more mature implementation of this would be a plugin for Yelp's pre-commit library:
# http://pre-commit.com/
echo "Running auto-formatter for any changed Java files"
echo "(formatting changes will be automatically added to your commit)"
@tmelz
tmelz / check_for_git_hooks.gradle
Created February 24, 2016 22:55
fail the gradle build if git-hooks don't exist
// Apply by adding the following line to your build.gradle:
// apply from: 'scripts/check_for_git_hooks.gradle'
// Comment out any hook files that aren't relevant for you.
final GIT_HOOK_DIR = ".git/hooks/"
final GIT_HOOK_FILES = [
"applypatch-msg",
"commit-msg",
"post-applypatch",
"post-checkout",
"post-commit",
@tmelz
tmelz / build.gradle
Created February 26, 2016 02:53
enforce your android versionName format with a regexp
android {
defaultConfig {
// Version name format: A.B.C-D, with A, B, and C numbers with -D optional as either "ALPHA"
// or "BETA" followed by a description. Examples: "1.0.0", "1.0.0-BETA",
// "1.0.0-ALPHA-TACO-DELIVERY".
versionName "1.0.0"
// Enforce that the version name matches the required format.
if (!(versionName ==~ /\d+\.\d+\.\d+(-(ALPHA|BETA).*)?/)) {
throw new IllegalStateException(
"Invalid version name ('$versionName')! See comment in app/build.gradle")
@tmelz
tmelz / samoklava.yaml
Created March 14, 2022 19:58
samoklava yaml
units:
kx: cx
ky: cy
px: 2
py: 2
points:
key:
footprints:
choc_hotswap:
type: choc
units:
kx: cx
ky: cy
px: 2
py: 2
points:
key:
footprints:
choc_hotswap:
type: choc