Value | Color | Category | Value | Color | Category |
---|---|---|---|---|---|
\e[0;39m | Default color | Foreground | \e[0;49m | Default color | Background |
\e[0;30m | Black | Foreground | \e[0;40m | Black | Background |
\e[0;31m | Red | Foreground | \e[0;41m | Red | Background |
\e[0;32m | Green | Foreground | \e[0;42m | Green | Background |
\e[0;33m | Yellow | Foreground | \e[0;43m | Yellow | Background |
\e[0;34m | Blue | Foreground | \e[0;44m | Blue | Background |
This file contains hidden or 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
# In order to make all the scripts below work, create .colors.csv file with the colors of your choice and drop it in the | |
# home directory. Since the file starts with . [dot], it won't be visible, yet one can always delete it with rm -r command. | |
# I think it's better to make it invisible since it's not a file to be used regularly and it might accidentally get deleted. | |
# Also, you can customize and create as much themes as you wish with combining different font styles/colors and background | |
# and foreground colors. | |
# I find these themes extremely handy when it comes to presentations or even switching colors for the daily usage (e.g. when | |
# it's dark, one might want use colors which are a little bit brighter or maybe even darker according to his/her needs | |
# and doing it manually is a big pain). |
This file contains hidden or 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
""" | |
Author: David Oniani | |
Created: May 22, 2019 | |
License: GNU General Public Licence v3.0 | |
""" | |
def longest_in_columns(table) -> int: | |
"""A simple function to find the longest string sizes for each column.""" | |
# This is a neat way of getting columns |
This file contains hidden or 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 remove_trailing_whitespace(file): | |
""" | |
Function to remove the trailing whitespace | |
and add a newline in the end. | |
""" | |
with open(file, 'r+') as file: | |
new_file = [] | |
for line in file: | |
new_file.append(line.rstrip()) | |
file.truncate(0) |
This file contains hidden or 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
# Customized '.zshrc' file by David Oniani | |
# Licensed under MIT | |
# Copyright (c) 2018 David Oniani | |
# If you come from bash you might have to change your $PATH. | |
export PATH=$HOME/bin:/usr/local/bin:$PATH | |
# Homebrew settings | |
export PATH=/usr/local/bin:/usr/local/sbin:$PATH |
This file contains hidden or 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
from collections import deque | |
def generate_graph(): | |
""" | |
Generate a weighted, directed or undirected graph. | |
NOTE: A weighted graph is represented as a map of maps. | |
""" | |
graph = {} |
This file contains hidden or 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
-- Change the prompt to lambda | |
:set prompt "\ESC[34mλ> \ESC[m" | |
-- Show the types of evaluated expressions | |
:set +t | |
-- Show statistics | |
:set +s | |
-- Aliases |
This file contains hidden or 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
""" | |
A generic Q-learning algorithm | |
Author: David Oniani | |
License: MIT | |
""" | |
import numpy as np | |
import random | |
import gym |
This file contains hidden or 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
from collections import deque | |
def BFS(graph, start): | |
visited = set() | |
new_deque = deque([start]) | |
while new_deque: | |
node = new_deque.popleft() | |
if node not in visited: |
This file contains hidden or 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
/// Filename: binary_search.rs | |
/// Author: David Oniani | |
/// Date: August 21, 2019 | |
/// | |
/// Slices are powerful! | |
/// | |
extern crate rand; | |
use rand::Rng; | |
/// A simple recursive binary search in Rust |
OlderNewer