Skip to content

Instantly share code, notes, and snippets.

View rayterrill's full-sized avatar

Ray Terrill rayterrill

View GitHub Profile
$ClientID = "CLIENT_ID" # Should be a ~36 hex character string; insert your info here
$ClientSecret = "CLIENT_PASSWORD" # Should be a ~44 character string; insert your info here
$tenantdomain = "DOMAIN.onmicrosoft.com" # For example, contoso.onmicrosoft.com
$loginURL = "https://login.microsoft.com"
$resource = "https://graph.microsoft.com"
$body = @{grant_type="client_credentials";resource=$resource;client_id=$ClientID;client_secret=$ClientSecret}
$oauth = Invoke-RestMethod -Method Post -Uri $loginURL/$tenantdomain/oauth2/token?api-version=1.0 -Body $body
@rayterrill
rayterrill / GetWildApricotData.ps1
Created February 19, 2018 05:23
Get Wild Apricot Data via the API
function Get-Token($apikey) {
$user = "APIKEY"
$pass = $apikey
$pair = "${user}:${pass}"
$bytes = [System.Text.Encoding]::ASCII.GetBytes($pair)
$base64 = [System.Convert]::ToBase64String($bytes)
$basicAuthValue = "Basic $base64"
$headers = @{ Authorization = $basicAuthValue }
$body = @{ grant_type = "client_credentials"; scope = "auto" }

Install minikube

Invoke-WebRequest https://github.com/kubernetes/minikube/releases/download/v0.25.0/minikube-windows-amd64 -UseBasicParsing -Outfile c:\wip\minikube.exe

Start minikube in RBAC Mode

minikube start --extra-config=apiserver.Authorization.Mode=RBAC
Function Test-Function {
param (
[ValidateSet('test','test1')][string]$a,
[ValidateSet('test','test2')][string]$b
)
if ($a) { Write-Host "a was set to $($a)" }
if ($b) { Write-Host "b was set to $($b)" }
}
@rayterrill
rayterrill / GetVSANDiskStats.ps1
Last active January 18, 2018 20:03
Uses PowerCLI to try to mimic the RVC command vsan.disks_stats does.
Moved this over to https://github.com/rayterrill/PowerCLIExtraFunctions
@rayterrill
rayterrill / app.js
Created January 10, 2018 20:19
Upload images to Mongo with NodeJS and Express
var express = require('express');
var mongoose = require('mongoose');
var ObjectId = require('mongoose').Types.ObjectId;
var fs = require('fs-extra');
var url = 'mongodb://username:password@server/mydb';
var multer = require('multer');
var upload = multer({limits: {fileSize: 1064960 },dest:'/uploads/'}).single('picture');
var app = express();
@rayterrill
rayterrill / Get-VSANResyncStatus.ps1
Created January 6, 2018 04:53
Get VSAN Resync Status using SSH
#requires https://github.com/darkoperator/Posh-SSH
function Get-VSANResyncStatus {
param(
[string]$esx_server,
[String]$esx_username,
[String]$esx_password
)
$secpasswd = ConvertTo-SecureString $esx_password -AsPlainText -Force

List of community resources:

Setting Text to Start Just Below the Status Bar

import React, { Component } from 'react';
import { AppRegistry, StyleSheet, Text, View, Image } from 'react-native';
import { getStatusBarHeight } from 'react-native-status-bar-height';

export default class LotsOfStyles extends Component {
  render() {
    return (