Skip to content

Instantly share code, notes, and snippets.

View sabesansathananthan's full-sized avatar
:octocat:
Work

Sathananthan Sabesan sabesansathananthan

:octocat:
Work
View GitHub Profile
@sabesansathananthan
sabesansathananthan / KerberosMiniKdc.java
Created August 8, 2019 17:08
Running a Key Distribution Center
public static void main(String[] args) throws Exception {
String[] config = MiniKdcConfigBuilder.builder()
.workDir(prepareWorkDir())
.confDir("minikdc-krb5.conf")
.keytabName("example.keytab")
.principals("client/localhost", "HTTP/localhost")
.build();
MiniKdc.main(config);
@sabesansathananthan
sabesansathananthan / KerberosConfig.java
Last active August 8, 2019 17:20
Client Application
@Configuration
class KerberosConfig {
@Value("${app.user-principal}")
private String principal;
@Value("${app.keytab-location}")
private String keytabLocation;
@Bean
@Service
class SampleClient {
@Value("${app.access-url}")
private String endpoint;
private RestTemplate restTemplate;
public SampleClient(RestTemplate restTemplate) {
this.restTemplate = restTemplate;
@Configuration
@EnableWebSecurity
class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Value("${app.service-principal}")
private String servicePrincipal;
@Value("${app.keytab-location}")
private String keytabLocation;
@sabesansathananthan
sabesansathananthan / suite.xml
Last active August 13, 2019 06:47
Paralyze Test NG groups
<suite name="Suite"configfailurepolicy="continue"parallel="true"thread-
count="3">
<test name="MockTest">
<groups>
<define name="Page">
<include name="bind" />
<include name="link" />
</define>
<run>
<include name="Page">
@sabesansathananthan
sabesansathananthan / TestNGParallelRunner.java
Last active August 15, 2019 10:42
Software parallelization custom implementation
public class TestNGParallelRunner{
public static void main(String[] args){
if(PARALLEL_ENABLE){
SeleniumGridManager seleniumGridManager = new SeleniumGridManager();
seleniumGridManager.startSeleniumGrid();
try{
List<String>testGroup=new TestNGXmlParser().getTestGroupsFromTestNGXml(TEST_SUITE);
ExecutorService executoService = Executor.newFixedThreadPool(THREAD_COUNT);
for(String testGroup : testGroups){
TestThread testThread = new TestThread(testGroup);
@sabesansathananthan
sabesansathananthan / TestThread.java
Last active August 15, 2019 11:41
Software parallelization custom implementation
public class TestThread impements Runnable{
public TestThread(String testGroupNam){
this.testGroupName=testGroupNam;
}
private String testGroupName;
@Override
public void run(){
TestNG testSuite = new TestNG(true);
TestBase c = constructGroup(testGroupName);
testSuite.setTestGroups(new Group[] {c.getGroup()});
@sabesansathananthan
sabesansathananthan / script.js
Last active September 2, 2019 05:18
get medium JSON object.
$(function () {
var mediumPromise = new Promise(function (resolve) {
var $content = $('#jsonContent');
var data = {
rss: 'https://medium.com/feed/@sabesan96'
};
$.get(' https://api.rss2json.com/v1/api.json?rss_url=https%3A%2F%2Fmedium.com%2Ffeed%2F%40sabesan96', data, function (response) {
if (response.status == 'ok') {
$("#logo").append(`<img src="${response.feed["image"]}" class="rounded mx-auto d-block">`)
var display = '';
@sabesansathananthan
sabesansathananthan / blog.html
Last active September 2, 2019 04:53
implement medium in your blog - front-end
<body>
<div class="container mt-5 pt-5" id="medium">
<div class="jumbotron text-center">
<div id="logo"></div>
<h1 class="display-4 mb-3">@username's Posts</h1>
<a class="btn btn-outline-primary btn-lg" href="https://medium.com/@username" target="_blank" role="button">View all posts</a>
</div>
<div class="row" id="jsonContent">
</div>
</div>
Name Size(gzip) Tree-shaking Popularity(stars) Methods richness Pattern Timezone Support Locale
Moment.js 329K(69.6K) No 42.1k High OO Good(moment-timezone) 123
dayjs 6.5k(2.6k) without plugins No 23k High OO Not yet 130