Skip to content

Instantly share code, notes, and snippets.

@annagapuz
annagapuz / DNWStreamingClient.java
Last active July 11, 2024 15:01
SSEWithSpringBootWebFluxAndOAuth
import io.netty.handler.timeout.ReadTimeoutHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpStatusCode;
import org.springframework.http.MediaType;
import org.springframework.http.codec.ServerSentEvent;
@annagapuz
annagapuz / StreamingAPIClient.cs
Last active May 15, 2024 14:10
CSharpSSEClient
namespace StreamingAPIClient
{
public static class Program
{
public static async Task Main(string[] args)
{
Console.WriteLine("Run sample client");
HttpClient client = new HttpClient();
@annagapuz
annagapuz / LDAPAuthErrorCodes.txt
Last active August 19, 2021 14:14
LDAP Authentication Error Codes
The key portion of the error message is the javax.naming.AuthenticationException in brackets. Example:
[LDAP: error code 49 - 80090308: LdapErr: DSID-0C0903A9, comment: AcceptSecurityContext error, data 52e, v1db1 ]
The AD-specific error code after the 'data' word ('52e' in the above example) is the actual error string returned to the binding process and will provide an explicit reason for the failure;
525 user not found
Description: Returns when username is invalid.
52e invalid credentials
Description: Logon failure: unknown user name or bad password. Returns when username is valid but password/credential is invalid. Will prevent most other errors from being displayed as noted.
@annagapuz
annagapuz / GenerateJsonSchemaFromObject
Created August 28, 2019 18:39
Generate JSON Schema from Java Object
public class JsonSchemaUtility {
public static void main(String[] args) throws Exception {
ObjectMapper objectMapper = new ObjectMapper();
// Serialize a LocalDate using the corresponding ISO formatter
objectMapper.registerModule(new SimpleModule().addSerializer(new LocalDateSerializer(DateTimeFormatter.ISO_LOCAL_DATE)));
// Serialize a OffsetDateTime using the corresponding custom formatter
objectMapper.registerModule(new SimpleModule().addSerializer(new CustomOffsetDateTimeSerializer(OffsetDateTime.class)));
// Serialize a Year using the corresponding ISO formatter
objectMapper.registerModule(new SimpleModule().addSerializer(YearSerializer.INSTANCE));
/**
* fieldIdentifier = //ROOT/FOO[0], fieldValue = abc
* fieldIdentifier = //ROOT/FOO[1]/@Bar, fieldValue = xyz
*/
public class SimpleXmlGenerator {
public static String createXml(String xmlRootName, List<FieldEnumeration> inputFields) {
StringBuilder xmlString = new StringBuilder("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
buildXml(xmlString, buildXmlNodes(xmlRootName, inputFields));
/**
* fieldIdentifier = objectRoot.foo[0].bar, fieldValue = abc
* fieldIdentifier = objectRoot.foo[1].bar, fieldValue = xyz
*/
public final class SimpleJsonGenerator {
private static final Set<String> ARRAY_NODES = getArrayNodes();
private static final String BASE_JSON_PATH = "objectRoot";
@annagapuz
annagapuz / ListJDKCiphers
Created July 12, 2017 13:58
ListJDKCiphers
import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;
import javax.net.ssl.SSLServerSocketFactory;
public class Ciphers
{
public static void main(String[] args)
throws Exception
{
Ended up being too memory intensive, but it worked:
==================================================
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
sudo sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt-get update
Benchmark your SSD or hard disk speed
To test write speed:
time dd if=/dev/zero bs=1024k of=tstfile count=1024
To test read speed:
time dd if=tstfile bs=1024k of=/dev/null count=1024
hdiutil convert -format UDRW -o ubcd.img /ubcd537.iso
@annagapuz
annagapuz / AtmosphereAndGrails
Last active August 29, 2015 13:56
Integrating Atmosphere with Grails
// Long-Polling is used in this example b/c of IE7
// Add atmosphere to ApplicationResources.groovy
modules = {
...
atmosphere {
dependsOn 'jquery'
resource url:'js/atmosphere.js' // used jQuery atmosphere minified
}
}