Skip to content

Instantly share code, notes, and snippets.

View jmondo's full-sized avatar

John Gesimondo jmondo

View GitHub Profile

How do repos with magical name based lookups work?

To repro, put a debugger in org.springframework.data.repository.core.support.RepositoryFactorySupport#getRepository(java.lang.Class<T>, org.springframework.data.repository.core.support.RepositoryComposition.RepositoryFragments)

How Repos are initialized

Includes parsing the magical method name syntax

Repos are registered as beans on app boot, then their proxies are created lazily when you first autowire the repo.

@jmondo
jmondo / copy_ruby_class.py
Last active May 2, 2022 20:33
Copy ruby class sublime plugin
# Installation
# Go to Tools > Developer > New Plugin, copy this code, save it.
# Then open the key bindings file and add something like
# { "keys": ["super+k", "super+c"], "command": "copy_ruby_class_window" }
# Usage
# With any ruby file open call this command to copy the class name (including all the nested modules) to clipboard.
# Shoutout to https://github.com/astrauka/TestRSpec plugin for the parsing/re logic
import sublime
@jmondo
jmondo / admin_helper.rb
Last active August 29, 2015 14:26
super simple way to display most objects for an admin system (array, AR relation, integers, strings, etc.) also links to associated record when possible.
# WHAT IT DOES:
# with these models ->
# book has author
# author has friendly_name method that points to title
# chapter_pages is a hash with keys of chapters, values of the page they start on
# it does these things ->
# object_for_admin(book.author)
@jmondo
jmondo / user.rb
Created June 30, 2015 21:52
gotta love ruby
def any_family_members_trying_to_lose_weight?
family_members.any?(&:trying_to_lose_weight?)
end
@jmondo
jmondo / deploy.rake
Last active August 29, 2015 14:06 — forked from J3RN/deploy.rake
# Deploy and rollback on Heroku in staging and production
task :deploy_staging => ['deploy:set_staging_app',
'deploy:push',
'deploy:migrate',
'deploy:restart']
task :deploy_production => ['deploy:set_production_app',
'deploy:push',
'deploy:migrate',
'deploy:post_deploy',
'deploy:restart']
@jmondo
jmondo / simple_delegator_example.rb
Last active December 26, 2015 16:09
simple delegator example from sfrails oct 2013
# it's all part of ruby!
require 'ostruct'
require 'delegate'
require 'forwardable'
require 'minitest/autorun' # can run rspec style tests with this, part of ruby
# ---------------------------------------------------------------------------------------------------------
# the classes
# using simple delegator with the country object /after/ this app has been made with bad dependency mgmt.
# we swap the country string 'FIN' out for a country object with Country.new('FIN')
@jmondo
jmondo / rspec_asserting_position.md
Created June 27, 2012 03:42
Asserting position blog post draft 1

layout: post title: "Rspec: Asserting Positions The Right Way" date: 2012-06-26 18:25 comments: true categories:

  • rails
  • Rspec
  • integration keywords:
@jmondo
jmondo / ubuntu-setup.md
Created April 1, 2012 01:41
Setting up Rails server environment on Ubuntu 11.10

Setting up Rails server environment on Ubuntu 11.10

Including Rails, Passenger, RVM, Ruby 1.9.3, SSH keys, Postgres and a test app

Instructions

  • This is tested on a clean install of Ubuntu 11.10 server (with SSH root access), though it should work on whatever install you have now.
  • Replace LOGIN with your ubuntu username
  • Replace SERVER_ADDRESS with the IP address of your server