Skip to content

Instantly share code, notes, and snippets.

Chris Buckley cmbuckley

Block or report user

Report or block cmbuckley

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@cmbuckley
cmbuckley / fd.sh
Last active Jun 12, 2019
Firedrill script
View fd.sh
#!/bin/bash
webhook_url="URL HERE"
role=Firedrill
icon=bust_in_silhouette
channel="#lotto-support-3p"
roles=(
"marketing,Marketing:female-technologist::skin-tone-2"
"crm,CRM:male-singer::skin-tone-3"
"core,Core on-call:bearded_person::skin-tone-2"
@cmbuckley
cmbuckley / p.sh
Created Mar 13, 2019
Use 1Password to copy a password to the clipboard
View p.sh
#!/bin/bash
[ -z "$OP_SESSION_my" ] && eval $(op signin my)
out="$(op get item "$1")"
jq -r '.details.fields | .[] | select(.type=="P") | .value' <<< "$out" | xclip -selection clipboard -i
echo "Password for $(jq -r '.overview.title' <<< "$out") copied to clipboard"
@cmbuckley
cmbuckley / outer-glow.sh
Created Feb 21, 2019
Add outer glow to images with transparent background
View outer-glow.sh
# Add 5px transparent border
convert file.png -bordercolor transparent -border 5 file-border.png
# Add a 3px blur based on the alpha channel
convert file-border.png \( +clone -background '#777777' -shadow 100x1+0+0 -channel A -level 0,100% -blur 0x3 \) -compose DstOver -gravity center -composite file-glow.png
# TODO combine the above
View test.php
<?php
$char = '';
// What's the UTF-8 encoding of this character? (This file is saved in UTF-8)
var_dump(bin2hex($char)); // e382a4
// What does another encoding look like?
// See http://www.fileformat.info/info/unicode/char/30a4/charset_support.htm
var_dump(bin2hex(mb_convert_encoding($char, "EUC-JP", "UTF-8"))); // a5a4
View nestingLolz.js
function nestingLolz(count) {
return [...Array(count)].reduce(function (a, c, i) {
return a + ' or my ' + Array(i + 1).fill('son').join('’s ');
}, 'Don’t talk to me') + ' ever again';
}
// haven't decided which I prefer :-)
function nestingLolzAlternate(count) {
return ['Don’t talk to me']
.concat([...Array(count)].map((e, i) => Array(i + 1).fill('son').join('’s ')))
@cmbuckley
cmbuckley / trapper.js
Last active Nov 21, 2018
JavaScript Cookie Trapper
View trapper.js
// Use to detect calls to document.cookie="xxx"
(function (){
var s = document.__lookupSetter__('cookie').bind(document),
g = document.__lookupGetter__('cookie').bind(document);
Object.defineProperty(document, 'cookie', {
get() {
return g();
},
set(n) {
@cmbuckley
cmbuckley / rounded.sh
Last active Sep 21, 2018
ImageMagick rounded corners
View rounded.sh
#!/bin/bash
# usage: rounded.sh INFILE RADIUS [OUTFILE]
# if OUTFILE is omitted, outputs to STDOUT
size=$2
convert $1 \( +clone -alpha extract -draw "fill black polygon 0,0 0,$size $size,0 fill white circle $size,$size $size,0" \( +clone -flip \) -compose Multiply -composite \( +clone -flop \) -compose Multiply -composite \) -alpha off -compose CopyOpacity -composite ${3:-png:-}
@cmbuckley
cmbuckley / verify-air-cert.sh
Last active Sep 28, 2018
Verify Adobe AIR code signing certificate
View verify-air-cert.sh
#!/bin/bash
# Usage: ./verify-air-cert.sh /path/to/app.air
unzip -p "$1" META-INF/signatures.xml \
| xpath '//Signature[@Id="PackageSignature"]//X509Certificate[1]/text()' 2>/dev/null \
| sed -e $'1s/^/-----BEGIN CERTIFICATE-----\\\n/;$s/$/\\\n-----END CERTIFICATE-----/' \
| openssl x509 -text -noout
@cmbuckley
cmbuckley / comments.php
Last active May 13, 2018
Emit WordPress comments as YML
View comments.php
<?php
$file = $argv[1];
$header = null;
$spec = array(
'_id' => function ($data) {
return intval($data['comment_ID']);
},
'name' => 'comment_author',
View mem.js
let maxConsumption = 0;
process.nextTick(() => {
let memUsage = process.memoryUsage();
if (memUsage.rss > maxConsumption) {
maxConsumption = memUsage.rss;
}
});
process.on('exit', () => {
You can’t perform that action at this time.