Skip to content

Instantly share code, notes, and snippets.

Robin Herbots RobinHerbots

View GitHub Profile
@RobinHerbots
RobinHerbots / gist:5eda12d1921c9c8bcd7737aec327ec9a
Created Jun 21, 2019 — forked from pmhsfelix/gist:4151369
Generating and validating JWT tokens using JWTSecurityTokenHandler
View gist:5eda12d1921c9c8bcd7737aec327ec9a
[Fact]
public void First()
{
var tokenHandler = new JWTSecurityTokenHandler();
var symmetricKey = GetRandomBytes(256/8);
var now = DateTime.UtcNow;
var tokenDescriptor = new SecurityTokenDescriptor
{
Subject = new ClaimsIdentity(new Claim[]
@RobinHerbots
RobinHerbots / uriSchemeWithHyperlinkFallback.js
Created Dec 6, 2018 — forked from ChaseFlorell/uriSchemeWithHyperlinkFallback.js
Ever want to launch a mobile app from within the browser, but ensure that the browser still redirects the user to the link if the app isn't installed? This took some fiddling around, but when the "ah ha" moment hit, the solution is really quite simple.
View uriSchemeWithHyperlinkFallback.js
// tries to execute the uri:scheme
function uriSchemeWithHyperlinkFallback(uri, href) {
// set up a timer and start it
var start = new Date().getTime(),
end,
elapsed;
// attempt to redirect to the uri:scheme
// the lovely thing about javascript is that it's single threadded.
// if this WORKS, it'll stutter for a split second, causing the timer to be off
View uriSchemeWithHyperlinkFallback.js
// tries to execute the uri:scheme
function uriSchemeWithHyperlinkFallback(uri, href) {
if(!window.open(uri)){
window.location = href;
}
}
@RobinHerbots
RobinHerbots / index.ejs
Created Feb 23, 2017 — forked from ksrb/index.ejs
jquery.inputmask webpack configuration and package.json
View index.ejs
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<input id="float"/>
</body>
</html>
@RobinHerbots
RobinHerbots / index.ejs
Created Feb 23, 2017 — forked from ksrb/index.ejs
jquery.inputmask webpack configuration and package.json
View index.ejs
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<input id="float"/>
</body>
</html>
@RobinHerbots
RobinHerbots / jquery.ajax.progress.js
Last active Oct 8, 2018 — forked from db/jquery.ajax.progress.js
XMLHttpRequest2 progress event on $.ajax
View jquery.ajax.progress.js
(function($) {
var originalXhr = $.ajaxSettings.xhr;
$.ajaxSetup({
progress: $.noop,
xhr: function() {
var req = originalXhr(), that = this;
if (req) {
if (typeof req.addEventListener == "function") {
req.addEventListener("progress", function(evt) {
that.progress(evt);
You can’t perform that action at this time.