Skip to content

Instantly share code, notes, and snippets.

View compwron's full-sized avatar
💭
https://github.com/drop-ice/dear-github-2.0

compwron compwron

💭
https://github.com/drop-ice/dear-github-2.0
View GitHub Profile
@compwron
compwron / deadBeanFinder
Created October 10, 2012 05:03
finder for dead spring beans in a java codebase; if the usage is 0 or 1, it's probably dead.
`grep "bean id=" resources/*.xml`.split("\n").map{ |raw_bean|
raw_bean.split('"')
}.map {|bean_pieces|
bean_pieces[1]
}.map {|bean_name|
num = `find ./ -iname "*.java" -exec grep #{bean_name} '{}' \\; | wc -l`
puts "#{bean_name} #{num}"
}
@compwron
compwron / gist:5953652
Last active December 19, 2015 12:18
Idle speculation on what the break-even rate for a cab ride is
cab_driver_pay_per_hour = 8
average_cab_drivers_on_duty_per_hour = 100
dispatcher_pay_per_hour = 10
average_cab_driver_hours_worked_per_day = 10
cab_drivers_per_dispatcher = 50
average_miles_per_gallon = 30
average_miles_per_trip = 5
average_trip_duration = 20 # minutes
average_miles_per_minute = 30
hours_in_day = 24
@compwron
compwron / XMLGregorianCalendar from GregorianCalendar
Created September 19, 2013 02:19
XMLGregorianCalendar from GregorianCalendar
import org.junit.Test;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;
import static junit.framework.Assert.assertEquals;
@compwron
compwron / gist:6619138
Created September 19, 2013 04:28
timed test skip for JUnit
import org.joda.time.DateTime;
import org.junit.Test;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeTrue;
public class TimedIgnoreTest {
@Test
public void shouldRunBecauseAssumptionHasTimedOut() {
@compwron
compwron / Git source finder
Created September 30, 2013 19:11
Find all git project src urls in a directory (intended to help me know what is mine and what is not mine, and what to delete)
configs = `find . -name config | grep ".git"`
configs.split("\n").each{ |config|
puts config.gsub("/.git/config", "").gsub("./", "") + `grep "url =" #{config}`.gsub("url =", "") + "\n"
}
@compwron
compwron / gist:7838187
Last active June 20, 2016 23:53
Set annotation processing to "on" when using gradle idea plugin (Intellij 12)
idea.module {
testSourceDirs += file('src/test/unit/java')
testSourceDirs += file('src/test/unit/resources')
excludeDirs += 'file://$MODULE_DIR$/src/main/webapp/node_modules'
}
idea.project {
ipr.withXml { provider ->
def node = provider.asNode()
(use 'clojure.string)
(defn first-parts-are? [s test-string]
(let [cleaned-string (subs s 0 (min
(count test-string)
(count s)))]
(= test-string cleaned-string)))
(defn is-a-comment [line]
(some true? (map
(partial first-parts-are? line)
@compwron
compwron / gist:9004950
Created February 14, 2014 17:09
gradlew
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@compwron
compwron / gist:0499c61ba441e3e8cb4a
Created July 1, 2014 20:08
vim tmux practice navigation setup generator
class Tvcom
attr_reader :command
attr_accessor :valid
def initialize(foo, valid)
@command = foo
@valid = valid
end
def flip
files = `git ls-files | grep -v vendor`.split("\n")
a = files[Random.new.rand(files.size)]
p a
`open -a "/Applications/Sublime\ Text.app/" #{a}`