Skip to content

Instantly share code, notes, and snippets.

@tera-ny
tera-ny / Entity.pu
Last active October 4, 2019 01:54
FoodTicketEntity(仮)
@startuml
class User {
id: String
}
class Shop {
name: String
imageID: String
bussinessHours: BussinessHours
owner: User
products: <String: [Product]>
import UIKit
class HomeViewController: UIViewController {
private let uniqueKey: String = "hkjladjgaldkjakjl"
...
override func viewWillAppear(_ animated: Bool) {
super.viewDidLoad()
Scheduler.shared.monitors.updateValue( self, forKey: uniqueKey)
}
@startuml models
class Article {
title: string
author: string
text: string
description: string
publishedAt: Date
imageURL: string
}
@tera-ny
tera-ny / Document.swift
Last active March 27, 2023 22:15
Swift + Combine + Firestore
import Foundation
import FirebaseFirestoreSwift
import FirebaseFirestore
import Combine
struct Document<Model: Codable> {
let ref: DocumentReference
let data: Model
static func get(collectionPath: String, id: String) -> Deferred<Future<Document<Model>, Error>> {
.init { () -> Future<Document<Model>, Error> in
@tera-ny
tera-ny / ContentView.swift
Created September 24, 2020 14:17
How to create a TextView with a ScrollView as a parent in SwiftUI.
import SwiftUI
struct ContentView: View {
var body: some View {
GeometryReader { proxy in
ScrollView(content: {
VStack {
Text("lorem ipsum").bold().font(.title2)
TextView(text: """
https://ja.wikipedia.org/wiki/Lorem_ipsum
@tera-ny
tera-ny / Readme.md
Last active November 21, 2020 15:04
Propose a product cell layout that supports aspect-fill images with SwiftUI components
@tera-ny
tera-ny / Ex+View.swift
Created May 9, 2021 13:47
Controlling which methods are enabled by starting with the bool flag in SwiftUI Component
//
// Ex+View.swift
// OrangeJuice
//
// Created by tera_ny on 2021/05/09.
//
import SwiftUI
extension View {
#include <stdio.h>
int my_strlen(char* s) {
int count = 0;
while (s[count] != '\0')
{
count++;
}
return count;
}
#include <stdio.h>
char* my_strcpy(char* to, const char* from) {
size_t i;
for (i = 0; from[i] != '\0'; i++) {
to[i] = from[i];
}
to[i] = '\0';
return to;
}
@tera-ny
tera-ny / simulate.py
Created October 13, 2021 14:15
ネットワーク品質をシミュレートするシミュレータです。
def simulate(csv, c):
d_prev = 0
result_t = []
result_a = []
for row in csv:
a_i = float(row[0])
l_i = float(row[1])
s_i = l_i*8/c
d_i = max(d_prev, a_i) + s_i
t_i = d_i - a_i