Skip to content

Instantly share code, notes, and snippets.

Kevin Sjöberg KevinSjoberg

Block or report user

Report or block KevinSjoberg

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View fibonacci.hs
fib 0 = 0
fib 1 = 1
fib n = fib (n-1) + fib(n-2)
fastFib n = go 1 1 n
where
go _ _ 0 = 0
go n1 _ 1 = n1
go n1 n2 counter = go n2 (n1+n2) (counter -1)
View overwrite.hs
overwrite x = let x = 2
in
let x = 4
in
x
View lexical.hs
counter = let x = x + 1
in
let x = x + 1
in
x
lambdaCounter = (\x ->
(\x ->
(\x -> x) x
@KevinSjoberg
KevinSjoberg / Main.elm
Created Dec 8, 2019
Advent of Code - Day 2 (Problem A)
View Main.elm
module Day02A exposing (..)
import Array exposing (Array, fromList, get, set, toList)
import Maybe exposing (withDefault)
input : List Int
input =
[ 1, 0, 0, 3, 1, 1, 2, 3, 1, 3, 4, 3, 1, 5, 0, 3, 2, 1, 6, 19, 1, 9, 19, 23, 2, 23, 10, 27, 1, 27, 5, 31, 1, 31, 6, 35, 1, 6, 35, 39, 2, 39, 13, 43, 1, 9, 43, 47, 2, 9, 47, 51, 1, 51, 6, 55, 2, 55, 10, 59, 1, 59, 5, 63, 2, 10, 63, 67, 2, 9, 67, 71, 1, 71, 5, 75, 2, 10, 75, 79, 1, 79, 6, 83, 2, 10, 83, 87, 1, 5, 87, 91, 2, 9, 91, 95, 1, 95, 5, 99, 1, 99, 2, 103, 1, 103, 13, 0, 99, 2, 14, 0, 0 ]
View aggregate unique values in CouchDB.md

Given the following documents

[
  {
    "id": 1,
    "brand": "Brand A",
    "category": "Category A",
    "colors": [
      "Red",
@KevinSjoberg
KevinSjoberg / filtering-and-sorting-couchdb.md
Last active Sep 16, 2019
Filtering and Sorting using CouchDB
View filtering-and-sorting-couchdb.md

I'm working with a set of products in CouchDB that has the following structure:

{
  "_id": 1,
  "name": "Product 1",
  "brand": "My Brand",
  "prices": [
    { "country": "DNK", "currency": "DKK", "price": 95 },
    { "country": "NOR", "currency": "NOK", "price": 110 }
View react-modal.test.jsx
import React from 'react';
import Modal from 'react-modal';
import { createMemoryHistory } from 'history';
import {
Link,
Route,
Router,
Switch,
} from 'react-router-dom';
import { render, fireEvent } from '@testing-library/react';
View gist:ea472592be07ea1e8d3dc38b3d2ad19a
[shim]: Set up Shim to run with the following parameters:
path to executable: C:\ProgramData\chocolatey\lib\unison\tools\unison 2.48.4 text.exe
working directory: C:\ProgramData\chocolatey\bin
is gui? False
wait for exit? True
command (optional):
[shim]: Command line '"unison 2.48.4 text.exe" --shimgen-log'
[shim]: Current process '"C:\ProgramData\chocolatey\bin\unison 2.48.4 text.exe"'
[shim]: Command line after removing process '"unison 2.48.4 text.exe" --shimgen-log'
[shim]: Shifting off the first argument since process didn't catch it
View README.md

Armstrong Numbers

An Armstrong number is a number that is the sum of its own digits each raised to the power of the number of digits.

For example:

  • 9 is an Armstrong number, because 9 = 9^1 = 9
  • 10 is not an Armstrong number, because 10 != 1^2 + 0^2 = 1
  • 153 is an Armstrong number, because: 153 = 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153
  • 154 is not an Armstrong number, because: 154 != 1^3 + 5^3 + 4^3 = 1 + 125 + 64 = 190
View company_settings.cr
require "json"
module Fortnox::Response
struct CompanySettings
include JSON::Serializable
@[JSON::Field(key: "CompanySettings")]
property company_settings : Resource::CompanySettings
def self.from_response(response : HTTP::Client::Response) : self
You can’t perform that action at this time.