Skip to content

Instantly share code, notes, and snippets.

import java.util.*;
import java.util.function.*;
import java.util.stream.Collectors;
import static java.util.function.Function.identity;
public class NonRepeatingLetter {
public static void main(String[] args) {
findFirstNonRepeatingLetter(args[0], System.out::println);
}
@schatterjee4
schatterjee4 / BasicAuth.java
Created June 16, 2016 10:17 — forked from kgsnipes/BasicAuth.java
preemptive http basic authentication in apache http client library
public class BasicAuth
{
public static void main(String a[])throws Exception
{
System.out.println(getHttpResponse("78.101.139.84"));
}
public static String getHttpResponse(final String ip) throws IOException
{
@schatterjee4
schatterjee4 / choice-exception-strategy.xml
Created October 20, 2016 09:50 — forked from cgorshing/choice-exception-strategy.xml
Small Mule example showing a choice-exception-strategy (copied from the Mule docs)
<flow name="RouteByExceptionType">
<jms:inbound-endpoint queue="in">
<jms:transaction action="ALWAYS_BEGIN" />
</jms:inbound-endpoint>
<test:component/>
<jms:outbound-endpoint queue="out">
<jms:transaction action="ALWAYS_JOIN" />
</jms:outbound-endpoint>
<choice-exception-strategy>
<catch-exception-strategy when="exception.causedBy(com.company.BusinessException)">
@schatterjee4
schatterjee4 / dialog.xml
Created May 2, 2017 06:52 — forked from markdaugherty/dialog.xml
CQ5 - disable dialog field when content is loaded
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" jcr:primaryType="cq:Dialog"
xtype="dialog">
<listeners jcr:primaryType="nt:unstructured"
loadcontent="function(dialog) {
// call servlet or perform arbitrary javascript functions
dialog.getField('./operator').disable();
}" />
<items jcr:primaryType="cq:WidgetCollection">
@schatterjee4
schatterjee4 / README.md
Created May 9, 2017 17:24 — forked from toodooleedoo/README.md
#AEM #SIGHTLY #SSJS JavaScript Use-API to append parameters and attributes to anchors

##Description

  1. Append two custom parameters to specific URL's entered by an Author.
  2. Open all links pointing outside your site inside a new window
  3. Add .html to links entered through the GUI pathfield widget (@adobe why is this not OOTB?)

##Use case When an Author selects a link via pathfield I found AEM is not adding the extension. I was going to add some Client Side JavaScript to my dialog windows to handle this on save however I also had the following business requests so I leveraged Server Side JavaScript to take care of all of this.

##Requirements

  • When a request is to domain1name.com or domain2name.com append 2 author controllable URL parameters used for Tracking which the authors could control Globally per site.
@schatterjee4
schatterjee4 / README.md
Created May 9, 2017 17:25 — forked from toodooleedoo/README.md
#AEM #Sightly #SSJS Server Side JavaScript Use-API Breadcrumbs

###Description Retrieve a Page Object from all pages which are in the Site root then build a breadcrumb component and display the current pages title in a submenu.

###Use case Display a bar under eg a menu which displays the current pages title and functional breadcrumb components o the right.

##Requirements

  • Responsive and which works on all mobile devices and desktop.
  • Current pages title on the left
  • Breadcrumbs on the right
@schatterjee4
schatterjee4 / Learning React Redux ES6 resources.md
Created July 1, 2017 09:32 — forked from tirams/Learning React Redux ES6 resources.md
Here are some resources I’ve used to learn react, redux and es6
@schatterjee4
schatterjee4 / app.js
Created July 17, 2017 08:59 — forked from itzg/app.js
Coordinating session timeout from Spring MVC (embedded Tomcat with Spring Boot) to AngularJS REST invocations
angular.module('App', [])
.factory('sessionTimeoutInterceptor', function($log, $window) {
return {
response: function(response){
if (response.headers('x-login') === 'true') {
$log.debug('Intercepted login redirect', response);
$window.location.reload();
}
return response;
}
@schatterjee4
schatterjee4 / aemTouchCheckboxDialog.xml
Created July 17, 2017 09:50 — forked from nateyolles/aemTouchCheckboxDialog.xml
AEM Touch UI component dialog checkboxes
<!-- Checked checkbox will result in a String property of "true" -->
<myCheckbox
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/checkbox"
text="My Checkbox"
name="./myCheckbox"
value="true"/>
<!-- Checked checkbox will result in a Boolean property of true-->
<myBooleanCheckbox
@schatterjee4
schatterjee4 / .content.xml
Created July 17, 2017 09:53 — forked from rjspiker/.content.xml
AEM 6 Touch UI Show/Hide Checkbox Component Extension - Extension to the standard checkbox component. It enables hiding/unhiding of other components based on the selection made in the checkbox.
<enable
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/checkbox"
text="Enable"
id="enable"
value="true"
name="./enable"
class="cq-dialog-checkbox-showhide"
cq-dialog-checkbox-showhide-target=".button-option-enable-showhide-target"/>
<deleteEnable