Skip to content

Instantly share code, notes, and snippets.

View rayterrill's full-sized avatar

Ray Terrill rayterrill

View GitHub Profile
@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();
2023-08-03T10:13:21.531-0700 [INFO] Terraform version: 1.3.2
2023-08-03T10:13:21.532-0700 [DEBUG] using github.com/hashicorp/go-tfe v1.9.0
2023-08-03T10:13:21.532-0700 [DEBUG] using github.com/hashicorp/hcl/v2 v2.14.1
2023-08-03T10:13:21.532-0700 [DEBUG] using github.com/hashicorp/terraform-config-inspect v0.0.0-20210209133302-4fd17a0faac2
2023-08-03T10:13:21.532-0700 [DEBUG] using github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734
2023-08-03T10:13:21.532-0700 [DEBUG] using github.com/zclconf/go-cty v1.11.0
2023-08-03T10:13:21.532-0700 [INFO] Go runtime version: go1.19.1
2023-08-03T10:13:21.532-0700 [INFO] CLI args: []string{"/opt/homebrew/Cellar/tfenv/3.0.0/versions/1.3.2/terraform", "apply"}
2023-08-03T10:13:21.532-0700 [DEBUG] Attempting to open CLI config file: /Users/rayterrill/.terraformrc
2023-08-03T10:13:21.532-0700 [INFO] Loading CLI configuration from /Users/rayterrill/.terraformrc

Build Project, App, and Generate Keys

  1. Sign into twitter with your bot account, and go to https://developer.twitter.com.
  2. If you're in the free account tier and your previous app was suspended, you may need to delete it. Free tier accounts appear to only support 1 app at a time.
  3. Create a project if you don't already have one, and then create an app. Make sure you take note of the keys you get at the end - you'll need these. These are your Consumer Keys and authenticate your application.
  4. Click on your app in the Developer Portal, make sure you're on the "Settings" tab, and click "Set up" under "User authentication settings"
  5. Select "Read and write" under "App permissions, "Web App, Automated App or Bot" under "Type of App", and enter something for Callback URI and Website URL (these aren't used in my flow), then click "Save". You'll get a Client ID and Client Secret - I didn't need these so I just ignored this.
  6. On the app page, click onto the "Keys and tokens" tab, then click "Generate" on "
@rayterrill
rayterrill / default.rb
Created May 22, 2018 15:18
Chef code to use AWS Secrets Manager in a Chef Recipe
# Chef code to use AWS Secrets Manager in a Chef Recipe
include_recipe "chef-vault"
vault = chef_vault_item(:chefsecrets, "awschefsecretsmanager")
aws_access_key = vault["access_key_id"]
aws_secret_key = vault["secret_access_key"]
require 'aws-sdk'
require 'json'
@rayterrill
rayterrill / main.go
Created June 15, 2022 05:53
Example of yaml marshal with inline map[string]interface
package main
import (
"fmt"
"gopkg.in/yaml.v3"
)
type Person struct {
ExtensionProps map[string]interface{} `yaml:",inline"`
@rayterrill
rayterrill / like.js
Created September 22, 2017 14:35
Add a Like/Ratings Button to the SharePoint Item Display Form (DispForm.aspx) to Allow Users to Like an Item from that page
<script language="javascript" type="text/javascript" src="/sites/MySPSite/SiteAssets/jquery-2.2.0.min.js"></script>
<script language="javascript" type="text/javascript" src="/sites/MySPSite/SiteAssets/jquery.SPServices.min.js"></script>
<script type="text/javascript">
SP.SOD.registerSod('reputation.js', '/_layouts/15/reputation.js');
SP.SOD.executeFunc('reputation.js', 'Microsoft.Office.Server.ReputationModel.Reputation', function () {
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', LoadRatingFunction);
});
ssh -vvv -i Identity-cert.pub -i Identity popnimda@172.31.29.228
OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n 7 Dec 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "172.31.29.228" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to 172.31.29.228 [172.31.29.228] port 22.
debug1: Connection established.
debug1: identity file Identity-cert.pub type 4
debug1: key_load_public: No such file or directory
$apps = Get-AzureADApplication -All $true
foreach ($a in $apps) {
try {
$appProxy = Get-AzureADApplicationProxyApplication -ObjectID $a.ObjectID
Write-Host "App Proxy config found for $($a.DisplayName): $($appProxy.ExternalURL) using $($appProxy.externalAuthenticationType)."
} catch {
#no app proxy config found for the app
}
}
@rayterrill
rayterrill / msalPopup.html
Last active August 12, 2019 14:05
Had a hell of a time trying to grok MSAL with simple, fully functional examples - the documentation still is pretty weak. Here are two examples showing both the redirect and popup flows. Hope it helps someone out
<!DOCTYPE html>
<html>
<body>
<div class="container">
<div class="leftContainer">
<p id="WelcomeMessage">Welcome to the Microsoft Authentication Library For Javascript Quickstart</p>
<button id="SignIn" onclick="signIn()">Sign In</button>
</div>
<div class="rightContainer">
<pre id="json"></pre>
@rayterrill
rayterrill / values.yaml
Created June 1, 2019 04:19
Sample values.yaml to configure CoreDNS with an etcd backend using Helm (helm install --name my-coredns --values values.yaml stable/coredns)
isClusterService: false
serviceType: "NodePort"
rbac:
create: true
servers:
- zones:
- zone: .
port: 53
plugins:
- name: etcd