Skip to content

Instantly share code, notes, and snippets.

View Ajaya1000's full-sized avatar
🐵
Learning

Ajaya Mati Ajaya1000

🐵
Learning
View GitHub Profile
extension Array where Element == XLayoutDimensionConstraint {
/// Activates Dimensional Constraints
/// - Parameter childView: child view for which constraints are to be added
func activateConstraints(for childView: UIView) {
getConstraints(for: childView).activate()
}
func getConstraints(for childView: UIView) -> [NSLayoutConstraint] {
return map { constraints in
@Ajaya1000
Ajaya1000 / DataRace.swift
Last active November 17, 2023 11:18
Multithreading in swift
var store: [String: String] = [:]
DispatchQueue.concurrentPerform(iterations: 1_000_000) { i in
store["aKey"] = "\(i)"
_ = store["aKey"]
}
@Ajaya1000
Ajaya1000 / ARC Basic.swift
Created October 31, 2023 07:42
ARC and Closure
class A {
var b: B?
deinit {
print("deinit called for A")
}
}
class B {
var a: A?
@Ajaya1000
Ajaya1000 / SnakeAndLader.swift
Created October 11, 2023 16:01
Snake And ladder Machine Coding
import Foundation
import UIKit
import PlaygroundSupport
struct Point {
var x: Int
var y: Int
}
extension Point {
let x=100,y=100;
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
circle(x,y,100);
x=x+1;
y=y+1;
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
circle(mouseX,mouseY,100);
}
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
frameRate(1); // To visualize the effect
circle(100,200,100); // the fill color will be pink after one call-1 sec
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
circle(100,100,50);
}
function setup() {
frameRate(3);
createCanvas(400,400);
}
function draw() {
background(random(0,255),random(0,255),random(0,255));
}
function setup() {
createCanvas(400, 400);
frameRate(3)
}
function draw() {
background(255,0,0)
}