Skip to content

Instantly share code, notes, and snippets.

@tabrindle
tabrindle / webp-convert-directory.sh
Last active April 30, 2024 14:03
Convert all files in directory to webp, with default params, or standard cwebp params passed from command
#!/bin/bash
PARAMS=('-m 6 -q 70 -mt -af -progress')
if [ $# -ne 0 ]; then
PARAMS=$@;
fi
cd $(pwd)
@tabrindle
tabrindle / gist:bce0dd3315b103514ea1
Created August 5, 2015 13:40
get windowID python
#!/usr/bin/python2.6
from itertools import chain
from Quartz import CGWindowListCreate as create_list
from Quartz import CGMainDisplayID as display_id
from Quartz import CGWindowListCreateDescriptionFromArray as lookup
import sys
class Windows(list):
def find(self, name):
@tabrindle
tabrindle / gist:6537307
Created September 12, 2013 13:28
Sencha itemTpl examples
itemTpl:[
"<div>",
"<div style='font-weight:bold;' class='list-item-title'>{FIRST_NAME} {LAST_NAME} </div>",
"<div class='list-item-narrative'>{EMAIL}</div>",
"<div class='list-item-narrative'>{PHONE}</div>",
"<div style='font-style:italic;' class='list-item-narrative'>",
"<tpl if='ACTIVE == 1'>",
"Active: True",
"</tpl>",
"</div>",
@tabrindle
tabrindle / uninstall-zoom.sh
Created July 9, 2019 18:38
Uninstall zoom and prevent reinstall
rm -rf /Applications/zoom.us.app/
lsof -i :19421 | awk 'NR!=1{print $2}' | xargs kill -9
rm -rf ~/.zoomus
touch ~/.zoomus
@tabrindle
tabrindle / gist:59737b27925c128e36796a5dbdf26a49
Created January 16, 2019 16:49
preset-env last two years - browserlist query
"since 2017, not Baidu > 0, not QQAndroid > 0, not iOS > 0, not Samsung > 0, not Android > 0, not FirefoxAndroid > 0, not ChromeAndroid > 0"
or
"['chrome > 55', 'edge > 15', 'firefox > 52', 'safari > 10.1', 'opera > 42']" as of Nov 2018
Both queries amount to the same things at one point in time, but the top one updates
@tabrindle
tabrindle / example.sh
Created August 9, 2018 19:48
print insertions and deletions after git status
git() {
if [[ "$1" = "status" ]]; then
command git status;
command git --no-pager diff --shortstat HEAD
else
command git "$@"
fi
}
@tabrindle
tabrindle / resolve.js
Created April 15, 2018 22:55
Resolve promises in place - first library attempt
const pProps = require('p-props');
const sleep = (message) => new Promise(resolve => setTimeout(() => resolve(message), Math.floor(Math.random() * 2500)));
const get = message => sleep(message).then(res => res);
const data = {
Amit: get('Amit'),
vitae: get('vitae'),
Lorem: {
Tellus: get('Tellus'),
@tabrindle
tabrindle / gist:6537256
Created September 12, 2013 13:25
Configure Sencha CMD to use a proxy.
Edit this file:
~/bin/Sencha/Cmd/3.1.2.342/sencha.cfg
Change line 33 to look like this:
cmd.jvm.args=-Xms128m -Xmx1024m -Djava.awt.headless=true -Dhttp.proxyHost=proxy.proxy.com -Dhttp.proxyPort=80​
@tabrindle
tabrindle / sendPushNotification.js
Created November 7, 2017 15:20
Expo Notifications Demo - sendPushNotification
sendPushNotification(token = this.state.token, title = this.state.title, body = this.state.body) {
return fetch('https://exp.host/--/api/v2/push/send', {
body: JSON.stringify({
to: token,
title: title,
body: body,
data: { message: `${title} - ${body}` },
}),
headers: {
'Content-Type': 'application/json',
@tabrindle
tabrindle / registerForPushNotifications.js
Created November 7, 2017 15:20
Expo Notifications Demo - registerForPushNotifications
async registerForPushNotifications() {
const { status } = await Permissions.getAsync(Permissions.NOTIFICATIONS);
if (status !== 'granted') {
const { status } = await Permissions.askAsync(Permissions.NOTIFICATIONS);
if (status !== 'granted') {
return;
}
}