Skip to content

Instantly share code, notes, and snippets.

View skellock's full-sized avatar

Steve Kellock skellock

View GitHub Profile
@m-radzikowski
m-radzikowski / script-template.sh
Last active May 4, 2024 04:13
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
import Cocoa
import SwiftUI
public extension View {
func bindWindow(_ window: Binding<NSWindow?>) -> some View {
return background(WindowAccessor(window))
}
}
public struct WindowAccessor: NSViewRepresentable {
@mecid
mecid / Calendar.swift
Last active May 5, 2024 08:43
SwiftUI Calendar view using LazyVGrid
import SwiftUI
extension Calendar {
func generateDates(
inside interval: DateInterval,
matching components: DateComponents
) -> [Date] {
var dates: [Date] = []
dates.append(interval.start)
@ebababi
ebababi / Dockerfile
Created November 10, 2019 20:17
Ruby on Rails Deployment Image: Builds a ready to be deployed image of a Ruby on Rails application.
# Ruby on Rails Deployment Image
#
# Builds a ready to be deployed image of a Ruby on Rails application.
# https://ebababi.net/dockerfile-for-ruby-on-rails-deployments.html
# Copyright (C) 2019 Nikolaos Anastopoulos, Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
@petedoyle
petedoyle / EdgeToEdge.kt
Last active March 10, 2022 09:59
Kotlin extension functions to simplify edge-to-edge on Android Q
/**
* Applies window transformation flags (WTFs) to aid in supporting
* edge-to-edge layouts on Android Q and higher.
*/
fun Activity?.applyEdgeToEdge(
lightStatusBar: Boolean = false,
lightNavigationBar: Boolean = false,
transparentStatusBar: Boolean = true,
immersive: Boolean = false
) {
extension XCTestCase {
struct AwaitError: Error {}
/**
This function is useful for asynchronous testing and acts as a wrapper around test expectations.
Consider the following example:
```swift
// Let's asume we have an async function with the following signature:
@objcode
objcode / ConcurrencyHelpers.kt
Last active May 2, 2024 08:05
Helpers to control concurrency for one shot requests using Kotlin coroutines.
/* Copyright 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@mashingan
mashingan / crud_web.nim
Last active June 11, 2023 00:45
Simplistic crud example using Jester and Nim
# This example using
# Nim: 0.18.0
# Jester: 0.2.1
# Using Jester >= 0.3.0 is preferrable if your Nim version > 0.18.0
# In case you're using Jester >= 0.3.0, look the syntax different
# in its example because it's not backward compatible
import db_sqlite, asyncdispatch, json, strformat, strutils, sequtils
import jester
@joshjhargreaves
joshjhargreaves / LazyLoadComponent.js
Last active July 27, 2018 16:03
Use lazy requires for screens for React Navigation
//Navigator
const SettingsScreen = createLazyComponent(
() => require('../containers/component').default
);
// ...
const MainStackNavigator = StackNavigator(
{
SettingsScreen: {
screen: SettingsScreen,
@stedi67
stedi67 / elm.nim
Created July 20, 2018 09:58
karax using elm architecture
import patty
import strformat
import strutils
import sugar
include karax / prelude
include karax / kdom
include karax / kajax
type