Skip to content

Instantly share code, notes, and snippets.

my_thing.instance_eval { (class << self; self; end).instance_eval "include MyModule" }
def create_lambda
lambda {|i| puts "You're at #{i}" }
end
my_lam = create_lambda
[1,2,3].each &my_lam
#!/bin/bash
echo "Starting $@"
nohup "./$@" &> /dev/null &
@njpearman
njpearman / retag-script
Last active February 19, 2020 13:34
Reattaching tags to a rebased branch in a git repo
#!/bin/bash
# This script applies tags that have become detached from a rebased branch, assuming
# that the original message for each tag has been unchanged in the rebased branch.
# This is necessary because tags get bound to a commit hash and a rebase will alter
# the commit hashes on a branch, "detaching" any tags that have been attached. It is
# of course debatable whether tags _should_ be moved around at all, but I needed to
# do this for a particular repo I have been working on. It has also been a good
# opportunity for me to explore git and some command line tools. It is not meant to
# be a reference script and there will almost certainly be much more effective ways
@njpearman
njpearman / retag-with-date
Created February 11, 2020 12:56
Regenerate all tags with date set to that of the commit that was tagged
#!/bin/bash
# This script will regenerate every tag in a repository, setting the
# creation date of the tag to that of the commit that the tag is
# attached to. The message for the tag is set to the static string
# 'End of unit'.
git tag | while read tag;
do
git checkout ${tag}
@njpearman
njpearman / vim_journal_opener.vim
Created June 28, 2020 14:23
VimScript journal opener
" My first super-simple and hardcoded bit of VimScript
" that opens up a markdown-based journal file
function! JournalToday()
let filename = strftime("~/journal/%Y-%m-%d.markdown")
echo "Opened journal: " . filename
execute "vsplit" filename
endfunction
" executing a function is literal: enter command-line mode, enter call and the
" function name, and press return