Skip to content

Instantly share code, notes, and snippets.

View scottfrederick's full-sized avatar

Scott Frederick scottfrederick

View GitHub Profile
// Create an array of Blackmagic Hyperdeck IP addresses to check
var hyperdecks = ["192.168.0.100", "192.168.0.101", "192.168.0.102"];
function sendCommand(hyperdeck, command) {
console.log("Hyperdeck " + hyperdeck + ": sending command " + command);
var request = new XMLHttpRequest();
request.open("GET", "http://" + hyperdeck + "/" + command, false);
request.send();
var response = request.responseXML;
#!/bin/bash
function cfenv() {
function curenv() {
if [ "$1" = "" ]; then
CURENV="default"
else
CURENV="$(echo "$1" | cut -d '-' -f 2)"
fi
}
@Configuration
@EnableConfigurationProperties
public class CloudFoundryConfiguration {
@Bean
@ConfigurationProperties(prefix = "cloudfoundry.client")
public ResourceOwnerPasswordResourceDetails cloudFoundryCredentials() {
return new ResourceOwnerPasswordResourceDetails();
}
@Bean
#!/usr/bin/env groovy
@Grapes([
@Grab('com.fasterxml.jackson.core:jackson-databind:2.8.3'),
@Grab('com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.8.3')
])
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator.Feature
@Controller
public class GreetingController {
@Autowired
private GreetingService service;
@RequestMapping("/")
public @ResponseBody String greet() {
return service.getHelloMessage() +
"<br/>" +
service.getWelcomeMessage();
public class CustomXmlContextLoader extends GenericXmlContextLoader {
@Override
protected void customizeContext(GenericApplicationContext context) {
ClassPathXmlApplicationContext propertySourceContext =
new ClassPathXmlApplicationContext("classpath:/spring/property-source-context.xml");
PropertySource propertySource = propertySourceContext.getBean(RedisPropertySource.class);
context.getEnvironment().getPropertySources().addFirst(propertySource);
}
@scottfrederick
scottfrederick / PersonValidator.java
Created March 22, 2012 03:06
Spring Meta-validator
@ValidatorComponent
public class PersonValidator implements Validator {
/**
* This Validator validates just Person instances
*/
public boolean supports(Class clazz) {
return Person.class.equals(clazz);
}
public void validate(Object obj, Errors e) {