Skip to content

Instantly share code, notes, and snippets.


Lenny Marks lenny

  • American Physical Society
  • Long Island, NY
View GitHub Profile
View tmux.conf
# switch C-b -> C-a
set -g prefix C-a
unbind C-b
bind C-a send-prefix
# quick pane cycling
unbind ^A
bind ^A select-pane -t :.+
# mouse support
lenny / test.clj
Last active Jan 18, 2017
Snippet showing clojure.spec instrumentation with stubbing through deftest
View test.clj
(defn assert-valid [spec-check]
(let [failure (-> spec-check first :failure)]
(is (nil? failure))))
(deftest manifest
(let [find-spec (s/fspec :args (s/cat :id ::submission-directory/id)
:ret (s/or :found ::submission-directory/submission-directory :not-found nil?))]
(stest/instrument ['submissions-svr.db.submission-directories/find `submission/manifest-files]
{:spec {'submissions-svr.db.submission-directories/find find-spec}
lenny / safari.js
Created Dec 2, 2016
Modified version of James' script that bombs out with error when bug is detected
View safari.js
/* selenium webdriver safari 10 OSX Sierra testing
[Error] Failed to load resource: The network connection was lost.
Note: Script is unable to capture console log errors. Error occurs
when page is blank
Error occurs for the following urls
Running script:
Install node js v7.2.0
View background_job_watcher.rb
class BackgroundJobWatcher
attr_accessor :mailer, :error_io
class << self
def attempt(job_name, &blk)
new.attempt(job_name, &blk)
def initialize(opts = {})
lenny / fix_amp_eq.rb
Last active Aug 29, 2015
Script used while upgrading from Rails 2 to Rails 3/4
View fix_amp_eq.rb
dir = ARGV[0]
raise "Usage: #{$0} <DIR>" if dir.nil?
Dir[File.join(dir, '**/*.haml')].each do |f|
s =
lines = []
s.each_line do |l|
l = l.gsub('&=', '=')
lenny / A.rb
Created May 29, 2012
BDD example
View A.rb
describe ResubmissionsController do
# Probably not the most ideal start-off point
# since it is fairly rare un-RESTFul action, but....
describe '#mark_as_processed' do
it 'responds with 404:not_found when no matching resubmissions were found' do
response.status.should == 404
View gist:1700352
module WordListMacros
def it_strips_double_quotes
it "strips double quotes" do
subject.list_of_words = %w("foo" "bar")
subject.list_of_words.should eq(%w(foo bar))
def it_strips_single_quotes
it "strips single quotes" do
lenny / java_classpath.rb
Created Jan 9, 2012
Java Classpath Helper
View java_classpath.rb
class JavaClasspath
class << self
def bootstrap(jar_dirs, classpath_dirs)
jar_dirs.each do |jardir|
Dir.entries(jardir).grep(/\.jar$/) {|jar| add_expanded_path(File.join(jardir, jar))}
classpath_dirs.each do |cp_dir|
lenny /
Created Jan 4, 2012
Custom Log4j appender to log messages into database via Hibernate
package org.aps.webprowo.hibernate;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Vector;
import org.apache.log4j.Appender;
import org.apache.log4j.AppenderSkeleton;
import org.apache.log4j.spi.LoggingEvent;
import org.aps.eop.dao.DataAccessUtils;
lenny /
Created Dec 21, 2011
ruby block interface for anonymous class
public interface TxCallback {
public Object execute(TransactionHolder txHolder) throws Exception;