Skip to content

Instantly share code, notes, and snippets.

@jbarr21
jbarr21 / FindMatchesAction.groovy
Last active July 6, 2020 12:57
IntelliJ plugin to perform multiple structural search and replace actions. Can be installed with https://github.com/dkandalov/live-plugin
import com.intellij.openapi.actionSystem.*
import com.intellij.openapi.application.*
import com.intellij.openapi.command.*
import com.intellij.openapi.diagnostic.*
import com.intellij.openapi.fileTypes.*
import com.intellij.openapi.progress.*
import com.intellij.openapi.project.*
import com.intellij.openapi.ui.*
import com.intellij.openapi.vfs.*
import com.intellij.psi.*
@jbarr21
jbarr21 / madb.sh
Last active January 21, 2020 20:45
Utilities for your BASH or ZSH profile that enable running ADB commands on multiple emulators/devices
# Utilities for your BASH or ZSH profile that enable running ADB commands on multiple emulators/devices
function prepend() { while read line; do echo "${1}${line}"; done; }
# requires ADB on $PATH
madb(){ for SERIAL in `adb devices | sed '1d;$d' | cut -f 1`; do adb -s $SERIAL "$@" | prepend "[$SERIAL] "; done; }
# requires https://github.com/ashishb/adb-enhanced
madbe(){ for SERIAL in `adb devices | sed '1d;$d' | cut -f 1`; do adbe -s $SERIAL "$@" | prepend "[$SERIAL] "; done; }
@jbarr21
jbarr21 / pasteboardAsHtml.swift
Last active January 18, 2020 08:14
Copies the contents of the general string pasteboard on Mac OSX over to HTML for easy pasting into Google Docs
// Utility to help with converting markdown on the clipboard into html on the
// clipboard for easy pasting of formatted text into a Google Doc in Chrome.
//
// Setup:
// - brew install pandoc
// - alias md2gd='pbpaste | pandoc -f markdown+smart -t html | pbcopy; swift pasteboardAsHtml.swift; echo "Copied to clipboard";'
//
// Usage:
// - <Copy some markdown text>
// - md2gd
@jbarr21
jbarr21 / ExportFigmaColorPalette.kts
Last active February 6, 2023 22:24
Export a color palette from Figma given a file with multiple tables of colors with semantic names on the row labels and theme names on the column names
/*
* Copyright (c) 2019. Uber Technologies
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@jbarr21
jbarr21 / phab-diff-stats.py
Created July 13, 2018 04:09
Phabricator Diff Stats
from phabricator import Phabricator
username = 'USERNAME'
ph = Phabricator()
my_phid = ph.user.whoami().phid
phid = ph.user.find(aliases=[username])[username]
def diffs_search(constraints, after=None):
diffs = []
class VectorDrawableInterceptor : Interceptor {
override fun intercept(chain: Interceptor.Chain): InflateResult {
val result = chain.proceed(chain.request())
(result.view() as? TextView)?.let { textView ->
result.context().obtainStyledAttributes(result.attrs(), intArrayOf(android.R.attr.drawableLeft))?.let { ta ->
val drawableRes = ta.getResourceId(0, 0)
if (drawableRes != 0) {
val drawable = AppCompatResources.getDrawable(result.context(), drawableRes)
textView.setCompoundDrawablesWithIntrinsicBounds(null, null, drawable, null)
}
@jbarr21
jbarr21 / GlideMemoryCache.java
Created February 23, 2017 17:24
A Glide memory cache backed by a delegate Picasso LruCache
import android.graphics.Bitmap;
import android.support.annotation.NonNull;
import com.bumptech.glide.load.Key;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.engine.cache.MemoryCacheAdapter;
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
import com.squareup.picasso.LruCache;