x => x + 1 // similar to function(x) {return x + 1;}
(x, y) => x + y // similar to function(x, y) {return x + y;}
x => {return x + 1}
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 case_scram(str_): | |
""" inpUT a StRINg, reTUrN a stRINg with rANDoM upPer or lOWER caSE. | |
This was built for testing case-insensitivity. | |
""" | |
from random import choice | |
if not isinstance(str_, str): | |
return str_ | |
return "".join(choice((c.upper(), c.lower())) for c in str_) |
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 lowercase_everything(obj): | |
""" Recursively lowercase all elements - accepts list, str, tuple, dict, set """ | |
if isinstance(obj, dict): | |
return {k.lower(): _lowercase(v) for k, v in obj.items()} | |
elif (t := type(obj)) in (list, set, tuple): | |
return t(_lowercase(o) for o in obj) | |
elif isinstance(obj, str): | |
return obj.lower() | |
return obj |
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
/* Adds background gridlines for code blocks */ | |
div.input_area { | |
background: repeating-linear-gradient( | |
to right, | |
transparent, | |
transparent 3px, | |
rgba(180, 180, 40, 0.2) 3px, | |
rgba(180, 180, 40, 0.2) 4px, | |
transparent 4px, | |
transparent calc(2.4em + 3px), |
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
morsecode_map = dict(a=".-",b="-...",c="-.-.",d="-..",e=".",f="..-.",g="--.",h="....",i="..", | |
j=".---",k="-.-",l=".-..",m="--",n="-.",o="---",p=".--.",q="--.-",r=".-.", | |
s="...",t="-",u="..-",v="...-",w=".--",x="-..-",y="-.--",z="--..") | |
def reverse_python_dict(dict_: dict) -> dict: | |
return {dict_[k]:k for k in dict_} | |
def encode_morsecode(str_: str) -> str: |
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
prefix_letter = ['', 'A','B','C','D','E','F','G'] | |
next_letter = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'] | |
def excel_column_letters(columns_needed=None): | |
result = [] | |
for prefix in prefix_letter: | |
for letter in next_letter: | |
result.append(prefix + letter) | |
if columns_needed and isinstance(columns_needed, int): | |
return result[:columns_needed] |
Read the copy in the accordion sections for some info about how this was made.
A Pen by Ben Kremer on CodePen.
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
import random | |
people = ['alice', 'bob', 'carl', 'dave', 'asdf', 'sdfg', 'sdffg', 'erty', 'ertry'] | |
people = [1,2,3,4,5,6,7,8,9] | |
def make_groups(people): | |
result_groups = [] | |
current_group = [] | |
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
adrdash () | |
{ | |
networksetup -connectpppoeservice "L2TP VPN"; | |
open smb://username:password@192.168.25.13/Share/; | |
workon adr-dashboard; | |
git status; | |
git diff; | |
read -r -p "Everything good? Continue? [y/N] " response; | |
if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]; then | |
echo 'Continuing\n'; |
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
alias leetcode='cd ~/Dropbox/\ LEETCODE/ && jupyter notebook' | |
alias lc='leetcode' | |
alias leet='leetcode' | |
alias goopencv='deactivate || : && cd ~/Dropbox/\ CLASSES/LearnOpenCV_2021/ && source .venv/bin/activate && jupyter notebook' | |
#Energy Solution specific aliases | |
alias activate='source .venv/bin/activate' | |
alias act='activate' | |
alias deact='deactivate' |
NewerOlder