Skip to content

Instantly share code, notes, and snippets.

How to play custom audio on Swift Playgrounds for iPad, using SwiftUI.

import AVFoundation
import SwiftUI
import PlaygroundSupport

struct SwiftUIAudioPlayerView: View {
    
    /// the audio player that will play your audio file. Can't be a local variable.
@hkamran80
hkamran80 / canvas_lms.user.js
Last active August 22, 2020 04:05
Canvas LMS - Keystrokes
// ==UserScript==
// @name Canvas LMS - Keystrokes
// @namespace https://hkamran.com
// @version 1.0.1
// @description Snippets for the Canvas LMS
// @author H. Kamran
// @downloadUrl https://gist.github.com/hkamran80/8f0778b0f5379305674742682cb17b5e/raw/canvas_lms.user.js
// @updateUrl https://gist.github.com/hkamran80/8f0778b0f5379305674742682cb17b5e/raw/canvas_lms.user.js
// @match https://*.instructure.com/courses/*
// @grant none
@stephsharp
stephsharp / README.md
Last active October 22, 2020 00:36
Stack Overflow user profile Dashing widget

Badge Overflow

An exceptionally handsome way to track your Stack Overflow badges.
Note: Badge Overflow now works with all Stack Exchange sites.

Created by Adam & Stephanie Sharp.

User Profile widget

A Dashing widget that

@maxcampolo
maxcampolo / UIView+PassThrough.swift
Last active December 14, 2020 11:07
UIView subclass that is transparent to all touch events besides those on eligible child views.
import UIKit
/**
UIView subclass that is transparent to all touch events besides those on eligible child views.
*/
class TKPassThroughView: UIView {
// MARK - Touch Handling
@mayoff
mayoff / ViewController.m
Created December 20, 2012 04:49
Animate a CALayer's position starting from its current (possibly mid-animation) position.
#import "ViewController.h"
#import <QuartzCore/QuartzCore.h>
@interface ViewController ()
@end
@implementation ViewController {
CALayer *_layer;
}
@aheze
aheze / iPadSwiftPlaygrounds_PlayAudio_SwiftUI.swift
Last active May 22, 2021 22:46
How to play custom audio on Swift Playgrounds for iPad, using SwiftUI. Replace "slow-spring-board" with the name of your audio file.
import AVFoundation
import SwiftUI
import PlaygroundSupport
struct SwiftUIAudioPlayerView: View {
/// the audio player that will play your audio file. Can't be a local variable.
/// Must be a `@State` property because we need to modify it later
@State var audioPlayer: AVAudioPlayer?
// Good
@IBAction func sideMenuClicked(_ sender: UIBarButtonItem) {
statusBarHidden = true
self.navigationController?.additionalSafeAreaInsets.top = 20
UIView.animate(withDuration: Constants.config_shortAnimTime) { () -> Void in
self.setNeedsStatusBarAppearanceUpdate()
}
}
//: A UIKit based Playground for presenting user interface
import UIKit
import PlaygroundSupport
final class SampleCollectionReusableView: UICollectionReusableView {
private let titleLabel = UILabel()
override init(frame: CGRect) {
super.init(frame: frame)
//
// TransactionView.swift
//
// Created by Balazs Erdesz on 2021. 02. 23..
//
import SwiftUI
import Combine
struct TransactionView: View {
else if type == NSFetchedResultsChangeType.move {
// A hackish way to ensure PIN icon is updated.
if let newIndexPath = newIndexPath, let indexPath = indexPath {
if let plainNote = nsPlainNoteProvider.getNSPlainNote(newIndexPath), let noteCell = collectionView.cellForItem(at: indexPath) as? NoteCell {
noteCell.update(
plainNote,
selected: false,
animate: false
)