Skip to content

Instantly share code, notes, and snippets.

var restify = require('restify');
var server = restify.createServer({ name: 'example' });
var fs = require('fs');
server.listen(8080, function () {
console.log('%s listening at %s', server.name, server.url);
});
server.use(restify.fullResponse()).use(restify.bodyParser());
@Configuration
protected static class CustomAuthorizationServerSecurityConfig extends AuthorizationServerSecurityConfiguration {
@Autowired
private AuthorizationServerEndpointsConfiguration endpoints;
@Autowired
private ClientDetailsService clientDetailsService;
@Override
@ccampo133
ccampo133 / Camel Spring Boot
Created April 6, 2015 23:19
Apache Camel Spring Boot
import org.apache.camel.builder.RouteBuilder;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
@SpringBootApplication
public class AdapterApplication {
public static void main(final String[] args) {
new SpringApplication(AdapterApplication.class).run(args);
@ccampo133
ccampo133 / keybase.md
Created February 7, 2016 16:49
Keybase ID

Keybase proof

I hereby claim:

  • I am ccampo133 on github.
  • I am ccampo (https://keybase.io/ccampo) on keybase.
  • I have a public key whose fingerprint is F0B4 68E0 F0B2 AA1B 3D12 9576 AEC6 56A2 0FD9 1A0E

To claim this, I am signing this object:

@ccampo133
ccampo133 / InfiniteRetry.kt
Last active January 20, 2021 04:13
Infinite retry with exponential backoff in Kotlin using co-routines
/**
* Copyright 2018 C.J. Campo
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
@ccampo133
ccampo133 / BackgroundWatchdog.kt
Created April 4, 2018 18:56
Background watchdog in Kotlin using co-routines
/**
* Copyright 2018 C.J. Campo
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
@ccampo133
ccampo133 / nukecouch.sh
Created November 13, 2018 16:08
Utility scripts for running Couchbase in a container
#!/usr/bin/env bash
stopcouch
rm -rf ~/couchbase
@ccampo133
ccampo133 / CurrencyFormatting.kt
Last active April 24, 2023 07:38
Currency formatting
import java.math.BigDecimal
import java.text.NumberFormat
import java.util.Currency
import java.util.Locale
fun main(args: Array<String>) {
val locales = listOf(
Locale.FRANCE,
Locale.GERMANY,
Locale.UK,
@ccampo133
ccampo133 / mfa
Created August 8, 2019 02:41
Generate an MFA TOTP token. Secret keys are stored in your ~/.mfa directory
#!/usr/bin/env bash
#
# Generate an MFA TOTP token. Secret keys are stored in your ~/.mfa directory
#
# Requires oathtool: http://www.nongnu.org/oath-toolkit/man-oathtool.html
#
# Example: I might have the following...
# $ cat ~/.mfa/aws.mfa
# ASDLJGJ893AS7JJF83NLSD9RTSMF81NSLA85SNSA81MASNFHG75KAKSKJV0192F7
#
@ccampo133
ccampo133 / prefmv
Last active August 8, 2019 03:24
Rename the prefix of a bunch of files
#!/usr/bin/env sh
# Usage:
# prefmv frompref topref files...
#
# Changes the prefx from `frompref` to `topref`. Adds prefix `topref` if the file
# didn't have the prefix `frompref`
#
# Examples:
# prefmv main oldmain main.c main.java main.cpp
# prefmv main oldmain main*