Skip to content

Instantly share code, notes, and snippets.

View allenmichael's full-sized avatar

Allen-Michael Grobelny allenmichael

  • Amazon Web Services
  • Austin, TX
  • X @amsxbg
View GitHub Profile
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Box.V2.Config;
using Box.V2.JWTAuth;
namespace BoxGetAllUsers
{
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"strings"
"time"
@allenmichael
allenmichael / Dockerfile
Last active February 12, 2018 21:47
Java, .Net Core, and Node.js build tools
FROM microsoft/dotnet
RUN apt-get update
RUN apt-get install -y curl unzip zip
RUN dotnet new -i Amazon.Lambda.Templates::*
RUN apt-get install -y groff-base
RUN wget https://bootstrap.pypa.io/get-pip.py
# Metadata commands
box files metadata create 278109288966 enterprise cli
box files metadata update 278109288966 enterprise cli --replace -p "/settings" -v "of"
box files metadata update 278109288966 enterprise cli --remove -p "/settings"
box files metadata update 278109288966 enterprise cli -a -p "/settings" -v "off"
# Metadata Date Value
box files metadata update 278109288966 enterprise cli -a -p "/home" -v "2002-10-02T10:00:00-05:00"
# Metadata Enum Value
box files metadata update 278109288966 enterprise cli -a -p "/env" -v "admin"
BoxFile file = new BoxFile(serviceAccountClient, source.get("id").asText().intern());
OutputStream stream = new ByteArrayOutputStream();
file.download(stream);
// Insert Epi. code
String metadataTemplate = "productClassification";
String metadataField = "/partSku";
String partSku = ""; // Replace with Epi return part SKU.
file.createMetadata(metadataTemplate, new Metadata().add(metadataField, partSku));
@allenmichael
allenmichael / app_users_with_no_files.ps1
Last active March 28, 2018 20:07
A PowerShell script to list all App Users that currently have 0 GB allocated.
box users list | ConvertFrom-Json | select -ExpandProperty "Entries" | select Name,Login,Id,Space_Used | where {($_.Login -Match "AppUser" -and $_.Space_Used -eq 0)} | select Id,Name,Space_Used | Tee-Object -Variable box_users | select Id | ConvertTo-Json;
$box_users | Format-Table
aws secretsmanager create-secret --name box_config --secre
t-string $(base64 -i ./boxConfig.json)
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: >
devNull
/dev/null as a Service
Parameters:
KMSAliasName:
Type: String
Default: alias/devnull/share
#!/usr/bin/env bash
if [ -z "$1" ]
then
read -p "Please enter text: " TEXT
else
TEXT=$1
fi
if [ -z "$2" ]
then
Import-Module AWSLambdaPSCore
Import-Module AWSPowerShell.NetCore
$region = 'eu-west-2'
New-AWSPowerShellLambdaPackage -ScriptPath ./rek/DetectLabels.ps1 -OutputPackage DetectLabels.zip
Write-S3Object -BucketName amsxbg-dotnet-eu -File ./DetectLabels.zip
New-CFNStack -StackName DetectLabelsPS -Capabilities @("CAPABILITY_IAM","CAPABILITY_AUTO_EXPAND") -TemplateBody $(Get-Content ./serverless.template.json | Out-String) -Region $region
Wait-CFNStack -StackName DetectLabelPS
Get-CFNStack -StackName DetectLabelsPS -Region $region | Select-Object -ExpandProperty Outputs | Select-Object -Property @{Name='BucketName'; Expression={$_.OutputValue}} | Write-S3Object -File /Users/amsg/Documents/laser.jpg
Get-CFNStack -StackName DetectLabelsPS -Region $region | Select-Object -ExpandProperty Outputs | Select-Object -Property @{Name='BucketName'; Expression={$_.OutputValue}} | Get-S3ObjectTagSet -Key laser.jpg