Skip to content

Instantly share code, notes, and snippets.

@pmenglund
pmenglund / part2.go
Created December 14, 2022 03:37
OAuth Device Flow part two
url := "https://internal.rockset.com/api/"
body := bytes.NewBufferString(`{"request":"foobar"}`)
request, err := http.NewRequestWithContext(ctx, http.MethodPost, url, body)
if err != nil {
log.Fatalf("failed to create request %v", err)
}
request.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token.AccessToken))
response, err := http.DefaultClient.Do(request)
@pmenglund
pmenglund / part1.go
Created December 14, 2022 03:37
OAuth Device Flow part one
ctx := context.Background()
cfg, err := device.NewConfig("auth0", "rockset", os.Getenv("AUTH0_CLIENT_ID"))
if err != nil {
log.Fatalf("failed to create configuration: %v", err)
}
a := device.NewAuthorizer(cfg)
code, err := a.RequestCode(ctx)
@pmenglund
pmenglund / rockset.apply.tfout
Created November 14, 2022 23:49
rockset terraform apply output
$ terraform apply
data.rockset_account.current: Reading...
data.rockset_account.current: Read complete after 1s [id=318212636800]
data.aws_iam_policy_document.rockset-trust-policy: Reading...
data.aws_iam_policy_document.rockset-trust-policy: Read complete after 0s [id=2982727827]
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
@pmenglund
pmenglund / rockset.tfout
Created November 14, 2022 21:58
terraform plan output
$ terraform plan
data.rockset_account.current: Reading...
data.rockset_account.current: Read complete after 0s [id=318212636800]
data.aws_iam_policy_document.rockset-trust-policy: Reading...
data.aws_iam_policy_document.rockset-trust-policy: Read complete after 0s [id=2982727827]
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
@pmenglund
pmenglund / gist:d318abde96defb2f2b6b79b9842fa4d8
Created September 27, 2018 17:50
thing to leave behind in /etc/profile.d
_ls() {
if [[ $[$RANDOM % 4] == 0 ]]; then
sleep 1
echo "Segmentation fault"
return 139
else
# run ls with randon sorting option
command ls -$(opts="frStu"; echo ${opts:$((RANDOM % ${#opts})):1}) "$@";
fi
}
@pmenglund
pmenglund / keybase.md
Last active January 31, 2018 15:57
keybase.md

Keybase proof

I hereby claim:

  • I am pmenglund on github.
  • I am pmenglund (https://keybase.io/pmenglund) on keybase.
  • I have a public key ASCSGLlZ8XJDQsST1ixqtpqE1B6aFbP2RBF72Mvg-8COcQo

To claim this, I am signing this object:

@pmenglund
pmenglund / gist:5000861
Created February 21, 2013 00:07
elb stuff in aws cpi
diff --git a/bosh_aws_cpi/lib/cloud/aws/cloud.rb b/bosh_aws_cpi/lib/cloud/aws/cloud.rb
index 6e2bfab..6a66b0a 100644
--- a/bosh_aws_cpi/lib/cloud/aws/cloud.rb
+++ b/bosh_aws_cpi/lib/cloud/aws/cloud.rb
@@ -56,7 +56,9 @@ module Bosh::AwsCloud
# AWS Ruby SDK is threadsafe but Ruby autoload isn't,
# so we need to trigger eager autoload while constructing CPI
AWS.eager_autoload!
- @ec2 = AWS::EC2.new(aws_params)
+
@pmenglund
pmenglund / gist:4034820
Created November 7, 2012 22:08
show slow require:s
module Kernel
alias_method :require_orig, :require
def require(name)
$indent ||= 0
t1 = Time.now.to_f
$indent += 2
puts "#{" " * $indent}> #{name}"
require_orig name
t2 = Time.now.to_f
@pmenglund
pmenglund / gist:3906090
Created October 17, 2012 15:17
Sample spec file
require "spec_helper"
describe "foo" do
before(:all) do
requirement release
requirement stemcell
end
after(:all) do
cleanup release
<script src="http://code.angularjs.org/angular-0.9.16.min.js" ng:autobind></script>
<script>
var SERVICE_URL = "http://blockexplorer.com/q/getdifficulty";
function CalculatorController($xhr) {
this.integer = /^\d+$/;
this.fraction = /^\d+\.*\d*$/;
this.fetch = function() {
var self = this;
$xhr('', SERVICE_URL, function(code, response) {
self.difficulty = response;