Skip to content

Instantly share code, notes, and snippets.

View simrandotdev's full-sized avatar

Simran simrandotdev

View GitHub Profile
func boundsAndCenter() {
// Do any additional setup after loading the view.
let v1 = UIView(frame: CGRect(x: 110, y: 110, width: 130, height: 200))
v1.backgroundColor = .green
let v2 = UIView(frame: v1.bounds.insetBy(dx: 10, dy: 10))
v2.backgroundColor = .red
view.addSubview(v1)
v1.addSubview(v2)
func boundsAndCenter() {
// Do any additional setup after loading the view.
let v1 = UIView(frame: CGRect(x: 110, y: 110, width: 130, height: 200))
v1.backgroundColor = .green
let v2 = UIView(frame: v1.bounds.insetBy(dx: 10, dy: 10))
v2.backgroundColor = .red
view.addSubview(v1)
v1.addSubview(v2)
@simrandotdev
simrandotdev / settingViewsFrames.swift
Created July 20, 2020 06:53
Setting a Custom UIView inside other UIView
func settingViewsFrames() {
let v1 = UIView(frame: CGRect(x: 113, y: 111, width: 132, height: 194))
v1.backgroundColor = UIColor(red: 1, green: 0.4, blue: 1, alpha: 1)
v1.clipsToBounds = true
let v2 = UIView(frame: CGRect(x: 10, y: 10, width: 112, height: 174))
v2.backgroundColor = UIColor(red: 0.5, green: 1, blue: 0, alpha: 1)
let v3 = UIView(frame: CGRect(x: 43, y: 197, width: 160, height: 230))
v3.backgroundColor = UIColor(red: 1, green: 0, blue: 0, alpha: 1)
@simrandotdev
simrandotdev / UIViewBasics.swift
Created July 20, 2020 06:52
Adding views in other views and checking which view is contained in what UIView
func basicsOfViews() {
let v = UIView(frame: CGRect(x: 100, y: 100, width: 150, height: 150))
v.backgroundColor = .red
self.view.addSubview(v)
v.layer.masksToBounds = true
let v2 = UIView(frame: CGRect(x: 130, y: 140, width: 150, height: 150))
v2.backgroundColor = .yellow
self.view.addSubview(v2)
@simrandotdev
simrandotdev / AndroidXMLProperties.md
Created January 4, 2020 04:07
XML Properties in Android

Android Manifest

android:screenOrientation="portrait"

This property is used in AndroidManifest file inside the activity tag to fix the orientation of the activity at all times.

android:theme="@style/AppTheme.NoActionBar"

This property will set a custom theme to the app or the Activity it is applied to.

android:windowSoftInputMode="adjustResize"

This will adjust the window size when the keyboard appears.

if let fileURL = Bundle.main.url(forResource: "filename", withExtension: "txt") {
if let fileContents = try? String(contentsOf: fileURL) {
// we loaded the file into a string!
}
}
@simrandotdev
simrandotdev / Shape.js
Created October 7, 2019 15:12
Shape.js
function Shape(){
let shape = [];
//shape.totalVolume = totalVolume;
/* Added the function add the shape in the 'shape' array. */
shape.addShape = function (newShape) {
shape.push(newShape);
}
@simrandotdev
simrandotdev / django_deploy.md
Last active April 21, 2019 05:13 — forked from bradtraversy/django_deploy.md
Django Deployment - Digital Ocean

Django Deployment to Ubuntu 18.04

In this guide I will go through all the steps to create a VPS, secure it and deploy a Django application. This is a summarized document from this digital ocean doc

Any commands with "$" at the beginning run on your local machine and any "#" run when logged into the server

Create A Digital Ocean Droplet

Use this link and get $10 free. Just select the $5 plan unless this a production app.

void main() {
final square = Square(side: 10.0);
print(square.area());
}
abstract class Shape {
double area();
}
class Square implements Shape {
@simrandotdev
simrandotdev / DartPad1.dart
Created March 15, 2019 17:07
Functions in Dart
void main() {
String name = 'Simran';
int age = 28;
final double height = 1.84; // You cannot change this variable as it is declared final
var occupation = "Mobile App Developer";
dynamic weight = 90;
describe(name, age, height, occupation, weight);
describe("Jassi", 29, 1.9, "Software Engineer");