Skip to content

Instantly share code, notes, and snippets.

View rintoandrews90's full-sized avatar
:octocat:

Rinto Andrews rintoandrews90

:octocat:
View GitHub Profile
struct TaskExample: View {
@State private var source = ""
var body: some View {
ScrollView {
Text(source)
}
.task {
await fetchSource()
}
}
@rintoandrews90
rintoandrews90 / String.swift
Created July 9, 2021 19:28 — forked from kharrison/String.swift
Swift String Playground Examples
// Swift Standard Librray - String
// Keith Harrison http://useyourloaf.com
// Import Foundation if you want to bridge to NSString
import Foundation
// ====
// Initializing a String
// ====
@rintoandrews90
rintoandrews90 / xcframework_generate.md
Created December 25, 2020 07:05 — forked from lalkrishna/xcframework_generate.md
Create xcframework instead of Universal(fat) frameworks.

Advantages of xcframework

  • Support for multiple platforms in the same framework.
  • Support for Swift, Objective-C and C.
  • Support for dynamic frameworks and static libraries.
  • Support for Swift Package Manager.
  • End of fat binaries.

Steps to create Aggregate target:

  1. Open Current framework project
func downsample(imageURL: URL, to pointSize: CGSize, scale: CGFloat) -> UIImage {
let imgeSourceOptions = [kCGImageSourceShouldCache: false] as CFDictionary
let imageSource = CGImageSourceCreateWithURL(imageURL as CFURL, imgeSourceOptions)!
let maxDimensionInPixel = max(pointSize.width, pointSize.height) * scale
let downsampleOptions = [
kCGImageSourceCreateThumbnailFromImageAlways: true,
kCGImageSourceShouldCacheImmediately: true,
kCGImageSourceCreateThumbnailWithTransform: true,
kCGImageSourceThumbnailMaxPixelSize: maxDimensionInPixel
@rintoandrews90
rintoandrews90 / SwiftCallbackHell.swift
Created May 29, 2020 18:55 — forked from rhlsthrm/SwiftCallbackHell.swift
Swift code to use raw Grand Central Dispatch to make requests
import Foundation
var todos = [String: Any]()
let dispatchGroup = DispatchGroup()
for todo in 0..10 {
let url = URL(string: "https://jsonplaceholder.typicode.com/todos/\(todo)")
dispatchGroup.enter()
let task = URLSession.shared.dataTask(with: url!) { (data, response, error) in
@rintoandrews90
rintoandrews90 / smaple.json
Last active April 6, 2020 11:13
samplejson
[
{ "ProductNumber":"GP_1134",
"Description": "Piza",
"StockQuantity":"0",
"SalesPrice":"12",
"SalesPriceCur":"EUR",
"id":"1"
},
{ "ProductNumber":"GPB_1134",
"StockQuantity":"0",
/*****
* Functions statments
* **/
function calcAge(birthyear) {
return 2018-birthyear;
}
var age = calcAge(1989);
console.log(age);
/**********************
* Truthy & falsy values
***/
// falsy values : undefined, null, 0, '', NaN
// truthy valyes: not falsy values
var height;
if (height || height === 0 ) {
console.log('value defined');
/*******
* If / else statments
* */
var firstName = 'john';
var civilStatus = 'single';
if (civilStatus === 'single') {
console.log('single');
} else {
console.log('married');
/***************************
* Basic Operators
*
*/
var year, yearJohn;
// Math operators
year = 2018