Skip to content

Instantly share code, notes, and snippets.

View felix-larsen's full-sized avatar
🤔
thinking

Felix Larsen felix-larsen

🤔
thinking
View GitHub Profile
@felix-larsen
felix-larsen / xmlToJsonStrings.py
Created April 16, 2023 09:43
Script to convert strings xml from android app to a json file used in flutter using the easy localization package
import os
import json
import xml.etree.ElementTree as ET
def xml_to_json(xml_file):
tree = ET.parse(xml_file)
root = tree.getroot()
strings = {}
for child in root:
@felix-larsen
felix-larsen / buildAndTest.yaml
Created June 9, 2021 20:50
iOS App with CocoaPods Test Automation with GitHub Actions CI
name: Build and Test
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
buildAndTest:
runs-on: macos-latest
steps:
@felix-larsen
felix-larsen / FabDemo.swift
Created March 16, 2021 19:20
Disappearing Floating action button SwiftUI
import SwiftUI
import Combine
struct ContentView: View {
@State var showFab = true
@State var scrollOffset: CGFloat = 0.00
var body: some View {
ScrollView {
VStack (alignment: .leading) {
@felix-larsen
felix-larsen / CustomAppTheme.dart
Last active March 8, 2021 20:01
Custom ThemeData Flutter
import 'package:calendarflutter/style/custom_app_theme_data.dart';
import 'package:flutter/material.dart';
class CustomAppTheme extends InheritedWidget {
CustomAppTheme({
Key key,
@required Widget child,
this.customAppTheme,
}) : super(key: key, child: child);
@felix-larsen
felix-larsen / december25_1.swift
Created December 25, 2020 08:50
25th December solution - Advent of code - swift
let cardsPublicKey = 9033205
let doorsPublicKey = 9281649
let subjectNumber = 7
let cardLoopSize = findLoopSizeFor(publicKey: cardsPublicKey, subjectNumber: subjectNumber)
let doorLoopSize = findLoopSizeFor(publicKey: doorsPublicKey, subjectNumber: subjectNumber)
print(cardLoopSize, doorLoopSize)
@felix-larsen
felix-larsen / december24_1.swift
Created December 24, 2020 07:50
24th December solution - Advent of Code 2020 - swift
let occurences = coordinates.reduce(into: [:]) { counts, coordinate in counts[coordinate, default: 0] += 1 }
print(occurences.filter { $0.value % 2 == 1 }.count)
@felix-larsen
felix-larsen / december23_1.swift
Last active December 23, 2020 11:51
23rd December solution - Advent of code - swift
var currentCup = cups.first!
for _ in 1...100 {
(currentCup,cups) = runMove(currentCup, cups)
}
let parts = cups.split(separator: 1)
var result = [Int]()
if parts.count > 1 {
result = Array(parts[1] + parts[0])
} else {
@felix-larsen
felix-larsen / december22_1.swift
Last active December 22, 2020 07:59
22th December solution - Advent of Code 2020 - swift
while player1Cards.count != 0 && player2Cards.count != 0 {
let card1 = player1Cards.removeFirst()
let card2 = player2Cards.removeFirst()
if card1 > card2 {
player1Cards.append(contentsOf: [card1, card2])
} else {
player2Cards.append(contentsOf: [card2, card1])
}
}
@felix-larsen
felix-larsen / december21_1.swift
Created December 21, 2020 09:15
21th December solution - Advent of Code 2020 - swift
let allPotIngredients = allergiesToIngredients.map{ $0.value }.reduce(Set<String>()) { (all, set) -> Set<String> in
all.union(set)
}
let result = foods.map { $0.0.subtracting(allPotIngredients).count }.reduce(0, +)
print(result)
@felix-larsen
felix-larsen / december20_1.swift
Created December 20, 2020 07:32
20th December solution - Advent Of Code 2020 - swift
import Foundation
struct Tile {
let id: Int
let imageData: [String]
var borders: [String] {
var list = [String]()
list.append(imageData.first!)
list.append(String(imageData.last!))
list.append(String(imageData.map { $0.first! }))