Skip to content

Instantly share code, notes, and snippets.

View acreeger's full-sized avatar

Adam Creeger acreeger

  • Engineering Manager, Facebook
  • New York, NY
View GitHub Profile
@acreeger
acreeger / gist:1056051
Created June 30, 2011 11:35
buildTree - tt.fm
buildTree: function(tree, containers) {
var type = $.type(tree);
if (type == "string" || type == "number") {
return document.createTextNode(String(tree));
}
if (type != "array") {
return tree;
}
var elemDescriptor = tree[0];
var cssClasses, elemId, containerKey = [];
@acreeger
acreeger / gist:1027916
Created June 15, 2011 19:42
ElasticSearch: query_string vs text queries
curl -XDELETE http://localhost:9200/ac-test
curl -XPUT http://localhost:9200/ac-test
curl -XPUT http://localhost:9200/ac-test/people/1 -d '
{
"firstNames" : "James Earl",
"lastName" : "Jones",
"location" : "Hollywood, CA"
}'
curl -XPUT http://localhost:9200/ac-test/people/2 -d '
@acreeger
acreeger / JConsole.groovy
Created April 8, 2011 19:01
A script that allows you launch a grails-app then launch a JConsole instance that connects to it. Useful for using JMX with a grails app. Place this in your 'scripts' folder. Usage: 'grails jconsole'
import java.lang.management.ManagementFactory
includeTargets << grailsScript("_GrailsPackage")
includeTargets << grailsScript("_GrailsRun")
target(main: "Launches an app and automatically launches JConsole") {
//depends(compile, classpath, runApp)
depends(checkVersion, configureProxy, packageApp, parseArguments)
if (argsMap.https) {
runAppHttps()
@acreeger
acreeger / ExternalInPlacePlugin_BuildConfig.groovy
Created April 8, 2011 18:33
Code that you can add to your app's BuildConfig to enable you to specify in-place plugins outside of source controlled files
def buildConfigFile = new File("${userHome}/.grails/${appName}-buildConfig.groovy")
if (buildConfigFile.exists()) {
println "Processing external build config at $buildConfigFile"
def slurpedBuildConfig = new ConfigSlurper().parse(buildConfigFile.toURL())
slurpedBuildConfig.grails.plugin.location.each { k, v ->
if (!new File(v).exists()) {
println "WARNING: Cannot load in-place plugin from ${v} as that directory does not exist."
} else {
println "Loading in-place plugin $k from $v"
grails.plugin.location."$k" = v