Skip to content

Instantly share code, notes, and snippets.

@davelnewton
davelnewton / syntax_highlighting.py
Created December 22, 2011 18:13 — forked from norbajunior/syntax_highlighting.py
Ruby on Rails syntax highlight switcher for Sublime Text 2
import sublime, sublime_plugin
import os
class DetectFileTypeCommand(sublime_plugin.EventListener):
""" Detects current file type if the file's extension isn't conclusive """
""" Modified for Ruby on Rails and Sublime Text 2 """
""" Original pastie here: http://pastie.org/private/kz8gtts0cjcvkec0d4quqa """
def on_load(self, view):
filename = view.file_name()
@davelnewton
davelnewton / temp1.groovy
Created January 5, 2012 17:13
Groovier groovy
/**
* Original with inline Groovier version
*/
//def publisher = null
//for (iter in project.getPublishersList()) {
// if (iter.getDescriptor().getDisplayName().equals("Editable Email Notification")) {
// publisher = iter
// break
// }
@davelnewton
davelnewton / pom.xml
Created January 28, 2012 20:05
Maven build file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org xsd/maven-.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>mygroup</groupId>
<artifactId>Test_Maven_03</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Test_Maven_03</name>
<url>http://maven.apache.org</url>
@davelnewton
davelnewton / dm.rb
Created April 25, 2012 17:06
DataMapper create-/query-by-hash equivalence
customer = {
:name => 'Dan Kubb',
:orders => [
{
:reference => 'TEST1234',
:order_lines => [
{
:item => {
:sku => 'BLUEWIDGET1',
:unit_price => 1.00,
@davelnewton
davelnewton / 01_spec.rb
Created August 9, 2012 01:48
RSpec Foolishness
describe Foo do
it { should respond_to(:bar) }
end
@davelnewton
davelnewton / 01_error.txt
Created August 23, 2012 23:48
A JRuby, Rails, RSpec, Spork, and an error walk into a bar...
$ rspec --drb spec/models/foo_spec.rb .../rubies/jruby-1.6.7/lib/ruby/1.9/drb/drb.rb:375 warning:
ObjectSpace is disabled; _id2ref only supports immediates, pass -X+O to enable
NoMethodError: undefined method `flush' for nil:NilClass
method_missing at .../rubies/jruby-1.6.7/lib/ruby/1.9/drb/drb.rb:1099
run at .../gems/jruby-1.6.7@cowbania/gems/rspec-core-2.11.1/lib/rspec/core/drb_command_line.rb:22
run at .../gems/jruby-1.6.7@cowbania/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:63
autorun at .../gems/jruby-1.6.7@cowbania/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:8
package main;
public class Triples {
private int number;
public Triples() {
// Does nothing.
}
class Reverb::Actions::WatchListing
def self.watch(user, product, listener)
if product.owner?(user)
listener.failure(I18n.t('flash.watchlist.error_own'))
else
user.user_watch_products.create(:product_id => product.id)
listener.success
end
end
end
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
// Consider isAssignableFrom depending on actual needs.
if (getClass() != obj.getClass()) {
return false;
}
@davelnewton
davelnewton / BrandActionOrig.java
Created August 20, 2013 12:14
Omg. How not to do it, followed by some sanitization. With emphasis on the sanity.
public class BrandAction extends AbstractProductListAction {
private static final long serialVersionUID = 3647582541701870610L;
protected CatalogBrowsingFacade catalogBrowsingFacade;
protected RedirectHandler redirectHandler;
private static final String BRAND_CONSTANT="BRAND";
private FormatStrategy formatStrategy;
@Override
public String execute() {
if (searchModel.getFreeTextCount() == 2) {