Skip to content

Instantly share code, notes, and snippets.

View Akasurde's full-sized avatar
🌏
To the infinity and beyond

Abhijeet Kasurde Akasurde

🌏
To the infinity and beyond
View GitHub Profile
- name: Remove nth element from the list
debug:
msg: |
{% set _ = my_list.pop(index) %}
{{ my_list }}
vars:
my_list: [1, 2, 3, 4, 5, 6]
index: 2
@Akasurde
Akasurde / ndef_multiple_record_example.py
Created July 7, 2022 14:53
Encode and decode multiple records
import ndef
import codecs
text_record = (
(ndef.TNF_WELL_KNOWN, ndef.RTD_TEXT, b'id', b'hello world'),
(ndef.TNF_WELL_KNOWN, ndef.RTD_TEXT, b'id', b'hello world 2'),
(ndef.TNF_URI, ndef.RTD_URI, b'id', b'https://github.com'),
)
text_message = ndef.new_message(*text_record)
text_raw_ndef = text_message.to_buffer()
@Akasurde
Akasurde / ndef_example.py
Created July 7, 2022 14:39
Encode and decode ndef message
import ndef
import codecs
text_record = (ndef.TNF_WELL_KNOWN, ndef.RTD_TEXT, b'id', b'hello world')
text_message = ndef.new_message(text_record)
text_raw_ndef = text_message.to_buffer()
encoded_hello_world = codecs.encode(text_raw_ndef, 'hex_codec')
decoded_hello_world = codecs.decode(encoded_hello_world, 'hex_codec')
---
- hosts: localhost
gather_facts: no
vars:
name: "abhi"
tasks:
- name: Print variable
debug:
msg: "{{ name }}"
apiVersion: v1
kind: Pod
metadata:
labels:
app: pod6
name: pod6
namespace: default
spec:
containers:
- args:
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
name: "trivy-scanner.example.com"
webhooks:
- name: "trivy-scanner.example.com"
rules:
- apiGroups: [""]
apiVersions: ["v1"]
operations: ["CREATE"]
from subprocess import Popen
from flask import Flask, request, jsonify
admission_controller = Flask(__name__)
@admission_controller.route("/validate", methods=["POST"])
def deployment_webhook():
request_info = request.get_json()
import pytest
import re
from six import PY2
def check_solaris_version(filename='/etc/release'):
with open(filename) as f:
content = f.readlines()
for line in content:
m = re.match(r'\s+Oracle Solaris (\d+\.\d+).*', line.rstrip())
@Akasurde
Akasurde / mysql_pod.yml
Created March 9, 2021 04:40
Create MySQL database pod with preloaded data
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql-deployment
labels:
app: mysql
spec:
replicas: 1
selector:
matchLabels:
@Akasurde
Akasurde / moid_datastore.yml
Created March 2, 2021 09:49
Rename datastore object using MoID
---
- hosts: localhost
gather_facts: no
vars_files:
- vcenter_vars.yml
vars:
datastore_name: "DS_117_1"
tasks:
- name: Provide information about datastore {{ datastore_name }}
community.vmware.vmware_datastore_info: