Skip to content

Instantly share code, notes, and snippets.

@jpriebe
jpriebe / assume_role.sh
Created January 31, 2023 19:41
assume_role
assume_role () {
SESSION_NAME=$1
ROLE_ARN=$2
export $(printf "AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s AWS_SESSION_TOKEN=%s" \
$(aws sts assume-role \
--role-arn $ROLE_ARN \
--role-session-name $SESSION_NAME \
--query "Credentials.[AccessKeyId,SecretAccessKey,SessionToken]" \
--output text))
@jpriebe
jpriebe / del_vpc.py
Last active February 3, 2023 22:08
#!/usr/bin/env python3
#### borrowed heavily from https://stackoverflow.com/questions/53519058/how-to-delete-vpc-with-all-its-dependencies-using-boto3
#### also found this online: https://github.com/jeffbrl/aws-vpc-destroy/blob/master/vpc_destroy.py
import boto3
import json
import re
import sys
from pprint import pprint
@jpriebe
jpriebe / wikijs.js
Created October 28, 2021 13:30
wiki.js script injection
<script>
window.onload = function() {
for (var links = document.links, i = 0, a; a = links[i]; i++) {
if (a.host !== location.host) {
a.target = '_blank';
}
}
};
</script>
#app > div > main > div > div.container.pl-5.pt-4.container--fluid.grid-list-xl > div > div.flex.page-col-sd.lg3.xl2 {
display: none
}
#app > div > main > div > div.container.grey.pa-0.container--fluid.lighten-4 > div > div {
margin-left: 0
}
#app > div > main > div > div.container.pl-5.pt-4.container--fluid.grid-list-xl > div > div.flex.page-col-content.xs12.lg9.xl10 {
flex-basis: 100%;
flex-grow: 0;
max-width: 100%
@jpriebe
jpriebe / test.yaml
Created May 19, 2021 17:36
Example of API that has a response that isn't handled properly by openapi-generator's golang client code
swagger: '2.0'
info:
version: '1'
title: Test
description: Test Service
contact: {}
host: localhost:8080
basePath: /api/v1
schemes:
- http
@jpriebe
jpriebe / degrees_to_direction.php
Created May 3, 2018 12:12
Convert degrees to direction string
function degrees_to_direction ($degrees, $short=true)
{
$dir_ary = [
['N', 'North'],
['NNE', 'North Northeast'],
['NE', 'Northeast'],
['ENE', 'East Northeast'],
['E', 'East'],
['ESE', 'East Southeast'],
['SE', 'Southeast'],
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous">
@jpriebe
jpriebe / NestedScrollViewManager.js
Last active August 15, 2021 13:23
Appcelerator Titanium code for managing scrollviews inside of scrollviews
function NestedScrollViewManager (parent_view)
{
// Appcelerator Titanium code for managing scrollviews inside of scrollviews (not true Android
// NestedScrollViews, but just a horizontal scrollview inside of a vertical scrollview).
//
// If you want to put a horizontal scrollview inside a vertical scrollview (like the Netflix app UI),
// it seems to work reasonably well on iOS. But on android, the user experience is very janky.
// Unless the user's drag movements are nearly exactly horizontal, there will be some movement of
// the parent scrollview, and then it becomes very difficult to scroll the child view. Flinging is
// almost impossible.
@jpriebe
jpriebe / spotify-playlist-indexer.php
Created April 30, 2017 11:37
Builds an HTML index of all Spotify playlists belonging to a particular user
#!/usr/bin/php -q
<?php
/**
* Builds an HTML index of all Spotify playlists belonging to a particular user;
* unfortunately, the API does not return folder information, so you can't
* structure the index according to folders.
*
* How to use:
* 1. go to https://developer.spotify.com/, log in, and create an app; you
* will need the Client ID and Client Secret
<?php
/**
* Class for interacting with an SMB server using the system command "smbclient".
* Of course this assumes that you have the smbclient executable installed and
* in your path.
*
* It is not the most efficient way of interacting with an SMB server -- for instance,
* putting multiple files involves running the executable multiple times and
* establishing a connection for each file. However, if performance is not an
* issue, this is a quick-and-dirty way to move files to and from the SMB