Skip to content

Instantly share code, notes, and snippets.

Raymond Finzel rfinz

Block or report user

Report or block rfinz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rfinz
rfinz / send-region-to-sh.el
Created May 15, 2018
Saving a fun snippet from Stack Overflow for sending emacs regions to shell
View send-region-to-sh.el
;;;; https://stackoverflow.com/a/7053298/1096485
(defun sh-send-line-or-region (&optional step)
(interactive ())
(let ((proc (get-process "shell"))
pbuf min max command)
(unless proc
(let ((currbuff (current-buffer)))
(shell)
(switch-to-buffer currbuff)
@rfinz
rfinz / DigitalOceanFreeBSDrc.subr
Created Oct 20, 2017
rc.subr for DO in case in gets borked in a merge
View DigitalOceanFreeBSDrc.subr
# $NetBSD: rc.subr,v 1.67 2006/10/07 11:25:15 elad Exp $
# $FreeBSD: releng/11.1/etc/rc.subr 310010 2016-12-13 04:50:45Z dteske $
#
# Copyright (c) 1997-2004 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by Luke Mewburn.
#
# Redistribution and use in source and binary forms, with or without
@rfinz
rfinz / nap.rb
Created Jan 12, 2016 — forked from siers/nap.rb
a more natural alarm clock command line interface
View nap.rb
#!/usr/bin/env ruby
require 'time'
def die(str)
$stderr.puts str
exit
end
def usage
View bash_snippets.sh
find /path/to/files* -mtime +5 -exec rm {} \; # delete files older than 5 days
find /path/to/files* -type d -mtime +5 -mindepth 1 -exec rm -r {} \; # delete folders older than 5 days
find ~salsa-server/.salsa.d/latest -regextype posix-egrep -regex '^TPMRO1Agile-cpdec[0-9]{3}-[0-9]{1}-[0-9]{10}-PictureDescription\.[0-9a-zA-Z]+-[0-9a-zA-Z_-]+(Response|\.txt)$' -exec cp {} /home/data/tpmdata/PD \; #find files matching regex and copy them to new folder
tar cf - /folder-with-big-files -P | pv -s $(du -sb /folder-with-big-files | awk '{print $1}') | gzip > big-files.tar.gz # see progress when compressing large data
pdftotext my.pdf - | grep 'pattern' # grep in pdf
find /path -iname '*.pdf' -exec pdfgrep pattern {} + # another grep in pdf solution using pdfgrep
for i in *.txt; do content=$(<$i); echo "{\"text\": \"${content}\"}" >> texts.jsonl; done # echo all txt files into a jsonl file
for i in *.xml; do mv $i "${i%.xml}.txt"; done # change the extension of a bunch of files (in this case xml to txt)
View git_snippets
find . -name .DS_Store -print0 | xargs -0 git rm --ignore-unmatch
git rev-list --all|tail -n1|xargs git show|grep -v diff|head -n1|cut -f1-3 -d' '
git rev-list HEAD -1 -- path/to/file # show commit hash of most recent revision of file
@rfinz
rfinz / indicators.md
Last active Jan 1, 2016
Finzel Indicators, a list of personal indicators for tracking taste and lifestyle over the next indeterminate number of years.Fill out a new one before looking at any past answers.
View indicators.md

Personal Culture:

  1. What is your favorite band?
  2. What is the genre of music you listen to most?
  3. What is your favorite pastime?
  4. How do you spend most of your free time?
  5. What is the most irksome thing in your day-to-day?
  6. What do you admire?
  7. Where do you work?
  8. Is there anywhere you'd rather work? Where?
@rfinz
rfinz / ModelDB.py
Last active Dec 20, 2015
Snippet that initializes a DB with all the tables defined in a peewee ORM model... in this case "MariaModel". Add tables to the model at any point and the program should be able to set up the DB programmatically.
View ModelDB.py
for t in [ name for name,c in \
inspect.getmembers(sys.modules[__name__],inspect.isclass) \
if issubclass(c, MariaModel) and not c is MariaModel]:
try:
globals()[t].create_table()
except Exception as e:
print e
You can’t perform that action at this time.