Skip to content

Instantly share code, notes, and snippets.

View lestercheung's full-sized avatar
🫠

Lester Cheung lestercheung

🫠
View GitHub Profile
@lestercheung
lestercheung / ansible_xml_filter.py
Last active November 4, 2022 11:20
A Ansible filter plugin that helps you edit xml files
'''Ansible filters: useful to edit xml configs
'''
import xml.etree.ElementTree as ET
def xml_edit(xml, xpath, attrs={}, txt=None):
'''changes is a list of xpath, attributes and text'''
root = ET.fromstring(xml)
elm = root.find(xpath)
@lestercheung
lestercheung / p4-bug-report-20200216.txt
Last active February 16, 2020 03:05
p4bug-20200216
lesterc@n54l /e/s/ws ❯❯❯ p4 sync -f //depot/path
//depot/path#1 - added as /client/path
[1] 25173 illegal hardware instruction (core dumped) p4 sync -f /client/path
lesterc@n54l /e/s/ws ❯❯❯ p4 -V ✘ 132
Perforce - The Fast Software Configuration Management System.
Copyright 1995-2020 Perforce Software. All rights reserved.
This product includes software developed by the OpenSSL Project
for use in the OpenSSL Toolkit (http://www.openssl.org/)
Version of OpenSSL Libraries: OpenSSL 1.1.1a 20 Nov 2018
See 'p4 help [ -l ] legal' for additional license information on
@lestercheung
lestercheung / pngminify.zsh
Created February 10, 2020 07:01
MacOS folder action to reduce screenshots size automatically
#!/bin/zsh
# This can be used as a folder action on the macOS's desktop to reduce the size of
# most PNG files automatically.
#
# http://about.me/lestercheung
POSTERIZE=0
PNGQUANT=0
[[ -x /usr/local/bin/posterize ]] && POSTERIZE=1
[[ -x /usr/local/bin/pngquant ]] && PNGQUANT=1
@lestercheung
lestercheung / parsley-test.py
Last active August 29, 2015 13:56
What's wrong with this? (See comment for trackback)
# -*- coding: utf-8 -*-
from parsley import makeGrammar
from pprint import pprint
import datetime
cmdstart = """Perforce server info:
2014/01/02 02:32:33 pid 19834 p4user@p4client 10.20.0.238 [p4/2013.3/DARWIN90X86_64/740675] 'user-submit -d Lr5 catalog dump 2014/01/02 lr5.lrcat.sql.xz'"""
cmdcomplete = """Perforce server info:
2014/01/02 02:32:33 pid 19834 completed .216s 4+8us 1251+0io 0+0net 2472k 0pf """