Skip to content

Instantly share code, notes, and snippets.

View fjeldstad's full-sized avatar
🦄

Anders Fjeldstad fjeldstad

🦄
View GitHub Profile

Keybase proof

I hereby claim:

  • I am fjeldstad on github.
  • I am hihaj (https://keybase.io/hihaj) on keybase.
  • I have a public key ASBYXxk2CnVB20Dx1bfMa6nTXJhQG-OJbplVRb9zFm7zkQo

To claim this, I am signing this object:

@fjeldstad
fjeldstad / kvantstrategier.md
Last active September 4, 2018 07:04
Kvantstrategier

Kvantstrategier

#investering

Trendande värde

Screeningmetod

  1. Filtrera fram bolag med börsvärde >= 500 mkr, exkludera finansbolag (banker, investment, fastighet) samt ev. oönskade branscher (betting & spel).
  2. Filtrera bort bolag med där information saknas för nyckeltalen P/E, P/B, P/S, P/FCF, EV/EBITDA.
  3. Ersätt negativa värden med 100000 för nyckeltalen P/E, P/B, P/S, P/FCF, EV/EBITDA. (Detta för att inte enskilda dåliga värden ska få för stor inverkan på helheten.)
  4. Ranka bolagen på följande nyckeltal:
    • P/E (pris/vinst) - stigande

Keybase proof

I hereby claim:

  • I am hihaj on github.
  • I am hihaj (https://keybase.io/hihaj) on keybase.
  • I have a public key ASAb8hcqj8zXB1t0q4LNP0GpP1xqiMWLQklP-qkZ098W5wo

To claim this, I am signing this object:

const service, { sendCommand, query, publishEvent } = require('microservice');
const accountSuspensionService = service('account-suspension');
accountSuspensionService.onCommand('suspend-account', async function (command) {
const { id, reason } = command.payload;
const account = await query('get-account-by-id', { id });
if (account.status !== 'active') {
throw new Error(`Suspending an account requires status 'active', was instead '${account.status}'.`);
}
@fjeldstad
fjeldstad / index.html
Last active October 5, 2016 09:40
A practical choo app starter kit with ES2015 support and reasonably small bundle footprint.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>hello-choo</title>
</head>
<body>
<script src="static/bundle.js"></script>
</body>
</html>
@fjeldstad
fjeldstad / strip-non-printable-unicode-characters.js
Last active October 13, 2021 17:09
Removing all (or perhaps just "common") non-printable Unicode characters - except line breaks - from a string in JavaScript. (Adaptation of http://stackoverflow.com/questions/21284228/removing-control-characters-in-utf-8-string?lq=1)
const trimmed = problematicString.replace(/[\x00-\x09\x0B-\x0C\x0E-\x1F\x7F-\x9F]/g, '');
public abstract class Saga<TState> where TState : class
{
private const int MaxMessageHandlingRetryAttemptsPerMessage = 3;
private const int MillisecondsBetweenMessageHandlingAttempts = 500;
private readonly List<Func<IBus, string, Task>> _registrations = new List<Func<IBus, string, Task>>();
protected void When<TMessage>(
Func<TMessage, Task<IMemory>> accessMemory,
Func<TMessage, TState, Task<ITransformResult>> transform) where TMessage : class
public class CustomerRevenueSaga : Saga<CustomerRevenue>
{
public CustomerRevenueSaga(ICustomerRevenueStore store)
{
When<OrderPlaced>(
accessMemory: async msg => new Memory(await store.GetByCustomerId(msg.CustomerId), store.Save),
transform: (msg, state) =>
{
var nextState = state?.Clone() ?? new CustomerRevenue { CustomerId = msg.CustomerId };
nextState.PendingOrderAmounts[msg.Id] = msg.Amount;
public class CustomerRevenueNode :
Node<CustomerRevenueNode.State>,
Node<CustomerRevenueNode.State>.IHandle<OrderPlaced>,
Node<CustomerRevenueNode.State>.IHandle<OrderCancelled>,
Node<CustomerRevenueNode.State>.IHandle<OrderDelivered>
{
public class State
{
public Guid CustomerId { get; set; }
public decimal AggregatedRevenue { get; set; }
public interface INode
{
}
public interface IMessageToPublish
{
object Message { get; }
TimeSpan? Delay { get; }
}