View keycloak auth server setup with nginx reverse proxy and letsencrypt certs (for https)
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
# first update and upgrade the server | |
sudo apt update -y | |
sudo apt upgrade -y | |
# install nginx for reverse proxy | |
sudo apt install nginx -y | |
# create a new file with the name, say, "keycloak_auth_server" (without any extension) inside the /etc/nginx/sites-available directory | |
# add the below configuration in that file | |
server{ |
View .gitignore
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
# Created by https://www.toptal.com/developers/gitignore/api/windows,linux,macos,java,java-web,intellij,intellij+all,intellij+iml,eclipse,maven | |
# Edit at https://www.toptal.com/developers/gitignore?templates=windows,linux,macos,java,java-web,intellij,intellij+all,intellij+iml,eclipse,maven | |
### Eclipse ### | |
.metadata | |
bin/ | |
tmp/ | |
*.tmp | |
*.bak | |
*.swp |
View medium_tf_model_builder.py
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 model_builder(hp): | |
if TASK == "r": | |
loss_fn = "mean_absolute_error" | |
elif TASK == "c": | |
if OUTPUT_NODES == 1: | |
loss_fn = tf.keras.losses.BinaryCrossentropy(from_logits=True) | |
else: | |
loss_fn = tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True) | |
if TASK == "r": |
View medium_tf_string_input_processor.py
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 string_input_processor(inputs): | |
if not inputs: | |
return | |
vocabularies = defaultdict(set) | |
for batch, _ in get_dataset(batch_size=BATCH_SIZE): | |
for col_name in inputs.keys(): | |
for st in np.array(batch[col_name]).astype("str"): | |
vocabularies[col_name].add(st.lower().strip()) |
View medium_tf_numerical_input_processor.py
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 numerical_input_processor(inputs): | |
if not inputs: | |
return | |
concat = None | |
if len(inputs.values()) > 1: | |
concat = tf.keras.layers.Concatenate()(list(inputs.values())) | |
norm = tf.keras.layers.experimental.preprocessing.Normalization() |
View movie_magnet.py
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
#! /usr/bin/env python3 | |
""" | |
Install these packages before running the script | |
beautifulsoup4==4.9.0 | |
bs4==0.0.1 | |
certifi==2020.4.5.1 | |
chardet==3.0.4 | |
idna==2.9 |
View sudoku_solve.py
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 search(grid_dict): | |
# try to solve the board | |
grid_dict = run_episode(grid_dict) | |
if grid_dict is False: | |
# it means the current configuration of the board is unsolvable | |
# this happens when any of the boxes have no possible value to fix |
View sudoku_run_episode.py
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 run_episode(grid_dict): | |
stuck = False | |
while not stuck: | |
# Check how many boxes have a fixed value | |
solved_values_before = len([box for box in grid_dict.keys() if len(grid_dict[box]) == 1]) | |
# Use the Eliminate Strategy | |
grid_dict = eliminate(grid_dict) | |
# Use the Only Choice Strategy |
View sudoku_only_choice.py
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 only_choice(grid_dict): | |
for unit in unit_list: | |
for num in '123456789': | |
num_places = [box for box in unit if num in grid_dict[box]] | |
if len(num_places) == 1: | |
grid_dict[num_places[0]] = num | |
return grid_dict |
View sudoku_eliminate.py
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 eliminate(grid_dict): | |
for k,v in grid_dict.items(): | |
if len(v) != 1: # if the box needs elimination | |
peers = peer_dict[k] # get all the peers | |
peer_values = set([grid_dict[p] for p in peers if len(grid_dict[p]) == 1]) | |
grid_dict[k] = ''.join(set(grid_dict[k]) - peer_values) | |
return grid_dict |
NewerOlder