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 / .zshenv
Last active December 28, 2021 21:15
MacBook setup
# Open application (or file with application)
alias vscode='open -a "Visual Studio Code"'
# Shortcut for editing this file
alias envedit='vscode /Users/goranlilja/.zshenv'
# Hide/show desktop icons
alias hideicons='defaults write com.apple.finder CreateDesktop false; killall Finder'
alias showicons='defaults write com.apple.finder CreateDesktop true; killall Finder'
# Jump directly to directories
alias code='cd ~/Code'
# Delete Xcode's Derived Data folder
@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()
}
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 / 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()
@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

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
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

@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

file="$HOME/.id"
if [ ! -f $file ]
then
uuidgen >> $file
fi
cat $file
@GoranLilja
GoranLilja / README.md
Last active June 9, 2020 07:59
Git init

git init

git remote add origin [email protected]:GoranLilja/ParticleNoiseFieldProcessing.git

git checkout -b master

git pull origin master

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