Skip to content

Instantly share code, notes, and snippets.

View dwelch2344's full-sized avatar

David Welch dwelch2344

View GitHub Profile
var data = [
{}, // blank so we can index by 1 (matching the IDs)
{id: 1, verb: 'Say', value: 'Thanks for calling. Press 1 to leave a voicemail or 2 Customer Service'
options: {
'1': 5,
'2': 6
}
},
{id: 2, verb: 'Gather', children: [1]},
{id: 3, verb: 'Say', value: 'Please leave a voicemail'}
@dwelch2344
dwelch2344 / debugTemplates.js
Created September 24, 2015 20:51
Nifty way to debug the interpolated templates for angularjs
$provide.decorator("$interpolate", function($delegate){
var interpolateWrap = function(){
var interpolationFn = $delegate.apply(this, arguments);
if(interpolationFn) {
return interpolationFnWrap(interpolationFn, arguments);
}
};
var interpolationFnWrap = function(interpolationFn, interpolationArgs){
'MediaStream.stop()' is deprecated and will be removed in M47, around November 2015. Please use 'MediaStream.active' instead.
@Slf4j
@SpringBootApplication(exclude={ AmqpBusAutoConfiguration.class })
public class Server {
public static void main(String[] args) {
EnhancedSpringApplication.run(Server.class, args);
}
@Autowired(required = false)
private ConfigServicePropertySourceLocator locator;
@dwelch2344
dwelch2344 / fd.sh
Created September 12, 2015 15:42
Count open file handles for all processes
#!/bin/bash
for D in `find /proc -maxdepth 1 -type d`
do
PID=`echo $D | cut -d'/' -f3 `
if [[ $PID =~ [0-9]+ ]]; then
C=`ps -up $PID | grep $PID | tr -s " " | cut -d " " -f 11-17`
COUNT=`sudo ls -l "$D"/fd | wc -l`
echo " ($PID) $COUNT => $C"
fi
done
public class ExampleController {
@Inject
private StepRepo stepRepo;
@Inject
private StepChildRepo childRepo;
@RequestMapping(value = "/{stepId}/options/", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody Object putOptions(@RequestBody OptionList beans, @PathVariable Long stepId){
{
version:0,
id:26,
value:"bah",
name:"bahaha",
links:[
{
rel:"self",
href:"http://localhost:8078/api/twilio/steps/26{?projection}"
}
@FeignClient(url = "${app.api.someService.baseUrl}")
public interface SomeFeign {
@RequestMapping(method = RequestMethod.POST, value = "/steps/",
produces = "application/json")
Step createStep(@RequestBody Step step);
@RequestMapping(method = RequestMethod.PUT, value = "/steps/{stepId}",
produces = "application/json")
Step updateStep(@RequestBody Step step, @PathVariable("stepId") Long stepId);
}
@dwelch2344
dwelch2344 / SpringDataRestConfig.java
Created August 27, 2015 17:07
Workaround to expose ids with SpringDataRest, if you can't extend RepositoryRestMvcConfiguration
@Slf4j
@Configuration
public class SpringDataRestConfig {
private static final String BASE_PACKAGE = "com.example.yourapp";
@Inject
private RepositoryRestConfiguration restConfig;
@Inject
@dwelch2344
dwelch2344 / app.js
Created July 7, 2015 00:58
Iterate some jquery forms?
var addRow = $('.add-row'),
submit = $('.submit'),
container = $('.question-container'),
tpl = $('.template').html() // get the HTML contents as a string
addRow.on('click', addOne);
submit.on('click', sendIt);
// *should* create a whole new element from the string and stuff it in at the bottom
function addOne(){