Skip to content

Instantly share code, notes, and snippets.

View kkoziarski's full-sized avatar

Krzysztof Koziarski kkoziarski

View GitHub Profile
@kkoziarski
kkoziarski / copy-jwt-token-bookmarklet.js
Created March 16, 2020 09:25
copy JWT token bookmarklet (jwt-cp)
javascript: (function() {
var key = window.localStorage.getItem('adal.token.keys').split('|')[0];
var token = window.localStorage.getItem('adal.access.token.key' + key);
if (token) {
/*window.prompt("Copy to clipboard: Ctrl+C, Enter", token);*/
sendToClipbord(token);
}
function sendToClipbord(myString) {
var textarea = document.createElement('textarea');
document.body.appendChild(textarea);
@kkoziarski
kkoziarski / ..README.md
Last active February 27, 2020 21:21
WSL setup oh-my-zsh

setup WSL

wsl --set-default Ubuntu-18.04

Install oh-my-posh

sudo apt-get install zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
@kkoziarski
kkoziarski / Paradox-custom-theme.psm1
Last active February 9, 2019 20:37
Scripts to run on a new system
#requires -Version 2 -Modules posh-git
function Write-Theme {
param(
[bool]
$lastCommandFailed,
[string]
$with
)
@kkoziarski
kkoziarski / Startup.cs
Last active April 13, 2018 12:26
JSNLog sample demo
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace JSNLogCore.Demo
{
public class Startup
{
@kkoziarski
kkoziarski / rx-subscribe-unsubscribe-listeners.ts
Last active February 20, 2018 08:11
Subscribe with unsubscribe listeners
// https://github.com/ng-book/angular2-redux-chat/blob/master/tutorial/06b-rx-store.ts
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import { Subject } from 'rxjs/Subject';
import 'rxjs/add/operator/scan';
interface Action {
type: string;
payload?: any;
}
@kkoziarski
kkoziarski / AudiencesStore.cs
Created January 22, 2018 08:25
AudiencesStore - create a ClientId(AudienceId) and Base64Secret(AudienceSecret) for JWT tokens
namespace WebApi.Identity.Providers
{
using System;
using System.Collections.Concurrent;
using System.Security.Cryptography;
using Microsoft.IdentityModel.Tokens;
public static class AudiencesStore
{
public static ConcurrentDictionary<string, Audience> AudiencesList = new ConcurrentDictionary<string, Audience>();
@kkoziarski
kkoziarski / yarn_angular_cli.md
Created November 24, 2017 17:26
Yarn for Angular CLI

To enable Yarn for Angular CLI run the following command:

ng set --global packageManager=yarn

To revert it back to using npm use this:

ng set --global packageManager=npm
@kkoziarski
kkoziarski / FULL-Microsoft.PowerShell_profile.ps1
Last active September 27, 2017 12:08
cmd PROMPT settings
# Chocolatey profile
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
if (Test-Path($ChocolateyProfile)) {
Import-Module "$ChocolateyProfile"
}
function PromptX {
# Print the working directory:
import { Injectable } from "@angular/core";
import { TestBed, async, inject } from '@angular/core/testing';
import { HttpModule, Http, Response, ResponseOptions, XHRBackend } from '@angular/http';
import { MockBackend } from '@angular/http/testing';
import { Observable } from 'rxjs/Rx';
@Injectable()
export class FancyService {
protected value = 'real value';
@kkoziarski
kkoziarski / AppBuilderExtensions.cs
Last active March 31, 2017 12:15 — forked from dschenkelman/Extensions.cs
Intro to OWIN talk and a simple IP filtering middleware sample
namespace Owin.IpFilter
{
using System;
using System.Net;
public static class AppBuilderExtensions
{
public static IAppBuilder UseIpFiltering(this IAppBuilder appBuilder, Func<IPAddress, bool> rejectRequest)
{
appBuilder.Use(typeof(IpFilterMiddleware), rejectRequest);