Skip to content

Instantly share code, notes, and snippets.

View fpg1503's full-sized avatar
🐥

Francesco fpg1503

🐥
View GitHub Profile
@fpg1503
fpg1503 / flatBoletim.js
Created July 28, 2018 10:30
Making an arbitrary JS Object nicer to work with
// Takes as input something like https://scontent-mad1-1.xx.fbcdn.net/v/t1.0-9/37899360_1857828550996984_1194250836729921536_o.jpg?_nc_cat=0&oh=04a7e8328932298e0f6eeec0764cd5b0&oe=5BD2D7EB
function flatBoletim(boletim) {
const innerAssign = (target, ...sources) => {
sources.forEach(source => {
Object.keys(source).forEach(key => target[key] = Object.assign(target[key] || {}, source[key]))
})
return target
}
const semesters = boletim.reduce((obj, current) => Object.assign({}, obj, {...current}), {})
const entries = Object.entries(semesters)
@fpg1503
fpg1503 / ColorContext+UITraitCollection.swift
Created June 7, 2019 22:12
Dynamic Color Palettes that resolve immediately on older versions
extension ColorContext {
@available(iOS 13.0, *)
init(_ traitCollection: UITraitCollection,
defaultMode: Mode = .light,
defaultElevation: Elevation = .base,
defaultAccessibilityContrast: AccessibilityContrast = .normal) {
mode = {
switch traitCollection.userInterfaceStyle {
case .light: return .light
case .dark: return .dark