Skip to content

Instantly share code, notes, and snippets.

View GoranLilja's full-sized avatar

Göran Lilja GoranLilja

  • Freelance software engineer
  • Växjö, Sweden
View GitHub Profile
@GoranLilja
GoranLilja / README.md
Created February 28, 2017 06:08
Drag to dismiss

Drag to dismiss

Steps:

  • Add the view controller that you want to be able to dismiss.
  • From the calling view controller, add an action to present it modally.
  • On the segue, change Presentation value to Over Current Context.
  • See code below.
@GoranLilja
GoranLilja / README.md
Last active June 9, 2020 07:59
Git init

git init

git remote add origin git@github.com:GoranLilja/ParticleNoiseFieldProcessing.git

git checkout -b master

git pull origin master

git branch --set-upstream-to=origin/master master

file="$HOME/.id"
if [ ! -f $file ]
then
uuidgen >> $file
fi
cat $file
@GoranLilja
GoranLilja / README.md
Last active October 30, 2017 11:17
Create directory and change to it

Add a quick way of creating a directory and change to it

  1. Open up your .bash_profile.

    nano ~/.bash_profile

  2. Add the following lines at the bottom of the file.

    mkcd() {
    

mkdir $1

@GoranLilja
GoranLilja / README.md
Created November 17, 2017 07:35
Pull and merge develop into the current branch

Pull and merge develop into the current branch

git pull origin develop

How do I take a screenshot?

In order ro take a screenshot using the macOS system, you have to press a lot or keys, but you also have a few different options.

  • To snap the whole screen, press ++3.
  • To snap a portion of the screen, press ++4, then click and drag to select the area with the mouse.
  • To snap a window, press ++4 followed by Space.
  • You can also open the screen grabbing app itself, Grab.app.

How do I open an app quickly?

The quickest way of opening an app is searching for it using Spotlight.

@GoranLilja
GoranLilja / README.md
Last active February 2, 2018 07:02
Generate self-signed certificate

Steps

Generate a Private Key

openssl genrsa -des3 -out server.key 1024

Generate a CSR (Certificate Signing Request)

openssl req -new -key server.key -out server.csr

Remove Passphrase from Key

cp server.key server.key.org

@GoranLilja
GoranLilja / ViewController.swift
Last active January 19, 2019 21:19
Getting the user's location
import UIKit
import CoreLocation
class ViewController: UIViewController {
let locationManager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
locationManager.delegate = self
locationManager.requestWhenInUseAuthorization()
import UIKit
func create<T>(_ input: T? = nil, _ setup: ((T) -> Void)) -> T where T: NSObject {
let obj = input ?? T()
setup(obj)
return obj
}
func create<T>(_ input: T? = nil, _ setup: ((T) -> Void)) -> T where T: UIView {
let obj = input ?? T()
@GoranLilja
GoranLilja / AppDelegate.swift
Last active May 12, 2024 12:24
Blur app when resigning active
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func applicationWillResignActive(_ application: UIApplication) {
addBlurViews()
}
func applicationDidBecomeActive(_ application: UIApplication) {
removeBlurViews()
}