This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 1) Prereqs | |
| sudo apt update | |
| sudo apt install -y cmake pkg-config build-essential zlib1g-dev liblzma-dev git | |
| # 2) Fetch the last series that still provides SONAME .2 | |
| mkdir -p ~/opt/src && cd ~/opt/src | |
| git clone https://gitlab.gnome.org/GNOME/libxml2.git | |
| cd libxml2 | |
| git checkout v2.12.7 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import WinSDK | |
| // Call a simple Win32 function and pass in strings | |
| MessageBoxA(nil, "Hello from Swift running on Windows", "Swift Message Box", UINT(MB_OK)) | |
| // Call a Win32 function that passes a variable by pointer | |
| var memorySizeInBytes: LONGLONG = 0 | |
| GetPhysicallyInstalledSystemMemory(&memorySizeInBytes) | |
| print("System has \(memorySizeInBytes / 1024 / 1024)GB of RAM installed."); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Adapted from Hacking with SwiftUI, credit to Paul Hudson (@twostraws). | |
| // https://www.hackingwithswift.com/books/ios-swiftui/animating-gestures | |
| import SwiftUI | |
| struct ContentView: View { | |
| @State private var dragAmount = CGSize.zero | |
| var body: some View { | |
| RoundedRectangle(cornerRadius: 10) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// Let's sort this array in reverse alphabetical order. Credit to @JoaquinAlori at @tryolabs for the idea. | |
| let names = ["Mavericks", "Yosemite", "El Capitan", "Sierra", "High Sierra", | |
| "Mojave", "Catalina", "Big Sur", "Monterey", "Ventura", "Sonoma"] | |
| var reversedNames : [String] | |
| /// ✅ Sort method returns true when the first element should be ordered before the second. | |
| func backward(_ a: String, _ b: String) -> Bool { | |
| return a > b | |
| } | |
| reversedNames = names.sorted(by: backward) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct ContentView: View { | |
| @State private var switchSetting = true | |
| @State private var stepperValue = 11 | |
| @State private var dateValue = Date.now | |
| var body: some View { | |
| NavigationView { | |
| Form { | |
| Section { | |
| Toggle("On or off: you choose", isOn: $switchSetting) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Range<T extends num> { | |
| final T from; | |
| final T to; | |
| num get magnitude => to - from; | |
| Range(this.from, this.to); | |
| factory Range.fromList(List<T> list) { | |
| assert(list.length == 2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // A simple example of records and patterns | |
| (double x, double y) getLocation(String name) { | |
| if (name == 'Nairobi') { | |
| return (1.2921, 36.8219); | |
| } | |
| else { | |
| return (0, 0); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| abstract class Animal { | |
| void makeNoise(); | |
| } | |
| class Dog extends Animal { | |
| @override | |
| void makeNoise() => print('Woof'); | |
| } | |
| class Cat extends Animal { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:flutter/material.dart'; | |
| void main() => runApp(const MyApp()); | |
| class MyApp extends StatelessWidget { | |
| const MyApp({Key? key}) : super(key: key); | |
| static const String _title = 'Flutter Code Sample'; | |
| @override |
This file has been truncated, but you can view the full file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1635476713209:Ver:1596173960672524124772:VS-Code:3.27.2:1.32.7:2.15.0 |
NewerOlder