Skip to content

Instantly share code, notes, and snippets.

View code-atom's full-sized avatar
🏠
Working from home

Ankit Rana code-atom

🏠
Working from home
View GitHub Profile
@code-atom
code-atom / long-press.directive.ts
Last active November 24, 2021 11:08
Long press directive in Angular
import {
Directive,
ElementRef,
EventEmitter,
OnDestroy,
Output
} from "@angular/core";
import {
fromEvent,
merge,
@code-atom
code-atom / odic-pre-request-postman.js
Created September 9, 2020 10:48
OIDC Authorization Proof Key in Postman Per-Request
var crypto = require("crypto-js");
var interval = setTimeout(function() {}, 10000);
var b64map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var b64pad = "=";
var stsEndpoint = 'https://XX-XXX-XXX-XXX.XXX.net/ids';
var tokenEndpoint = stsEndpoint + '/connect/token';
var authorizationEndpoint = stsEndpoint + '/connect/authorize';
var loginEndpoint = stsEndpoint + '/login';
@code-atom
code-atom / JwtValidator.cs
Created May 18, 2020 18:16
Jwt Token Validator with all default properties.
using Microsoft.IdentityModel.Protocols;
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
using Microsoft.IdentityModel.Tokens;
using System;
using System.IdentityModel.Tokens.Jwt;
using System.Threading;
namespace JwtValidator
{
class Program
@code-atom
code-atom / setAuthProfile.soapui
Last active August 7, 2019 08:44
Set Auth Profile API
import com.eviware.soapui.config.CredentialsConfig;
for(testSuiteItem in testSuite.project.getTestSuiteList()) {
for( testCaseItem in testSuiteItem.getTestCaseList()) {
for( testStep in testCaseItem.getTestStepsOfType(com.eviware.soapui.impl.wsdl.teststeps.RestTestRequestStep) ) {
log.info("Setting basic auth for all REST test requests in testStep ["+testStep.getName()+"]")
testStep.getTestRequest().setEndpoint('https://localhost');
testStep.getTestRequest().setSelectedAuthProfileAndAuthType("TEST_DM_TOKEN", com.eviware.soapui.config.CredentialsConfig.AuthType.O_AUTH_2_0);
}
}
}
@code-atom
code-atom / keyword-focus.js
Created July 2, 2019 10:35
Tab focused on focus-element class html element
(function (window, document) {
var state = {
mouseUsage: false,
focusClass: 'focus-class',
documentBody: document.body
}
var controller = {
@code-atom
code-atom / pre-request-script.js
Created May 13, 2019 08:21
Add pre-request script for postman
const stsEndpoint = pm.variables.get("STSEndpoint");
const clientCredentialBase64Encode = pm.variables.get("clientSecret64Encode");
const scopes = pm.variables.get("scopes");
let getToken = true;
const tokenEndpoint = stsEndpoint + '/connect/token';
if (!pm.variables.get('token')) {
console.log('Token missing');
} else {
getToken = false;
@code-atom
code-atom / beat-logstash.config
Last active April 4, 2019 10:39
beat integration with logstash
# Sample Logstash configuration for creating a simple
# Beats -> Logstash -> Elasticsearch pipeline.
input {
beats {
port => 5044
}
}
filter
{
@code-atom
code-atom / App.ts
Created January 31, 2018 10:06
Setup Custom Global Error Handler in angular
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { NgModule, ErrorHandler } from '@angular/core';
import { ToastrModule, ToastContainerModule } from 'ngx-toastr';
import { AppRoutingModule } from './app.routing.module';
import { CoreModule } from './core/core.module';
import { AppComponent } from './app.component';
import { GlobalErrorHandler } from './error-handler.service';
import { AppRootLoaderComponent } from './content-loader.component';
@code-atom
code-atom / APIKeyHandler.cs
Last active October 16, 2017 07:42
Api key verify Handler
/// <summary>
/// Verify that all request to api must contain apikey
/// </summary>
public class APIKeyHandler : DelegatingHandler
{
private string APIToken = "apiKey";
protected override System.Threading.Tasks.Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)
{
if (request.Method == HttpMethod.Options) goto success;
@code-atom
code-atom / DisableAspButton.trick
Created September 12, 2017 05:09
Disable the button after the first click and submit the form in asp.net.
<asp:Button ID="btnSubmit"
ValidationGroup="confirmOrder"
OnClientClick="submitOrder()"
OnClick="SubmitOrder"
Text="Pay Now"
CssClass="inputSubmit" runat="server"
UseSubmitBehavior="false"
/>
<script type="text/script">
function submitOrder() {