Skip to content

Instantly share code, notes, and snippets.

Avatar

sonson sonsongithub

View GitHub Profile
@sonsongithub
sonsongithub / dummy.swift
Created Sep 11, 2022
Prevents the window from being displayed for Mac Catalyst.
View dummy.swift
class DummyViewController: UIViewController {
deinit {
print(#function)
}
required init?(coder: NSCoder) {
print(#function)
super.init(coder: coder)
}
View test.swift
if let obj = CommandLine.arguments.first {
print(obj)
}
View gist:7eba0a7e7ed5ac96a64a3daeaeb135e0
tccd Prompting policy for hardened runtime; service: kTCCServiceAppleEvents requires entitlement com.apple.security.automation.apple-events but it is missing for accessing={<TCCDProcess: identifier=com.sonson.HomeConMenu.macOS, pid=632, auid=501, euid=501, binary_path=/Applications/HomeConMenu.app/Contents/MacOS/HomeConMenu>}, requesting={<TCCDProcess: identifier=com.apple.appleeventsd, pid=331, auid=55, euid=55, binary_path=/System/Library/CoreServices/appleeventsd>},
@sonsongithub
sonsongithub / vae_check.py
Created Mar 11, 2022
VAEを作ったときのサイズを合わせるためのツールスクリプト
View vae_check.py
import numpy as np
class Sequential:
def __init__(self, channel=0, height=0, width=0, layers=[], source=True):
print('--------------------------------')
if source:
for layer in layers:
(channel, height, width) = layer.source(channel, height, width)
else:
@sonsongithub
sonsongithub / concurrency.swift
Created Feb 17, 2022
Try to use DispatchSemaphore.
View concurrency.swift
class Controller {
var isProcessing = false
let semaphore = DispatchSemaphore(value: 0)
func doit() async {
do {
print("try")
semaphore.signal()
if isProcessing {
print("busy")
@sonsongithub
sonsongithub / test.swift
Created Feb 17, 2022
swift concurrency
View test.swift
actor Flag {
var value = false
func free() {
value = false
}
func check() -> Bool {
if value == false {
value = true
return false
View derivation.py
class A:
def __init__(self, name):
self.name = name
def doit(self):
print(self.name + " doit by class A")
def dodo(self):
self.doit()
View test_a.py
def hoge(**kwargs):
print(a)
print(kwargs)
a = 10
arg = {}
arg['a'] = 20
hoge(**arg)
View simple_newton_method.rs
// 接線の傾き
fn get_a(x:&f32) -> f32 {
return 3.0 * x * x + 2.0 * x + 2.0;
}
// 接線の切片
fn get_b(x:&f32, n: &f32) -> f32 {
return x * x * x + x * x + 2.0 * x + (3.0 - n) - x * get_a(x);
}
@sonsongithub
sonsongithub / ContentView.swift
Created Aug 11, 2020
Try to start download image according to scrolling the list.
View ContentView.swift
//
// ContentView.swift
// testswiftui
//
// Created by sonson on 2020/08/07.
//
import SwiftUI
import UIKit