Skip to content

Instantly share code, notes, and snippets.

@HereOrCode
HereOrCode / Utils.swift
Created August 30, 2021 07:26
SwiftUI-Debug
//
// Utils.swift
// SwiftUIAppleDemo
//
// Created by Apple on 2021/8/30.
//
import Foundation
import SwiftUI
@HereOrCode
HereOrCode / read.md
Created October 17, 2021 04:57
github repo

…or create a new repository on the command line

echo "# fhefh2015.github.io" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin [email protected]:fhefh2015/fhefh2015.github.io.git
git push -u origin main
@HereOrCode
HereOrCode / Codable Nested Data.swift
Last active October 22, 2021 05:03
Swift: Codable Nested Data
import UIKit
import SwiftPrettyPrint
/*
* SwiftPrettyPrint
* https://github.com/YusukeHosonuma/SwiftPrettyPrint
*/
class ViewController: UIViewController {
@HereOrCode
HereOrCode / ScreenRecordPermission.swift
Created November 4, 2021 13:48
Check Screen Record Permission
import Cocoa
struct ScreenRecordPermission {
static var hasPermission: Bool {
permissionCheck()
}
static func permissionCheck() -> Bool {
if #available(macOS 10.15, *) {
let runningApplication = NSRunningApplication.current
@HereOrCode
HereOrCode / notification.swift
Created November 8, 2021 02:18
Deliver an OSX notification with Swift
// Remember: import UserNotifications
func sendNotification(title: String, body: String = "") {
let content = UNMutableNotificationContent()
content.title = title
if body.count > 0 {
content.body = body
}
@HereOrCode
HereOrCode / Switch configuration file.json
Last active November 13, 2021 13:23
Configuration file differences
{
"commands": [
{
"Work": [
{
"cmd": "ping www.bing.com",
"name": "Ping Bing"
},
{
"cmd": "ps aux",
@HereOrCode
HereOrCode / CoreData.md
Created March 7, 2022 11:16
CoreData fetchRequest methods
//  here are the five different ways to set up a fetch request so you’re not caught by surprise:
// 1
let fetchRequest1 = NSFetchRequest<Venue>()
let entity = 
  NSEntityDescription.entity(forEntityName: "Venue",
                             in: managedContext)!
fetchRequest1.entity = entity

// 2
@HereOrCode
HereOrCode / make-your-own-blog-with-jekyll.md
Created April 13, 2022 06:33
Make your own blog with Jekyll

Building a website nowadays is not as hard or expensive as it was in the past. These days, you do not have to learn a crazy programming language to have your site up and running.

Install Jekyll

# First install rbenv
brew install rbenv

# Second install ruby 2.7
# Why, detaill see: https://talk.jekyllrb.com/t/error-no-implicit-conversion-of-hash-into-integer/5890