Skip to content

Instantly share code, notes, and snippets.

View keycloak auth server setup with nginx reverse proxy and letsencrypt certs (for https)
# 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{
@zahash
zahash / .gitignore
Created Apr 29, 2021
java spring boot gitignore
View .gitignore
# 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
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
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
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()
@zahash
zahash / movie_magnet.py
Last active Apr 27, 2020
get torrent magnet links of movies
View movie_magnet.py
#! /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
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
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
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
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