Skip to content

Instantly share code, notes, and snippets.

View donly's full-sized avatar
🎯
Focusing

Tung donly

🎯
Focusing
View GitHub Profile
@pdarcey
pdarcey / SwiftData.md
Last active May 4, 2024 10:30
SwiftData storage on the Mac

SwiftData storage on the Mac

Where does SwiftData store things on the Mac?

Default Storage Location

On iOS, this directory is in the app's own storage location (app_UUID/Library/Application Support) but, on the Mac, it's a shared location in the user's Library.

By default on the Mac, SwiftData stores its model in the /~/Library/Application Support directory as default.store. (It will also add two other files, default.store-shm and default.store-wal, as the model is stored as a SQLite database, and these are these additional files are part of how SQLite works.)

@daffoxdev
daffoxdev / AbstractAdminCrudController.php
Last active December 22, 2023 11:58
EasyAdmin 3.2.7 show records list of another controller inside of details page. Can be used as base to continue the idea
<?php
namespace App\Controller\Admin;
use App\Admin\Field\ControllerIndexField;
use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection;
use EasyCorp\Bundle\EasyAdminBundle\Config\Action;
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore;
@sarunw
sarunw / LandscapeModifier.swift
Created March 16, 2021 03:43
Preview a device in landscape with SwiftUI Previews
struct LandscapeModifier: ViewModifier {
let height = UIScreen.main.bounds.width
let width = UIScreen.main.bounds.height
var isPad: Bool {
return height >= 768
}
var isRegularWidth: Bool {
return height >= 414
@spirillen
spirillen / ffmpeg-add-subtitles.md
Last active January 14, 2024 04:50
Use FFmpeg to add subtitles to video

Use FFmpeg to add subtitles to video

MP4:

ffmpeg -i input.mp4 -f srt -i input.srt -map 0:0 -map 0:1 -map 1:0 -c:v copy \
    -c:a copy -c:s mov_text output.mp4

MKV:

import SwiftUI
import PlaygroundSupport
struct AppleTV: View {
var body: some View {
ZStack {
// Image(uiImage: #imageLiteral(resourceName: "IMG_6281.JPG"))
// .resizable()
// .aspectRatio(contentMode: .fill)
Color.gray
@nickcernis
nickcernis / mariadb-brew-macos.md
Created July 13, 2020 15:13
Install MariaDB with brew on macOS and fix the “access denied” issue

Attempting mysql -u root fails with Access denied for user 'root'@'localhost immediately after doing brew install mariadb and starting mariadb with brew services start mariadb.

To fix it (with MariaDB still running):

  1. sudo mysql then enter your Mac user password
  2. ALTER USER 'root'@'localhost' IDENTIFIED BY 'newrootpassword'; replacing newrootpassword with the password you wish to use for the MariaDB root user.
  3. Ctrl-C to exit mysql.

You should then be able to connect to MariaDB with mysql -u root -p, then entering the root password when prompted.

@yongkyuns
yongkyuns / ffmpeg_example.rs
Created July 7, 2020 23:38
FFMPEG usage in rust using command and raw pixels
use std::io::prelude::*;
use std::process::{Command, Stdio};
fn main() {
let mut child = Command::new("ffmpeg")
// Overwrite file if it already exists
.arg("-y")
// Interpret the information from stdin as "raw video" ...
.arg("-f")
.arg("rawvideo")
@rikumi
rikumi / iconsur.sh
Last active October 24, 2023 06:46
My personal iconsur setup
# See https://github.com/rikumi/iconsur
yarn global add iconsur
sudo iconsur set /Applications/Android\ File\ Transfer.app -k Airdroid
sudo iconsur set /Applications/Android\ Studio.app/ -l -c 7a5 -s 0.8
sudo iconsur set /Applications/DaisyDisk.app/ -l
sudo iconsur set /Applications/Decompressor.app/ -l
sudo iconsur set /Applications/Discord.app/
sudo iconsur set /Applications/Google\ Chrome.app/
sudo iconsur set /Applications/IINA.app/ -l -c 161d22
@ollieatkinson
ollieatkinson / Restorable.swift
Created June 16, 2020 08:43
Restorable - Undo/Redo management of values using Swift 5.1 property wrappers
@propertyWrapper
public struct Restorable<Value> {
public var wrappedValue: Value
public init(wrappedValue: Value, using undoManager: UndoManager = .init()) {
self.wrappedValue = wrappedValue
self.projectedValue = undoManager
}
@Wilsonilo
Wilsonilo / HstackDragDrop.swift
Last active November 2, 2022 01:14
Drag and Drop SwiftUI with ScrollView and HStack
//: HSTack /Scroll View With Drag and Drop
// By Wilson Munoz / @yosoywil
// Inspiration 1: https://gist.github.com/tarasis/f9bac6d98de5433f1ddbadaef02f9a29
// Inspiration 2: https://swiftui-lab.com/drag-drop-with-swiftui/
// Really dirty but functional, need to stress test with several items in the ScrollView/HStack and check memory.
import SwiftUI
import PlaygroundSupport
import Combine