Skip to content

Instantly share code, notes, and snippets.

Avatar

Coty Condry ccondry

  • Cisco Systems
  • Texas
View GitHub Profile
@ccondry
ccondry / webex-room.html
Created Apr 14, 2021
open webex teams room from web link
View webex-room.html
<a href="webexteams://im?space=abcd-1234-efgh-56789">
@ccondry
ccondry / docker-rm.sh
Created Mar 28, 2021
remove all docker images
View docker-rm.sh
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 Mar 4, 2021
choose random integer between min and max, inclusively
View random-int.js
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 Feb 22, 2021
send data as a file to webex user or room using node-fetch
View send-webex-file.js
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 Feb 22, 2021 — forked from tanaikech/submit.md
Multipart-POST Request Using Node.js
View submit.md

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 Feb 20, 2021
create a short alphanumeric hash using shake128
View short-hash.js
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 Feb 20, 2021
sign out of Cisco SSO
View cisco-signout.txt
https://sso.cisco.com/autho/logout_redirect.html
View nginx-websocket-proxy-settings.conf
# 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 Feb 18, 2021
set git default branch name
View git-set-default-branch.sh
# this would set it to "main"
git config --global init.defaultBranch main
@ccondry
ccondry / node-fetch-ignore-cert.js
Created Feb 1, 2021
disable SSL cert checking for 1 request
View node-fetch-ignore-cert.js
const fetch = require('node-fetch');
const https = require('https');
const httpsAgent = new https.Agent({
rejectUnauthorized: false,
});
const response = await fetch(url, {
method: 'POST',
headers: headers,