This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace TestingStuff | |
{ | |
/// <summary> | |
/// Thread safe and generic state machine, that can be made infinite and guards against invalid state transisitions | |
/// | |
/// public enum MyStates {Init, Running, Stopped} | |
/// var finiteStateMachine = new StateMachine<MyStates>(); | |
/// | |
/// // Infinite state machine that can go back to running or init state once stopped | |
/// var infiniteStateMachine = new StateMachine<MyStates>(new Transition[] { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace TestingStuff.Tasks | |
{ | |
/// <summary> | |
/// Syntactic sugar for handling running async processes in the background, without await | |
/// </summary> | |
/// <example> | |
/// <code> | |
/// BackgroundTaskRunner.RunOnce(() => { }); | |
/// BackgroundTaskRunner.Run(async () => { }).EveryMinute(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
<!-- CSS only --> | |
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous"> | |
</head> | |
<body class="p-5" onload="renderLog(document.getElementById('the-log').value)"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.write( | |
[...document.querySelectorAll('img')] | |
.filter(node => node.src?.indexOf('qa.jollyroom.se') > -1) | |
.map(node => node.src.split('?')[0].replace('qa.jollyroom.se', 'qa.jollyroom.shimmercat.cloud')) | |
.map(shimmerCatSrc => '<img src="'+shimmerCatSrc+'">').join('') | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Turn our form data into a JSON string | |
const data ={ | |
... | |
data: { | |
... | |
integrations: [ | |
{type: 'integrationX' ... }, | |
{type: 'integrationY' ... } | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public SomethingController([FromBody] MyDataModel model) { | |
try { | |
DoTheStuff(model); | |
} catch (SpecificExceptionIKnowCanHappen exc) { | |
return BadRequest(new { errorCode = ErrorCode }); | |
} | |
// all other exceptions will let the app crash, exception info will be sen to log and app returns status 500 to the client | |
return Ok(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Controller exempel | |
public class AccountController : Controller | |
{ | |
public async Task<IActionResult> kollaStatusPåBankIdInloggningen(string reference) { | |
// ... massa saker händer... | |
AuthResult result = authClient.AuthorizeReference(...) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.formUtils.addValidator({ | |
name: 'statement', | |
validatorFunction : function(value, $elem, conf, language, $form, eventContext) { | |
var statementIsValid = true, | |
$resultTree = $('<result><node></node></result>'), | |
$current = $resultTree.children().eq(0), | |
invokeNext = true; | |
$.each(value.replace(/\s+/g,' ').split(' '), function (i, str) { | |
if (str == '||') { | |
invokeNext = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
interface State { | |
public function getState(); | |
} | |
abstract class StateAbstract implements State { | |
const STATE_INIT = 'STATE_INIT'; |
NewerOlder