Skip to content

Instantly share code, notes, and snippets.

View nick3499's full-sized avatar
🏠
Working from home

nick3499 nick3499

🏠
Working from home
  • USA
View GitHub Profile
@nick3499
nick3499 / desktop_bg_set.py
Last active April 5, 2021 15:30
Desktop Background Set: GNOME desktop background settings: subprocess.run(), os.listdir(), datetime, gsettings
#!/usr/bin/python3
'''Gnome desktop background settings.'''
from subprocess import run
from os import listdir
from datetime import datetime
WALLPAPERS = listdir('/home/foo/Pictures/Wallpapers')
D = {}
@nick3499
nick3499 / gradient_chart_256.py
Created January 20, 2021 04:20
Python: Generate 256-Color Gradient Chart
#!/usr/bin/env python
'''Generate gradient chart.'''
N = 16
def gen_gradient():
'''Generate gradient.'''
global N
f_str = f''
@nick3499
nick3499 / generate_design.py
Last active December 18, 2020 14:31
Python: Generate Desktop Background Design: random.randrange(), input(), for loop, terminal color formatting
#!/usr/bin/env python
'''Generate random colored background design.'''
from random import randrange
def generate_design():
'''Generate random background design.'''
print('\x1b[1;34mEnter hex color\x1b[0m: (example: 50514f) or leave blank')
hex1 = input('hex 1: ').upper() or '000000'
hex2 = input('hex 2: ').upper() or '000000'
@nick3499
nick3499 / beautifulsoup_html_parsing.ipynb
Last active December 3, 2020 21:02
BeautifulSoup HTML parser
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nick3499
nick3499 / index.htm
Created November 20, 2020 22:43
Pygal Bar Chart: Python, Flask, pygal, HTML, Jinja2, decorator
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Bar Chart: Fibonacci</title>
</head>
<body>
<!-- bar chart -->
<div><embed src={{ chart|safe }} /></div>
</body>
@nick3499
nick3499 / simple_gematria_converter.py
Created October 24, 2020 11:09
Simple Gematria Converter: dict, input(), list(), for loop,
#! /usr/bin/env python
'''`simple_gematria_converter` module contains `convert()` method which \
converts letters to simple gematria values.'''
def convert():
'''Convert alphabetical characters to numerological integers.'''
char_num = {
'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7,
'h': 8, 'i': 9, 'j': 10, 'k': 11, 'l': 12, 'm': 13, 'n': 14,
'o': 15, 'p': 16, 'q': 17, 'r': 18, 's': 19, 't': 20, 'u': 21,
'v': 22, 'w': 23, 'x': 24, 'y': 25, 'z': 26, ' ': ' '
@nick3499
nick3499 / convert_chars_from_utf8.py
Created October 5, 2020 17:04
Convert Characters from UTF-8 to Binary, Hexadecimal, Octal, Base64
#! /bin/python3
'''Given string, convert characters to hexadecimal, binary, hexadecimal and \
base64 values. Script available under MIT license: opensource.org/licenses/MIT'''
from base64 import b64encode as b64
def convert_chars():
'''Convert characters to hexadecimal, binary, hexadecimal and base64 \
values.'''
chr_keys = {
@nick3499
nick3499 / letter_subs.py
Last active June 5, 2023 15:25
Convert letters: Python3: input(), for loop, dictionary
#!/usr/bin/env python3
'''Convert characters to similar, random UTF-8 characters.'''
from random import randrange
def substitute():
'''Given text string, `substitute()` method substitutes characters.'''
char_dict = {
'a': ['à', 'á', 'â', 'ã', 'ä', 'å', 'ā', 'ă', 'ȃ', 'ą', 'ǎ', 'ȁ', 'ȧ',
'ɑ', 'ά'],
'A': ['À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Ā', 'Ă', 'Ȃ', 'Ą', 'Ǎ', 'Ȁ', 'Ȧ',
@nick3499
nick3499 / addBitwise.js
Created July 14, 2020 18:26
Bitwise Addition of Integers
#! /bin/nodejs
function addBitwise (a, b) {
// if `a` = `3` and `b` = `2`
let c = 0; // carry over
// loop while `b` is not equal to zero
while (b !== 0) {
// first iteration
c = a & b; // bitwise AND: 3/0011 AND 2/0010 --> 2/0010
a ^= b; // bitwise XOR: 3/0011 XOR 2/0010 --> 1/0001
@nick3499
nick3499 / totalInversions.js
Last active July 1, 2020 11:15
Nested For Loops for Numerical Inversions (Naive)
#! /bin/nodejs
function countInversions(a) {
var count = 0
for (let i=0; i<a.length; ++i) {
for (let j=i+1; j<a.length; ++j) {
if (a[i] > a[j]) {
count++
}
}