Skip to content

Instantly share code, notes, and snippets.

@ipmsteven
ipmsteven / rco.sh
Last active October 27, 2021 00:04
rco
function rco {
git reflog | egrep -io "moving from ([^[:space:]]+)" | awk '{ print $3 }' | head -n10 | sort | uniq
}
sudo mkdir /buildArtifacts
response=$(curl --silent --header "Metadata: true" "http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https%3A%2F%2Fvault.azure.net")
sudo echo $response >> /buildArtifacts/output
access_token=$(echo $response | jq -r '.access_token')
sudo curl --silent --header "Authorization: Bearer $access_token" "https://ghpiimagekeyvault.vault.azure.net/secrets/password/50d9c07516ff4a9c8c779015abbced94?api-version=2016-10-01" >> /buildArtifacts/output
#! /usr/bin/python
# importing the requests library
import requests
# Step 1: Fetch an access token from an MSI-enabled Azure resource
# Note that the resource here is https://vault.azure.net for the public cloud, and api-version is 2018-02-01
MSI_ENDPOINT = "http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https%3A%2F%2Fvault.azure.net"
r = requests.get(MSI_ENDPOINT, headers = {"Metadata" : "true"})
<table>
<thead>
<tr>
<th>Payment</th>
<th>Issue Date</th>
<th>Amount</th>
<th>Period</th>
</tr>
</thead>
<tbody>
@ipmsteven
ipmsteven / hello_world.rb
Created March 7, 2015 20:49
weird hello world
obj = ''
obj.define_singleton_method :to_s, ->(s) { "hello #{s}" }
obj.to_s('world')
@ipmsteven
ipmsteven / 0_reuse_code.js
Last active August 29, 2015 14:15
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ipmsteven
ipmsteven / this.js
Last active August 29, 2015 14:15
this $
var selectFlight = {
fetchingFlights : null,
init: function(){
$("#tabs").bind({
click: this.changeTab
});
$('a').click(function(event) {
event.preventDefault();
@ipmsteven
ipmsteven / singleton_class.rb
Created February 10, 2015 06:43
singleton_class in ruby
class B;end
class A < B;end
module C;end
module D;end
A.include C
@ipmsteven
ipmsteven / new.js
Created February 4, 2015 08:57
js new
var Class = function(){
var klass = function(){
this.init.apply(this, arguments);
};
klass.prototype.init = function(){};
return klass;
};
// Case 1
var Person = new Class;
@ipmsteven
ipmsteven / tenant_name_normalizer.rb
Created January 27, 2015 10:04
tenant_name_normalizer
class Person < Struct.new(:name); end
@tenants = ('ah'..'ch').map { |l| Person.new(l) }
@tenant_names = @tenants.map(&:name)
class TenantNamesNormalizer
def initialize(tenant_names, filter_by_letter:nil, sorted_in_reverse: false)
@tenant_names = tenant_names
@filter_by_letter = filter_by_letter
@sorted_in_reverse = sorted_in_reverse