Skip to content

Instantly share code, notes, and snippets.

View searls's full-sized avatar
💚

Justin Searls searls

💚
View GitHub Profile
@searls
searls / jspIncludesFilesInDirectory.jsp
Created June 13, 2011 22:25
Renders a jsp:include action for each of the files immediately in some directory (Goodness hope you never have reason to do this, but I needed something like this for a very tricky dev-environment)
<%@page import="java.io.File" %>
<%
String templates = "/path/to/folder/of/stuff";
for(File f : new File(application.getRealPath(templates)).listFiles()) {
String path = templates+"/"+f.getName();
%><jsp:include page="<%= path %>" /><%
}
%>
@searls
searls / gist:1026974
Created June 15, 2011 12:24
Weird jenkins error
SEVERE: Failed Loading job my-job
hudson.util.IOException2: /var/lib/jenkins/jobs/my-job/nextBuildNumber doesn't contain a number
at hudson.model.Job.onLoad(Job.java:174)
at hudson.model.AbstractProject.onLoad(AbstractProject.java:248)
at hudson.model.Project.onLoad(Project.java:88)
at hudson.model.Items.load(Items.java:114)
at hudson.model.Hudson$13.run(Hudson.java:2354)
at org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:146)
at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:259)
at hudson.model.Hudson$4.runTask(Hudson.java:735)
//Gruber wrote this regex for matching URLs, but it took a small amount of massage to use it in JavaScript. So here.
//Sauce: http://daringfireball.net/2010/07/improved_regex_for_matching_urls
var p = /\b((?:https?:\/\/|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/i;
p.exec('party fun www.twitter.com yay') //winning.
@searls
searls / jshint-spec.js
Created June 21, 2011 22:52
JSHint spec for use w/ jasmine-maven-plugin (where vendor sources are in a folder called 'vendor' and excluded).
describe('JSHint', function() {
var options = {
curly : true,
white : false,
evil: true,
indent : 2
}, excludes = /^.*\/vendor\/.*$/, includes = /^.*js$/;
function get(path) {
path = path + "?" + new Date().getTime();
@searls
searls / maven-git-flow.sh
Created June 24, 2011 00:25
My approximation of nvie's git flow when using maven-release-plugin to cut releases. - http://nvie.com/posts/a-successful-git-branching-model/
# How to perform a release with git & maven following the git flow conventions
# ----------------------------------------------------------------------------
# Finding the next version: you can see the next version by looking at the
# version element in "pom.xml" and lopping off "-SNAPSHOT". To illustrate,
# if the pom's version read "0.0.2-SNAPSHOT", the following instructions would
# perform the release for version "0.0.2" and increment the development version
# of each project to "0.0.3-SNAPSHOT".
# branch from develop to a new release branch
git checkout develop
Installing capybara-webkit (1.0.0.beta4) with native extensions /Volumes/HD/Users/justin/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/site_ruby/1.8/rubygems/installer.rb:483:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)
/Volumes/HD/Users/justin/.rvm/rubies/ruby-1.8.7-p302/bin/ruby extconf.rb
Gem files will remain installed in /Volumes/HD/Users/justin/.rvm/gems/ruby-1.8.7-p302/gems/capybara-webkit-1.0.0.beta4 for inspection.
Results logged to /Volumes/HD/Users/justin/.rvm/gems/ruby-1.8.7-p302/gems/capybara-webkit-1.0.0.beta4/gem_make.out
from /Volumes/HD/Users/justin/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/site_ruby/1.8/rubygems/installer.rb:446:in `each'
from /Volumes/HD/Users/justin/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/site_ruby/1.8/rubygems/installer.rb:446:in `build_extensions'
from /Volumes/HD/Users/justin/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/site_ruby/1.8/rubygems/installer.rb:198:in `install'
<%@include file="istore/jsp/dependencies/css.jsp" %>
package com.github.searls.jasmine.io;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import java.io.File;
import java.io.IOException;
import org.junit.Test;
find . -name *.js -exec js2coffee {} {}.coffee \;
@searls
searls / ouch_one_extra_line.coffee
Created July 15, 2011 14:34
Here's why users are polluting "this" in Jasmine"
describe 'chum', ->
chum=null
beforeEach -> chum = 'D.W. Frank'
it 'is chummy', ->
expect(chum).toBe('D.W. Frank')