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2J6E2WX6AC
SC7MDSHCX3734KSWU4YFGJTKLJRSRM7AHC4MALZKQGDAHH42ILJQC
YH7BEHJP22AVP4S36VNNXSB7F44UBWA5MFVORNEBTIR4IO5MEZAAC
K25EHKGA7AW7YAZLYLB27DXGX4QPHFQEXU4B4S7WLRPVIV3WUJ7QC
3RG3K64UNBVMFYBBHNYCI7Y6GI7NZAHCCT76GMBBGK7PO4744BLAC
RTH5R4AZ2H4DORWS7UQFQ43K5Q24PIP7JVDN2HMMNIGUEMUUIWYQC
XZDJ2Z4M2MKWIDXN7EYBYQHGO7P5RSWPUGOQ3W2MHIUF55XQSXHQC
J4BENTWNXXU7ILVEJX2DTUVZ47R5FTQTJWZAQ4SXLFTZNO33QQXQC
THSBL5M5W2SACGBK3OUSOZ4J2KO3EJG6TALMPOONXZYPFKAS5UTAC
MAIEPZVQNNMHNN5MJ4UVPR5D7M3EE4B6QEBTR7L3KQERPUKOD5IQC
MA2CFUK6WX65WKLQ7RYEESOQ7HH3PFKW3FIPJCH7HASONV52PB7QC
TMO3SOZBNVAM5QFULQWSGJEODJ2MRY5EJSG2WGV6MIAPKF5YDMEAC
6A3T3RRKUBP2VMR7FFQJ5RNP62LAKUYDCCYRNHSXZR3O3Z73VZ5QC
4BXYTJPI3YWWXJ4JFUNFUO6ANCMJNALQ7L3XK3U3AXQGFDV7CAEQC
VSGSN57DJWUM5XTB76IDCPLWXQ7NWN2I25XROSZIFLF6PT5AVZOAC
O4DFDXEXZ7ONXUAKX4AKXXL5HXGWOG3T6N7R4JRICGF2OTQISIXQC
UPKMMJFFBYJRZHQDUNLVXKVJH32VNY5ZGEH3GXI3KOG7NO5OJF3AC
{ config, pkgs, ... }:
{
# List packages installed in system profile. To search by name, run:
# $ nix-env -qaP | grep wget
environment.systemPackages = with pkgs; [ git stow ];
nix.allowedUsers = [ "*" ];
# Use a custom configuration.nix location.
# $ darwin-rebuild switch -I darwin-config=$HOME/.config/nixpkgs/darwin/configuration.nix
environment.darwinConfig = "$HOME/.config/nixpkgs/darwin/configuration.nix";
# Auto upgrade nix package and the daemon service.
services.nix-daemon.enable = true;
nix.package = pkgs.nix;
# Create /etc/zprofile that loads the nix-darwin environment.
programs.zsh.enable = true; # default shell on catalina
# Used for backwards compatibility, please read the changelog before changing.
# $ darwin-rebuild changelog
system.stateVersion = 4;
}
function () {
# anonymous functions are evaluated without being called
# # so we're just using this to scope our variables
# lazy load functions defined in dotfiles/zsh/functions
local fns=$HOME/dotfiles/zsh/functions
local sure=$HOME/dotfiles/zsh/sure
fpath=($sure $fns $fpath)
for fn in $(ls $fns); do autoload $fn; done;
[[ -d $sure ]] && for fn in $(ls $sure); do autoload $fn; done;
}
if test $(uname) = "Darwin"; then
fpath=($fpath $macosfns)
[[ -d $macosfns ]] && for fn in $(ls $macosfns); do autoload $fn; done;
fi
local macosfns=$HOME/dotfiles/zsh/macos_functions
eval "$(direnv hook zsh)"
PATH=$HOME/.poetry/bin:$PATH
#! /usr/bin/env python3
from heapq import nlargest
import sys
import subprocess
def print_help_message_and_exit(exit_code=0):
USAGE:
$ srch PATTERN --top-N --flags-to-ripgrep --options-to-ripgrep
ARGUMENTS AND OPTIONS:
PATTERN: [ REQUIRED ] can be any valid regex pattern, it's passed directly to ripgrep
--top-N: [ OPTIONAL ] N is a number of results that you want to return.
--flags-to-ripgrep: [ OPTIONAL ] any valid ripgrep flags
--options-to-ripgrep: [ OPTIONAL ] any valid ripgrep options
EXAMPLE:
$ srch 'ticket_class' --top-5 -i -g '*event_service*' -t py
>>> will print the 5 files with top number of occurences of "ticket_class" case
insensitively that are in a path that contains "event_service" and are python
files
print(msg)
sys.exit(exit_code)
def parse_args(args): # noqa: C901
heap_size = 100
print_count = False
if args:
for arg in args:
print_help_message_and_exit()
print_count = True
else:
rg_args.append(arg)
return rg_args, heap_size, print_count
return print_help_message_and_exit(exit_code=1)
def run():
rg_args, heap_size, print_count = parse_args(sys.argv[1:])
results = []
for line in ripgrep.stdout:
results.append((int(count), path))
if print_count:
print(result[-1])
run()
if __name__ == "__main__":
print(f"{result[0]}:", end=" ")
for result in nlargest(heap_size, results, key=getitem(0)):
path, count = line.decode("utf-8").strip().split(":")
ripgrep = subprocess.Popen(" ".join(rg_args), shell=True, stdout=subprocess.PIPE)
elif "--top-" in arg:
heap_size = int(
"".join(filter(str.isdigit, arg)) or heap_size
) # prevent ValueError if no number
elif arg in ("-c", "--count"):
if arg == "--help":
rg_args = ["rg", "-c"]
"""
msg = """srch is a wrapper around ripgrep to sort search results by number of occurences.
from operator import getitem
#! /usr/bin/env python3
import sys
def print_help_and_exit(error_msg=None, error_code=0, print_help=True):
if error_msg:
if print_help:
USAGE: $ user_agent "{DESKTOP_EXAMPLE_STRING}"
>>> Chrome (60, 0, 3112) | Windows 7
HELP:
"Other () | Other" was returned - the user agent string you passed to this function was not recognized
print(msg)
sys.exit(error_code)
def parse(user_agent_raw_string):
from user_agents import parse
ua = parse(user_agent_raw_string)
def run():
try:
print(parse(sys.argv[1]))
except IndexError:
except ImportError:
TRY:
$ pip install user_agents
print_help_and_exit(error_msg=error_message, error_code=2)
run()
if __name__ == "__main__":
"""
error_message = """user_agents python package is required
print_help_and_exit(error_msg="argument is required", error_code=1)
return f"{ua.browser.family} {ua.browser.version} | {ua.os.family}{is_mobile}"
is_mobile = ": is mobile" if ua.is_mobile else ""
"""
msg = f""" user_agent accepts a user agent string from a browser and attempts to parse system information from it
print("ERROR:", f" {error_msg}", "\n", sep="\n")
MOBILE_EXAMPLE_STRING = "Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_3 like Mac OS X) AppleWebKit/603.3.8 (KHTML, like Gecko) FxiOS/8.3b5826 Mobile/14G60 Safari/603.3.8" # noqa
DESKTOP_EXAMPLE_STRING = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36" # noqa
function () {
for functions_group in $(ls $HOME/dotfiles/nixpkgs/shell/zsh_functions)
do
if [[ $functions_group =~ "macos" && $(uname) != "Darwin" ]]
then
continue
fi
full_path="$HOME/dotfiles/nixpkgs/shell/zsh_functions/$functions_group/"
fpath=("$full_path" $fpath)
for fn in $(ls "$full_path")
do
autoload $fn
done
done
}
eval "$(direnv hook zsh)"
PATH=$HOME/.poetry/bin:$PATH
{ config, pgks, ... }:
{
imports = [
../emacs
../firefox
../guiapps
../neovim
../python
../rust
../shell
../tmux
];
home.username = "chris";
home.homeDirectory = "/home/chris";
home.stateVersion = "21.05";
programs.home-manager.enable = true;
programs.git = {
enable = true;
userName = "Chris Cummings";
userEmail = "chris@thesogu.com";
extraConfig = { pull.rebase = true; };
};
home.sessionVariables = {
BROSWER = "firefox";
};
pam.sessionVariables = config.home.sessionVariables // {
LANGUAGE = "en_US:en";
LANG = "en_US.UTF-8";
LC_NUMERIC = "en_US.UTF-8";
LC_TIME = "en_US.UTF-8";
LC_MONETARY = "en_US.UTF-8";
LC_PAPER = "en_US.UTF-8";
LC_NAME = "en_US.UTF-8";
LC_ADDRESS = "en_US.UTF-8";
LC_TELEPHONE = "en_US.UTF-8";
LC_MEASUREMENT = "en_US.UTF-8";
LC_IDENTIFICATION = "en_US.UTF-8";
PAPERSIZE = "letter";
};
targets.genericLinux.enable = true;
xdg.enable = true;
xdg.mime.enable = true;
xdg.systemDirs.data = [
"/usr/share/pop"
"/home/chris/.local/share/flatpak/exports/share"
"/var/lib/flatpak/exports/share"
"/usr/local/share"
"/usr/share"
"/home/chris/.nix-profile/share"
"/home/chris/.nix-profile/share/applications"
];
}
{ }
let
template = import ./template.nix;
in
(template {
email = "chris@thesogu.com";
realName = "Chris Cummings";
imapHost = "imap.fastmail.com";
smtpHost = "smtp.fastmail.com";
}) // {
primary = true;
}
let
template = import ./template.nix;
in
(template {
email = "mistahchris@mac.com";
realName = "Chris Cummings";
imapHost = "imap.mail.me.com";
smtpHost = "smtp.mail.me.com";
})
### Notes
#### zsh
* if zsh start up is really slow, first try restarting computer, then try running zsh with `zsh -lvx`.