Skip to content

Instantly share code, notes, and snippets.

View markmals's full-sized avatar

Mark Malstrom markmals

View GitHub Profile
@markmals
markmals / test.component.ts
Last active October 20, 2022 20:03
My Ideal Angular Component Syntax
import { Component, State, Computed, html, css } from '@angular/core'
import FooDirective from './foo.directive.ts'
import FooComponent from './foo.component.ts'
// The `selector` is derived from the class's name and a globally configured selector prefix
// In this case, the selector for this class would be `app-test`, using the default prefix
export class TestComponent implements Component {
@State() foo = ""
@Computed() get bar(): number {
@markmals
markmals / wrangular.ts
Created July 28, 2022 21:18
A sketch for a component library for Angular
// =====================================================================
// FILE: app/routes/index.route.ts
import { Component } from "@angular/core";
import { Paths } from "@remix-run/angular";
import { SidebarListStyle } from "pineappleui";
@Component({
selector: "app-content-view",
template: `
function LandmarkRow({ landmark }) {
return (
<HStack>
<Image source={landmark.image} resizable />
<Text>{landmark.name}</Text>
<Spacer />
</HStack>
)
}
@markmals
markmals / Publisher+passthrough.swift
Created June 30, 2021 00:07
A passthrough operator for Combine Publishers
extension Publisher {
@discardableResult
func passthrough(_ closure: @escaping (Result<Output, Failure>) -> Void) -> AnyPublisher<Output, Failure> {
map { output in
closure(.success(output))
return output
}
.mapError { error in
closure(.failure(error))
return error
@markmals
markmals / Combine+concurrency.swift
Last active June 24, 2021 09:05
Extensions to Apple's Combine framework to interoperate with Swift 5.5's new concurrency features
import Combine
extension Publisher {
var stream: AsyncThrowingStream<Output> {
AsyncThrowingStream(Output.self) { continuation in
let cancellable = sink { completion in
switch completion {
case .finished: continuation.finish()
case .failure(let error): continuation.finish(throwing: error)
}
@markmals
markmals / Emulator.md
Last active October 10, 2023 16:36
Guides for setting up a Linux computer to play video games in emulators
@markmals
markmals / Wiggle.swift
Last active October 13, 2025 14:21
The iOS Home Screen wiggle animation, in SwiftUI
import SwiftUI
extension View {
func wiggling() -> some View {
modifier(WiggleModifier())
}
}
struct WiggleModifier: ViewModifier {
@State private var isWiggling = false
extension Array {
func combine(_ numberOfElements: Int) -> [[Element]] {
guard numberOfElements > 0 else { return [.init()] }
guard let first = first else { return [] }
return Array(dropFirst())
.combine(numberOfElements - 1)
.map { [first] + $0 } +
Array(dropFirst())
.combine(numberOfElements)
@markmals
markmals / transcode.sh
Last active June 16, 2020 01:08
Transcode video files to Apple-compatible HEVC using ffmpeg
if [[ -d "$1" ]]; then
for file in "$1"/**/*(.); do
ext="${file##*.}"
if [[ $ext == "mkv" ]] || [[ $ext == "mp4" ]] || [[ $ext == "avi" ]]; then
transcode "$file"
fi
done
trash "$1"
import tweepy # pip3 install tweepy
import json
from datetime import datetime, timedelta, timezone
CONSUMER_KEY = "**********"
CONSUMER_SECRET = "**********"
def oauthLogin(consumerKey, consumerSecret):
auth = tweepy.OAuthHandler(consumerKey, consumerSecret)
authURL = auth.get_authorization_url()