Skip to content

Instantly share code, notes, and snippets.

View NamrataSitlani's full-sized avatar

Namrata Sitlani NamrataSitlani

View GitHub Profile
@NamrataSitlani
NamrataSitlani / gist:e0a90510193de54bd6ef4ca6515999f8
Last active September 5, 2023 14:45
Setting up internal DNS resolution with OVN
The Networking service enables users to control the name assigned to ports by the internal DNS.
To enable this functionality when you have deployed the openstack using kolla-ansible, do the following to override the exsting configuration:
1.Edit the /etc/kolla/config/neutron.conf file and assign a value different to openstacklocal (its default value) to the dns_domain parameter in the [default] section. As an example:
```
[DEFAULT]
dns_domain = example.org.
```
@NamrataSitlani
NamrataSitlani / a.sh
Created April 24, 2021 14:30
File for creating an openstack stack
openstack stack create -t a.yaml namrata
@NamrataSitlani
NamrataSitlani / pig_latin_sentence.py
Created September 13, 2020 14:27
Write a function that converts a sentence into Pig Latin. https://en.wikipedia.org/wiki/Pig_Latin#Rules
def pig_latin_sentence(sentence):
VOWELS = "aeiou"
new_sentence = []
for word in sentence.split():
consonants = 0
if word[0].lower() in VOWELS:
new_sentence.append(word + 'yay')
continue
for letter in word.lower():
if letter not in VOWELS:
@NamrataSitlani
NamrataSitlani / stockBuySell.py
Created September 5, 2020 18:44
Given an array of numbers that represent stock prices (where each number is the price for a certain day), find 2 days when you should buy and sell your stock for the highest profit.
def stockBuySell(stock_list):
buy = stock_list.index(min(stock_list)) +1
sell = stock_list.index(max(stock_list)) +1
return f'buy on day {buy}, sell on day {sell}'
if __name__ == '__main__':
stock_list = [110, 180, 260, 40, 310, 535, 695]
print(stockBuySell(stock_list))
@NamrataSitlani
NamrataSitlani / numChars.py
Last active August 25, 2020 19:47
Given a string s and a character c, return the number of occurrences of c in s.
def numChars(string, word):
count = 0
for i in list(string):
if word in i:
count+= 1
print(count)
numChars("oh heavens", "h")
@NamrataSitlani
NamrataSitlani / findmedian.py
Created July 19, 2020 19:56
Given an unsorted array arr of integers and an index n, return a list of medians of the subarrays in arr (where the first subarray is from index 0 to index 1, the next from 0 to index 2… index 0 to index n)
def median(list1):
length = len(list1)
list1.sort()
if length %2 == 0:
median1 = list1[length//2]
median2 = list1[length//2 - 1]
median = (median1 + median2)/2
else:
median = list1[length//2]
@NamrataSitlani
NamrataSitlani / Linkedlist.py
Created July 17, 2020 12:59
Insert a node in a sorted Linked List
class Node:
def __init__(self,data):
self.data = data
self.next = None
class LinkedList:
def __init__(self):
self.head = None
def sortedInsert(self, new_node):
if self.head is None:
new_node.next = self.head