diff --git a/content/blog/cloc.md b/content/blog/cloc.md new file mode 100644 index 0000000..a7ac193 --- /dev/null +++ b/content/blog/cloc.md @@ -0,0 +1,42 @@ +--- +title: "cloc" +date: 2020-01-25T10:24:16-05:00 +draft: false +images: [] +--- + +**C**ount **L**ines **o**f **C**ode is an application included in the standard Ubuntu repositories that counts the lines of code separated by programming language. + +It is able to separate out blank lines, comment lines, and actual code lines in the count. It's quick and easy to use for giving a quick statistic on any given code repository. + +To count lines of code in the current directory, + +```bash +cloc . +``` + +An example from my website repository: + +``` +1019 text files. +894 unique files. +158 files ignored. + +github.com/AlDanial/cloc v1.82 T=0.58 s (1501.1 files/s, 213974.9 lines/s) +----------------------------------------------------------------------- +Language files blank comment code +----------------------------------------------------------------------- +HTML 581 14457 4041 69754 +Markdown 248 6758 0 14620 +XML 9 1201 0 5291 +JavaScript 8 478 1282 2623 +JSON 11 0 0 1875 +CSS 7 216 47 1048 +TOML 3 22 17 120 +SVG 1 2 0 20 +Bourne Shell 1 0 0 3 +----------------------------------------------------------------------- +SUM: 869 23134 5387 95354 +----------------------------------------------------------------------- +``` + diff --git a/content/blog/pythoninterrupts.md b/content/blog/pythoninterrupts.md new file mode 100644 index 0000000..dbe69d5 --- /dev/null +++ b/content/blog/pythoninterrupts.md @@ -0,0 +1,24 @@ +--- +title: "Quick Python: Interrupts" +date: 2020-01-25T09:51:34-05:00 +draft: false +images: [] +--- + +This post is part of a new series I'm starting where I quickly outline small Python snippets. + +If you have an application that you want to gracefully exit when the user presses CTRL-C here's the short snippet +```python +import signal +import sys + +# Function that gets called when interrupt is found +def signal_handler(sig, frame): + print('You pressed Ctrl+C!') + sys.exit(0) + +# Attach the function to the interrupt signal +signal.signal(signal.SIGINT,signal_handler) + +print('Press Ctrl+C') +``` diff --git a/content/blog/zshandsnaps.md b/content/blog/zshandsnaps.md new file mode 100644 index 0000000..591dc9b --- /dev/null +++ b/content/blog/zshandsnaps.md @@ -0,0 +1,41 @@ +--- +title: "Zsh and Snaps" +date: 2020-01-25T09:46:23-05:00 +draft: false +images: [] +--- + +In case I forget again, by default when snaps are installed it doesn't populate in the `zsh` shell. To enable this add the following to `/etc/zsh/zprofile` + +```bash +emulate sh -c 'source /etc/profile.d/apps-bin-path.sh' +``` + +In case you don't have `apps-bin-path.sh` in `/etc/profile.d/`, then here's the file as of this date: + +```bash +# shellcheck shell=sh + +# Expand $PATH to include the directory where snappy applications go. +snap_bin_path="/snap/bin" +if [ -n "${PATH##*${snap_bin_path}}" -a -n "${PATH##*${snap_bin_path}:*}" ]; then + export PATH=$PATH:${snap_bin_path} +fi + +# Ensure base distro defaults xdg path are set if nothing filed up some +# defaults yet. +if [ -z "$XDG_DATA_DIRS" ]; then + export XDG_DATA_DIRS="/usr/local/share:/usr/share" +fi + +# Desktop files (used by desktop environments within both X11 and Wayland) are +# looked for in XDG_DATA_DIRS; make sure it includes the relevant directory for +# snappy applications' desktop files. +snap_xdg_path="/var/lib/snapd/desktop" +if [ -n "${XDG_DATA_DIRS##*${snap_xdg_path}}" -a -n "${XDG_DATA_DIRS##*${snap_xdg_path}:*}" ]; then + export XDG_DATA_DIRS="${XDG_DATA_DIRS}:${snap_xdg_path}" +fi +``` + +Source: [hackel](https://askubuntu.com/users/263969/hackel) on [Ask Ubuntu](https://askubuntu.com/questions/910821/programs-installed-via-snap-not-showing-up-in-launcher). +