This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# mysqldump -u[root] -p[root_password] [database_name] > [dbdump].sql | |
mysqladmin -u[root] -p[root_password] drop [database_name] | |
sudo systemctl stop mariadb | |
sudo rm /var/lib/mysql/ibdata1 | |
sudo rm /var/lib/mysql/ib_logfile* | |
sudo systemctl start mariadb | |
# mysqladmin -u[root] -p[root_password] create [database_name] | |
# mysqladmin -u[root] -p[root_password] [database_name] < [dbdump].sql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create a load balancer | |
openstack loadbalancer create --name lb1 --vip-subnet-id <SubnetName("public")> | |
# Create a listener | |
openstack loadbalancer listener create lb1 --protocol HTTP --protocol-port 80 --name listener1 | |
# Create a pool | |
openstack loadbalancer pool create --lb-algorithm ROUND_ROBIN --listener listener1 --protocol HTTP --name pool1 | |
# Create a health monitor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create a flavor which would be used by the instance | |
openstack flavor create --id 0 --vcpus 1 --ram 2048 --disk 20 m1.small | |
#openstack flavor create --id 1 --vcpus 4 --ram 8192 --disk 80 m1.large | |
#openstack flavor create --id 2 --vcpus 8 --ram 16384 --disk 160 m1.xlarge | |
# create a network | |
openstack extension list -c Alias -c Name --network # list extensions within the system | |
openstack network create net1 | |
#openstack network create net2 --provider-network-type vxlan | |
openstack subnet create subnet1 --network net1 --subnet-range 192.0.2.0/24 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* https://www.baeldung.com/java-stack-heap */ | |
class Person { | |
int pid; | |
String name; | |
// constructor, setter/getters | |
} | |
public class Driver { | |
/** | |
* 1. Upon entering the main() method, a space in stack memory would be created to store primitives |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Using the synchronized keyword to protect blocks of code within a method. | |
This block is guarded by a key, which can be either a string or an object | |
This key is called the lock | |
*/ | |
public synchronized void critial() { | |
// some thread critical stuff | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -------- | |
# Hardware | |
# -------- | |
# Opcode - operational code | |
# Assebly mnemonic - abbreviation for an operation | |
# Instruction Code Format (IA-32) | |
# - Optional instruction prefix | |
# - Operational code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# String | |
string = "" | |
# Tuple | |
t = tuple() # (), (1,) | |
# List (Array) | |
l = [] | |
# Stack, LIFO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def quick_sort(arr): | |
smaller, equal, greater = [], [], [] | |
if len(arr) > 1: | |
pivot = arr[0] | |
for x in arr: | |
if x < pivot: | |
smaller.append(x) | |
elif x == pivot: | |
equal.append(x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def selection_sort(arr): | |
for i in range(len(arr)): | |
min_idx = i | |
for j in range(i+1, len(arr)): | |
if arr[min_idx] > arr[j]: | |
min_idx = j | |
arr[i], arr[min_idx] = arr[min_idx], arr[i] | |
return arr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def insertion_sort(arr): | |
for i in range(1, len(arr)): | |
cur_val = arr[i] | |
# indexes of the previous values | |
j = i-1 | |
while j>=0 and cur_val < arr[j]: | |
arr[j+1] = arr[j] | |
j -= 1 |
NewerOlder