Skip to content

Instantly share code, notes, and snippets.

View freysie's full-sized avatar
💭
I may be slow to respond.

Freya Alminde freysie

💭
I may be slow to respond.
  • 09:17 (UTC +02:00)
View GitHub Profile
@beader
beader / InfiniteScrollChart.swift
Last active January 29, 2024 16:25
Infinite Scrollable Bar Chart using Swift Charts
//
// InfiniteScrollChart.swift
// ChartsGallery
//
// Created by beader on 2022/11/3.
//
import SwiftUI
import Charts
@chriseidhof
chriseidhof / ContentView.swift
Last active March 27, 2024 19:14
Variadic Views
import SwiftUI
struct MyValue: _ViewTraitKey {
static var defaultValue: Int = 0
}
extension View {
func myValue(_ value: Int) -> some View {
_trait(MyValue.self, value)
}
@Ridwy
Ridwy / MTAudioProcessingTapSample.swift
Created July 30, 2021 11:21
How to use MTAudioProcessingTap in Swift 5
//
// Created by Chiharu Nameki @Ridwy on 2021/07/30.
//
import UIKit
import AVFoundation
/*
Using MTAudioProcessingTap, you can touch raw audio samples playing with AVPlayer.
This sample code shows how to use MTAudioProcessingTap in Swift 5.
@me2beats
me2beats / main.gd
Created October 7, 2020 07:28
Godot Engine GDScript snake2camel, snake2pascal, camel2snake, pascal2snake
func snake2camel(string:String)->String:
var result = PoolStringArray()
var prev_is_underscore = false
for ch in string:
if ch=='_':
prev_is_underscore = true
else:
if prev_is_underscore:
result.append(ch.to_upper())
@krummler
krummler / String+EmojiCheck.swift
Last active December 26, 2023 10:21
Emoji Checking for Swift 5.0 and up
import Foundation
extension Character {
/// A simple emoji is one scalar and presented to the user as an Emoji
var isSimpleEmoji: Bool {
return unicodeScalars.count == 1 && unicodeScalars.first?.properties.isEmojiPresentation ?? false
}
/// Checks if the scalars will be merged into and emoji
var isCombinedIntoEmoji: Bool {
@amomchilov
amomchilov / DownloadProgressIndicatorDemo.swift
Last active July 9, 2024 17:56 — forked from mminer/DownloadProgressIndicatorDemo.swift
Displays a progress indicator on a file in the Finder.
import Cocoa
let path = "/Users/You/Pick/Any/Random/File/On/Your/System.txt"
let destination = URL(fileURLWithPath: path)
let progress: Progress = {
let p = Progress(parent: nil, userInfo: [
.fileOperationKindKey: Progress.FileOperationKind.downloading,
.fileURLKey: destination,
])
@vincent-peng
vincent-peng / Data+HexEncodedString.swift
Last active November 26, 2023 14:28
Convert Data to hex string in Swift
// http://stackoverflow.com/a/40089462
extension Data {
func hexEncodedString() -> String {
return map { String(format: "%02hhx", $0) }.joined()
}
}
@michal-tomlein
michal-tomlein / MTSegmentedControl.h
Created August 14, 2015 09:35
An NSSegmentedControl subclass with support for conditional segment selection via a delegate.
//
// MTSegmentedControl.h
//
// Created by Michal Tomlein on 14/08/15.
// Copyright (c) 2015 Michal Tomlein. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@class MTSegmentedControl;
@franciscoadasme
franciscoadasme / gist:1008620
Created June 5, 2011 03:40
How to show a custom title bar icon in NSWindow
// Force to show a titlebar icon
[window setRepresentedURL:[NSURL URLWithString:@"WindowTitle"]];
// Set our custom icon
[[window standardWindowButton:NSWindowDocumentIconButton] setImage:[NSImage imageNamed:@"imagename"]];
...
// Implement window delegate method to prevent to popup document (which do not exist) path menu when cmd+clicked
- (BOOL)window:(NSWindow *)window shouldPopUpDocumentPathMenu:(NSMenu *)menu
{