Skip to content

Instantly share code, notes, and snippets.

@opsb
opsb / docker-compose.yml
Last active March 20, 2024 17:54
Docker compose for electric
```
version: "3"
services:
db:
image: postgres:16.2
restart: always
ports:
- "15432:5432"
environment:
module View.Grid exposing (view)
import Element exposing (Element, column, el, fill, row, spacing, width)
import List.Extra
type alias Config =
{ itemsPerRow : Int
, horizontalSpacing : Int
, verticalSpacing : Int
@opsb
opsb / NonMutatingArray.swift
Last active February 17, 2022 15:34
Swift extension to add non mutating methods to Array
extension Array {
func inserted(_ element: Element, at index: Int) -> Array<Element> {
return updated({$0.insert(element, at: index)})
}
func appended(_ element: Element) -> Array<Element> {
return updated({$0.append(element)})
}
func appended(contentsOf elements: Array<Element>) -> Array<Element> {
@opsb
opsb / Cursor.elm
Last active February 14, 2022 00:26
elm-ui cursor
module Cursor exposing (cursor, Cursor(..))
import Element exposing (Element, Attribute, htmlAttribute)
import Html.Attributes
cursor : Cursor -> Attribute msg
cursor cursor_ =
htmlAttribute <| Html.Attributes.style "cursor" (cursorName cursor_)
@opsb
opsb / Function based
Created May 20, 2017 19:05
Possible view API styles
view model =
HolyGrail.view
|> HolyGrail.header
(HeaderCard.config
|> HeaderCard.leftGutter Avatar.small
|> HeaderCard.title "Using AI to Detect Emotions in text"
)
|> HolyGrail.body
(ScrollPaneCard.view
[ ChatDay.config
@opsb
opsb / elm-cache-add.sh
Last active November 4, 2021 18:43
Pulls all elm.json dependencies from github and saves in local cache (requires jq to be installed)
#!/bin/sh
set -e
if [ "$(elm --version)" != "0.19.1" ]; then
echo "Globally installed elm 0.19.1 is required"
exit 1
fi
export packages=~/.elm/0.19.1/packages
@opsb
opsb / app_spector_widget.dart
Last active January 27, 2021 10:41
AppSpector flutter widget that supports hot restart
import 'package:appspector/appspector.dart';
import 'package:flutter/material.dart';
class AppSpectorWidget extends StatefulWidget {
final String iosApiKey;
final String androidApiKey;
final Widget child;
AppSpectorWidget(
{@required this.iosApiKey,
{
"Cluster": "arn:aws:ecs:us-west-2:&ExampleAWSAccountNo1;:cluster/default",
"TaskARN": "arn:aws:ecs:us-west-2:&ExampleAWSAccountNo1;:task/default/febee046097849aba589d4435207c04a",
"Family": "query-metadata",
"Revision": "7",
"DesiredStatus": "RUNNING",
"KnownStatus": "RUNNING",
"Limits": {
"CPU": 0.25,
"Memory": 512
{
"DockerId": "c7a6b9b237934e9999f319ea3ccc9da4query-metadata",
"Name": "query-metadata",
"DockerName": "query-metadata",
"Image": "mreferre/eksutils",
"ImageID": "sha256:1b146e73f801617610dcb00441c6423e7c85a7583dd4a65ed1be03cb0e123311",
"Labels": {
"com.amazonaws.ecs.cluster": "arn:aws:ecs:us-west-2:&ExampleAWSAccountNo1;:cluster/default",
"com.amazonaws.ecs.container-name": "query-metadata",
"com.amazonaws.ecs.task-arn": "arn:aws:ecs:us-west-2:&ExampleAWSAccountNo1;:task/default/c7a6b9b237934e9999f319ea3ccc9da4",
@opsb
opsb / gist:0081ce0a211b3f88e6510eafa4ba2198
Created May 25, 2020 18:39
Map operation on a protocol in swift
public protocol Notifier {
associatedtype Event
init()
func send(_ : Event) -> Void
func map<ChildNotifier, ChildEvent>(_ : (Event) -> (ChildEvent)) -> ChildNotifier where ChildNotifier : Notifier, ChildNotifier.Event == ChildEvent
}