This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String format(String unformattedXml) { | |
try { | |
DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance(); | |
DOMImplementationLS impl = (DOMImplementationLS) registry.getDOMImplementation("LS"); | |
LSSerializer writer = impl.createLSSerializer(); | |
writer.getDomConfig().setParameter("format-pretty-print", Boolean.TRUE); | |
writer.getDomConfig().setParameter("xml-declaration", Boolean.FALSE); | |
LSOutput output = impl.createLSOutput(); | |
ByteArrayOutputStream out = new ByteArrayOutputStream(); | |
output.setByteStream(out); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task fatJar(type: Jar) { | |
manifest { | |
attributes 'Implementation-Title': 'Gradle Jar File Example', | |
'Implementation-Version': version, | |
'Main-Class': 'com.mkyong.DateUtils' | |
} | |
baseName = project.name + '-all' | |
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } | |
with jar | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task createJavaProject << { | |
sourceSets*.java.srcDirs*.each { it.mkdirs() } | |
sourceSets*.resources.srcDirs*.each { it.mkdirs()} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This is the Towers of Hanoi example from the prolog tutorial [1] | |
* converted into Scala, using implicits to unfold the algorithm at | |
* compile-time. | |
* | |
* [1] http://www.csupomona.edu/~jrfisher/www/prolog_tutorial/2_3.html | |
*/ | |
object TowersOfHanoi { | |
import scala.reflect.Manifest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ------------------------------------------------------------------ | |
// Friend collection, where _id is a user.Id and Friends is a list, of user.Id. | |
// Note: friending and unfriending is a two step operation in this scheme: | |
> db.friends.find() | |
{ "_id" : 1, "friends" : [ 2, 3, 4 ] } | |
{ "_id" : 2, "friends" : [ 1, 3, 5 ] } | |
{ "_id" : 3, "friends" : [ 1, 2, 4, 5 ] } | |
{ "_id" : 4, "friends" : [ 1, 3, 5 ] } | |
{ "_id" : 5, "friends" : [ 2, 3, 4 ] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ldap = require('ldapjs'); | |
const Promise = require("bluebird"); | |
class LDAPClient { | |
constructor(ldap_url, ldap_user, ldap_pwd, ldap_base_dn) { | |
this.ldap_url = ldap_url; | |
this.ldap_user = ldap_user; | |
this.ldap_base_dn = ldap_base_dn; | |
this.domain = this._getDomain(ldap_base_dn); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '2' | |
services: | |
rancher-server: | |
image: 'rancher/server:stable' | |
container_name: rancher-server | |
restart: always | |
volumes_from: | |
- rancher-db | |
ports: | |
- "8080:8080" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.function.Predicate; | |
public class User { | |
private String name; | |
private String email; | |
public String getName() { | |
return name; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.ignite.internal.IgniteInterruptedCheckedException; | |
import org.apache.ignite.internal.util.typedef.internal.U; | |
import org.apache.ignite.spi.IgniteSpiException; | |
import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinderAdapter; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStreamReader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const val UPSTREAM_SERVICE_NAME_HEADER = "x-client-name" | |
class VisualisationMetricHandler : Handler<RoutingContext> { | |
val httpGauge = Gauge.build() | |
.name("status:http_requests_total:rate5m") | |
.help("Requests per 5m") | |
.labelNames("service", "client", "status") | |
.register() |
OlderNewer