Skip to content

Instantly share code, notes, and snippets.

;;; Helper functions
(defun setup-go-mode ()
(require 'go-guru)
(add-hook 'before-save-hook 'gofmt-before-save)
(setq fill-column 80)
(setq indent-tabs-mode 1)
(setq tab-width 2)
(setq gofmt-command "goimports")
(go-guru-hl-identifier-mode)

Keybase proof

I hereby claim:

  • I am jtrim on github.
  • I am jessetrimble (https://keybase.io/jessetrimble) on keybase.
  • I have a public key ASDuRkIsH2pYoAsTtZLJPHLNggBWU6OEfS8_fNXVktCrQAo

To claim this, I am signing this object:

(require 'seq)
(defun magit-rspec-run-changed-files ()
(interactive)
(let ((changed-files (seq-filter 'magit-rspec--spec-file-p (mapcar 'car (magit-file-status)))))
(rspec-run-multiple-files changed-files)))
(defun magit-rspec--spec-file-p (filename)
(string-suffix-p "_spec.rb" filename))
package main
import (
"image"
"image/png"
"os"
)
func Show(f func(int, int) [][]uint8) {
const (
# Example for https://twitter.com/jessetrimble/status/910940206924050432
def test_matches_fixture_document
(1..3).each do |row_number|
expected_value = fixture_spreadsheet.cell(row, "A")
assert_equal get_value_from_db, expected_value
end
end
###### Refactored to:

Installing Ruby 2.3 on Fedora 26

As of this writing (2017-07-24), Ruby 2.3.4 doesn't build on Fedora 26 because of GCC 7 and openssl 1.1 being the defaults.

Fedora 26 allows for installation of only Ruby 2.4 from the default repositories. My preference for Ruby management on Linux are chruby and ruby-install. To install Ruby 2.3 on Fedora 26 with ruby-install:

  • Download openssl 1.0.2l
  • Unpack the openssl archive, then from within the openssl dir, build and install openssl, then link the CA cert bundle and certs dir into place into the new install:
    • $ ./config --prefix=/usr/local/openssl-1.0.2l shared
  • $ sudo make install
require 'yaml'
require 'busted'
require 'ostruct'
obj = Object.new
module Stuff
def bar
end
end
@jtrim
jtrim / with_retry.rb
Last active October 21, 2015 21:08
A (mostly) referentially-transparent retry method in Ruby that doesn't mutate local state.
def with_retry(timeout=0.25, tries=3)
exception = \
tries.times.reduce(nil) do
begin
result = yield
rescue StandardError => ex
sleep timeout
ex
else
return result
Plugin 'junegunn/goyo.vim'
" ===================
" Goyo
" ===================
function! s:goyo_enter()
setlocal wrap linebreak nolist
set virtualedit=
setlocal display+=lastline
noremap <buffer> <silent> k gk
#!/usr/bin/env ruby
require 'pathname'
def print_usage
puts "USAGE: test-unit-runner path/to/spec.rb[:<line-number>]"
end
unless ARGV.first
print_usage
exit 1