This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Playing with java topology suite in jruby | |
require 'java' | |
require 'rubygems' | |
require 'mvn:com.vividsolutions:jts' | |
java_import "com.vividsolutions.jts.geom.PrecisionModel" | |
java_import "com.vividsolutions.jts.geom.GeometryFactory" | |
java_import "com.vividsolutions.jts.geom.Coordinate" | |
java_import "com.vividsolutions.jts.geom.Point" | |
java_import "com.vividsolutions.jts.geom.LineString" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ChordDSL | |
def chord(file_path, &block) | |
chord = Chord.new | |
chord.file_path = file_path | |
chord_ctx = ChordContext.new chord | |
chord_ctx.instance_exec &block | |
chord.save! | |
end | |
class ChordContext |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'sql_mapper' | |
# sql_mapper is built on top of ActiveRecord and is meant to augment it in this specific case: 1. You | |
# want fast read access for large data sets, 2. the data can be flat (denormalized) and 3. you don't | |
# need AR's magic. It also assumes the ability to comfortably craft raw sql. Sql is a data retrieval DSL | |
# after all ;) | |
ActiveRecord::Base.establish_connection :adapter => 'sqlite3', :database => ':memory:' | |
conn = ActiveRecord::Base.connection | |
conn.execute 'create table foos (id serial, name string)' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'service_locator' | |
# Declare our services | |
Services.instance.config do | |
service :first, "this is" | |
service :second, " a test" | |
end | |
# See that ServiceDependent has convenience methods defined to access services. | |
puts ServiceDependent.instance_methods |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ManufacturingContext | |
def initialize(manufacturer, payor, item, quantity) | |
@manufacturer = manufacturer | |
@payor = payor | |
@item = item | |
@quantity = quantity | |
@manufacturer.extend Manufacturer | |
@payor.extend Payor | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
list_snippets_for() { | |
egrep "^snippet|^#" ~/.vim/snippets/$1.snippets | awk '/^#/ {comment = comment $0} /^snippet/ {print $0 "\t\t" comment; comment=""}' | |
} | |
if [ "$1" == "" ] | |
then | |
echo "You must specify at least one file type as an argument to ls_snip" | |
exit | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AddendPerformanceProgramObjectives | |
AddendPerformanceProgramSchedule | |
ApplicantListWorker | |
ApplicationTransitionWorker | |
ChoreCreated | |
ChoresNotifications | |
EeoReportWorker | |
EmailWorker | |
EmployerStatsExportWorker | |
EmploymentTaskOpeningWorker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pools = ActiveRecord::Base.connection_handler.connection_pools.values | |
pools.each do |pool| | |
pool.connections.each{|connection| connection.reconnect!} | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[48] pry(main)> reflection = HiringProposal.reflections[:job_application] | |
=> #<ActiveRecord::Reflection::AssociationReflection:0x007fd7c6e91420 | |
@active_record= | |
Action(id: integer, action_definition_id: integer, created_at: datetime, updated_at: datetime, position_context_id: integer, job_application_id: integer, created_by_id: integer, position_description_id: integer, type: string, variances: text, workflow_state_id: integer, deleted_at: datetime, last_updated_at: datetime, hr_override: boolean, delta: boolean, version: integer, latest: boolean, position_type_id: integer, organizational_unit_id: integer, auto_number: string, workflow_state_definition_id: integer, workflow_owner_user_id: integer), | |
@association_foreign_key="job_application_id", | |
@class_name="JobApplication", | |
@collection=false, | |
@klass= | |
JobApplication(id: integer, posting_id: integer, form_id: integer, created_at: datetime, updated_at: datetime, user_id: integer, confirmation_number: string, submitted_at: datetime, certification_statemen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2.1.1 :001 > array = [1] * 100 | |
=> [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] | |
2.1.1 :002 > array.each_slice(array.size / 4).to_a | |
=> [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]] | |
2.1.1 :003 > arrays = array.each_slice(array.size / 4).to_a | |
=> [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, |
OlderNewer