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
View README.md

These snippets are to highlight a minor display discrepancy between desktop and mobile link unfurling in Slack.

The article:published_time OpenGraph tag can have an optional time component. When unfurling links, desktop always treats the tag as a date, and mobile always treats it as a datetime, regardless of the content of the tag.

The content can essily be passed into Slack using raw.githack.com:

@cmbuckley
cmbuckley / sms.sh
Created Oct 10, 2019
Nexmo SMS script
View sms.sh
#!/bin/bash
function msisdn() {
sed 's/^0/44/' <<< "$1"
}
API=https://rest.nexmo.com/sms/json
KEY= # Nexmo API key
SECRET= # Nexmo API secret
DEFAULT= # Default SMS sender
View README.md

This is just an example for https://stackoverflow.com/q/58283005/283078.

The following commands were run to create this history:

git checkout -b dev
git commit --allow-empty -m 'Dev commit 1'
git commit --allow-empty -m 'Dev commit 2'
git commit --allow-empty -m 'Dev commit 3'
git checkout master
@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:-}
You can’t perform that action at this time.