Skip to content

Instantly share code, notes, and snippets.

View krispykalsi's full-sized avatar
⚒️
Building

Ikroop Singh Kalsi krispykalsi

⚒️
Building
View GitHub Profile
@scriptpapi
scriptpapi / DocumentPicker.swift
Created April 26, 2021 21:25
Document Picker for SwiftUI
import Foundation
import SwiftUI
import UIKit
struct DocumentPicker: UIViewControllerRepresentable {
@Binding var filePath: URL?
func makeCoordinator() -> DocumentPicker.Coordinator {
return DocumentPicker.Coordinator(parent1: self)
@AlexMeuer
AlexMeuer / dart.json
Last active September 29, 2023 07:49
VSCode User Snippets and Settings
{
"Part statement": {
"prefix": "pts",
"body": [
"part '${TM_FILENAME_BASE}.g.dart';",
],
"description": "Creates a filled-in part statement"
},
"Part 'Freezed' statement": {
"prefix": "ptf",
@pierrejoubert73
pierrejoubert73 / markdown-details-collapsible.md
Last active July 24, 2024 07:10
How to add a collapsible section in markdown.

How to add a collapsible section in markdown

1. Example

Click me

Heading

  1. Foo
  2. Bar
    • Baz
  • Qux
@pkuecuekyan
pkuecuekyan / WKWebViewSizeToFit.swift
Last active June 17, 2024 17:44
Adjust height of WKWebView frame based on scrollHeight of the webView's content
// Since the WKWebView has no sizeToFit() method, increase the frame height of the webView to
// match the height of the content's scrollHeight
//
// The WKWebView's `navigationDelegate` property needs to be set for the delegate method to be called
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
if webView.isLoading == false {
webView.evaluateJavaScript("document.body.scrollHeight", completionHandler: { [weak self] (result, error) in
if let height = result as? CGFloat {
@startupcode
startupcode / HtmlToAttributedString.swift
Last active October 3, 2023 01:08
Swift - Assign HTML to NSAttributedString with custom FONT
//Usage
lbl.attributedText = htmlToAttributedString ("html text")
//Assign attributed string
func htmlToAttributedString(string : String) -> NSAttributedString{
var attribStr = NSMutableAttributedString()
do {//, allowLossyConversion: true
attribStr = try NSMutableAttributedString(data: string.dataUsingEncoding(NSUnicodeStringEncoding)!, options: [ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType], documentAttributes: nil)
@jbergen
jbergen / get-fonts
Created November 18, 2014 20:38
Print all available font families and font names (Swift)
for family in UIFont.familyNames() {
let sName: String = family as String
println("family: \(sName)")
for name in UIFont.fontNamesForFamilyName(sName) {
println("name: \(name as String)")
}
}
@itsmattsoria
itsmattsoria / gistfil1.textile
Last active July 3, 2024 05:36
Mac Terminal Cheat Sheet

SHORTCUTS

Key/Command Description
Tab Auto-complete files and folder names
Ctrl + A Go to the beginning of the line you are currently typing on
Ctrl + E Go to the end of the line you are currently typing on
Ctrl + U Clear the line before the cursor
Ctrl + K Clear the line after the cursor
Ctrl + W Delete the word before the cursor
Ctrl + T Swap the last two characters before the cursor