Skip to content

Instantly share code, notes, and snippets.

View ccondry's full-sized avatar

Coty Condry ccondry

  • Cisco Systems
  • Texas
View GitHub Profile
@ccondry
ccondry / sd-zero.sh
Created October 20, 2022 16:24
fix SD card format
sudo dd if=/dev/zero of=/dev/disk3 bs=1024 count=100
@ccondry
ccondry / webex-room.html
Created April 14, 2021 05:06
open webex teams room from web link
<a href="webexteams://im?space=abcd-1234-efgh-56789">
@ccondry
ccondry / docker-rm.sh
Created March 28, 2021 09:30
remove all docker images
docker rm $(docker ps -a -q)
docker rmi $(docker images -q)
docker volume rm $(docker volume ls |awk '{print $2}')
rm -rf ~/Library/Containers/com.docker.docker/Data/*
@ccondry
ccondry / random-int.js
Last active March 4, 2021 17:21
choose random integer between min and max, inclusively
function randomInt (min, max) {
const range = max - min
if (range < 0) {
throw Error('cannot generate random int with min-max range less than 0')
}
const r = Math.random()
return Math.round(r * range + min)
}
@ccondry
ccondry / send-webex-file.js
Created February 22, 2021 21:49
send data as a file to webex user or room using node-fetch
require('dotenv').config()
const fetch = require('node-fetch')
async function sendWebexFile ({
filename = 'test.csv',
fileMetaName = 'files',
contentType = 'text/csv',
content,
metadata = {}
}) {
@ccondry
ccondry / submit.md
Created February 22, 2021 21:33 — forked from tanaikech/submit.md
Multipart-POST Request Using Node.js

Multipart-POST Request Using Node.js

Here, I introduce 2 scripts for uploading files to Slack using Node.js as samples. These 2 sample scripts are for uploading files to Slack.

Sample script 1:

  • You can upload the zip file by converting byte array as follows.
    • At first, it builds form-data.
    • Adds the zip file converted to byte array and boundary using Buffer.concat().
    • This is used as body in request.
@ccondry
ccondry / short-hash.js
Created February 20, 2021 14:43
create a short alphanumeric hash using shake128
const crypto = require('crypto')
// create hash of user sub, and append it to the first 8 characters of the user sub
function getHash (sub) {
const hash = crypto
.createHash('shake128', {outputLength: 6})
.update(sub, 'utf-8')
.digest('base64')
// you could remove this replace statement if you didn't want to alter the base64 or number of output characters
// this is here so that only alphanumerics are returned. but it does change the length of some hashes (consistently)
@ccondry
ccondry / cisco-signout.txt
Created February 20, 2021 03:42
sign out of Cisco SSO
https://sso.cisco.com/autho/logout_redirect.html
@ccondry
ccondry / nginx-websocket-proxy-settings.conf
Created February 19, 2021 22:23
nginx websocket proxy settings
# WebSocket support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
@ccondry
ccondry / git-set-default-branch.sh
Created February 18, 2021 20:13
set git default branch name
# this would set it to "main"
git config --global init.defaultBranch main